Class: RailsFinder::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, output = $stdout) ⇒ Runner

Returns a new instance of Runner.



13
14
15
16
# File 'lib/rails_finder.rb', line 13

def initialize(dir, output = $stdout)
  @dir = dir
  @output = output
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



11
12
13
# File 'lib/rails_finder.rb', line 11

def dir
  @dir
end

#outputObject (readonly)

Returns the value of attribute output.



11
12
13
# File 'lib/rails_finder.rb', line 11

def output
  @output
end

Instance Method Details

#appsObject



28
29
30
31
32
# File 'lib/rails_finder.rb', line 28

def apps
  @apps ||= Dir["#{dir}/**/config/environment.rb"].map do |file|
    App.new(File.expand_path("../..", file))
  end
end


18
19
20
21
22
23
24
25
26
# File 'lib/rails_finder.rb', line 18

def print
  if apps.any?
    apps.sort_by { |a| Naturally.normalize(a.rails_version) }.each do |app|
      output.puts "#{app.basename.ljust(root_width)} #{app.rails_version.ljust(version_width)} #{app.root}"
    end
  else
    output.puts "none found"
  end
end