Class: Haml::I18n::Extractor::Workflow
- Inherits:
-
Object
- Object
- Haml::I18n::Extractor::Workflow
- Defined in:
- lib/haml-i18n-extractor/flow/workflow.rb
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize(project_path, options = {}) ⇒ Workflow
constructor
A new instance of Workflow.
- #interactive? ⇒ Boolean
- #process_file?(file) ⇒ Boolean
- #run ⇒ Object
- #start_message ⇒ Object
Constructor Details
#initialize(project_path, options = {}) ⇒ Workflow
Returns a new instance of Workflow.
6 7 8 9 10 11 12 13 |
# File 'lib/haml-i18n-extractor/flow/workflow.rb', line 6 def initialize(project_path, = {}) @passed_options = @project_path = project_path @prompter = Haml::I18n::Extractor::Prompter.new unless File.directory?(@project_path) raise Extractor::NotADirectory, "#{@project_path} needs to be a directory!" end end |
Instance Method Details
#files ⇒ Object
19 20 21 22 23 |
# File 'lib/haml-i18n-extractor/flow/workflow.rb', line 19 def files @haml_files ||= Dir.glob(@project_path + "/**/*").select do |file| file.match /.haml$/ end end |
#interactive? ⇒ Boolean
15 16 17 |
# File 'lib/haml-i18n-extractor/flow/workflow.rb', line 15 def interactive? !!@passed_options[:interactive] end |
#process_file?(file) ⇒ Boolean
31 32 33 34 |
# File 'lib/haml-i18n-extractor/flow/workflow.rb', line 31 def process_file?(file) file_index = index_for(file) @prompter.process_file?(file, file_index) end |
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/haml-i18n-extractor/flow/workflow.rb', line 36 def run if interactive? files.each do |haml_path| type = process_file?(haml_path) if type process(haml_path, type) else @prompter.not_processing(haml_path) end end else files.each do |haml_path| process(haml_path, :overwrite) end end end |
#start_message ⇒ Object
25 26 27 28 29 |
# File 'lib/haml-i18n-extractor/flow/workflow.rb', line 25 def file_count = files.size file_names = files.join("\n") @prompter.(file_count, file_names) end |