class Shelly::StructureValidator
Public Class Methods
new()
click to toggle source
# File lib/shelly/structure_validator.rb, line 5 def initialize @gemfile_path = "Gemfile" @gemfile_lock_path = "Gemfile.lock" end
Public Instance Methods
config_ru?()
click to toggle source
# File lib/shelly/structure_validator.rb, line 42 def config_ru? repo_paths.include?("config.ru") end
gem?(name)
click to toggle source
# File lib/shelly/structure_validator.rb, line 50 def gem?(name) gems.include?(name) end
gemfile?()
click to toggle source
# File lib/shelly/structure_validator.rb, line 10 def gemfile? repo_paths.include?(@gemfile_path) end
gemfile_engine()
click to toggle source
# File lib/shelly/structure_validator.rb, line 34 def gemfile_engine definition.ruby_version.engine end
gemfile_engine_version()
click to toggle source
# File lib/shelly/structure_validator.rb, line 38 def gemfile_engine_version definition.ruby_version.engine_version end
gemfile_lock?()
click to toggle source
# File lib/shelly/structure_validator.rb, line 14 def gemfile_lock? repo_paths.include?(@gemfile_lock_path) end
gemfile_ruby_patchlevel()
click to toggle source
patchlevel is supported since bundler 1.4.0.rc
# File lib/shelly/structure_validator.rb, line 28 def gemfile_ruby_patchlevel if definition.ruby_version.respond_to?(:patchlevel) definition.ruby_version.patchlevel end end
gemfile_ruby_version()
click to toggle source
# File lib/shelly/structure_validator.rb, line 23 def gemfile_ruby_version definition.ruby_version.version end
gemfile_ruby_version?()
click to toggle source
# File lib/shelly/structure_validator.rb, line 18 def gemfile_ruby_version? return false unless gemfile? && gemfile_lock? definition.ruby_version end
invalid?()
click to toggle source
# File lib/shelly/structure_validator.rb, line 65 def invalid? !valid? end
rakefile?()
click to toggle source
# File lib/shelly/structure_validator.rb, line 46 def rakefile? repo_paths.include?("Rakefile") end
task?(name)
click to toggle source
# File lib/shelly/structure_validator.rb, line 54 def task?(name) tasks.include?("rake #{name}") end
valid?()
click to toggle source
Public: Check all requirements that app has to fulfill
# File lib/shelly/structure_validator.rb, line 59 def valid? gemfile? && gemfile_lock? && gem?("rake") && (gem?("thin") || gem?("puma")) && config_ru? && rakefile? && task?("db:migrate") && task?("db:setup") end
warnings?()
click to toggle source
Public: Check if there are any warnings regarding app structure, these warning don’t prevent from deploying to shelly
# File lib/shelly/structure_validator.rb, line 72 def warnings? !gem?("shelly-dependencies") || gem?("shelly") end
Private Instance Methods
definition()
click to toggle source
# File lib/shelly/structure_validator.rb, line 83 def definition @definition ||= Bundler::Definition.build(@gemfile_path, @gemfile_lock_path, nil) end
gems()
click to toggle source
# File lib/shelly/structure_validator.rb, line 78 def gems return [] unless gemfile? && gemfile_lock? @gems ||= definition.specs.map(&:name) end
repo_paths()
click to toggle source
# File lib/shelly/structure_validator.rb, line 93 def repo_paths @repo_paths ||= begin files = `git ls-files`.split("\n") deleted_files = `git ls-files -d`.split("\n") files - deleted_files end end
tasks()
click to toggle source
# File lib/shelly/structure_validator.rb, line 88 def tasks return [] unless rakefile? @loaded_tasks ||= %x(rake -P).split("\n") end