Class: Prj::App
- Inherits:
-
Object
- Object
- Prj::App
- Defined in:
- lib/prj/app.rb
Class Attribute Summary collapse
-
.config_path ⇒ Object
Returns the value of attribute config_path.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(output, args = []) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(output, args = []) ⇒ App
Returns a new instance of App.
11 12 13 14 |
# File 'lib/prj/app.rb', line 11 def initialize(output, args = []) @letters = String(args.first).each_char.to_a @output = output end |
Class Attribute Details
.config_path ⇒ Object
Returns the value of attribute config_path.
7 8 9 |
# File 'lib/prj/app.rb', line 7 def config_path @config_path end |
Instance Method Details
#config ⇒ Object
30 31 32 33 34 35 |
# File 'lib/prj/app.rb', line 30 def config @config ||= begin config = File.exists?(self.class.config_path) ? YAML.load(File.read(self.class.config_path)) : {} default_config.merge(config) end end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/prj/app.rb', line 16 def run if @letters.empty? @output.puts File.(config.fetch("projects_root")) return 0 end finder = Finder.new(config.fetch("projects_root"), symbolize_keys(config)) filter = Filter.new(@letters, config.fetch("case_sensitive")) directories = finder.find_project_directories filtered_directories = filter.filter(directories) target_directory = File.(File.join(config.fetch("projects_root"), filtered_directories.first.to_s)) @output.puts target_directory 0 end |