Sha256: 8bae2d5d387755bd72ff3429646bc734df7fa1488f76508c51728bea36b60594
Contents?: true
Size: 1000 Bytes
Versions: 1
Compression:
Stored size: 1000 Bytes
Contents
require "rails_finder/version" require "rails_finder/app" require "naturally" module RailsFinder def self.run(dir, output = $stdout) Runner.new(dir, output).print end class Runner attr_reader :dir, :output def initialize(dir, output = $stdout) @dir = dir @output = output end 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 def apps @apps ||= Dir["#{dir}/**/config/environment.rb"].map do |file| App.new(File.expand_path("../..", file)) end end private def root_width @root_label_width = (apps.map { |a| a.basename.length }.max || 0) + 2 end def version_width @version_width ||= (apps.map { |a| a.rails_version.length }.max || 0)+ 2 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_finder-0.0.3 | lib/rails_finder.rb |