Class: MissingText::Runner

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

Class Method Summary collapse

Class Method Details

.runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/missing_text/runner.rb', line 4

def self.run
  # create a Batch entry that the record can reference in order to group this session
  MissingText::Batch.create

  # start at the root folder and begin performing the diff operation on all inner locale directories

  Dir.glob("#{MissingText.app_root}/#{MissingText.locale_root}*").select{ |file| File.directory?(file)}.each do |directory|
    
    unless self.skip_directories.include?(File.basename(directory))

      # Get a set of locale files and begin performing the diff operation on them
      locale_files = self.get_locale_files(directory)
     
      # set up the file arguments to be passed into the diff engine
      if locale_files.present?
        diff_files = self.get_file_info(locale_files)

        MissingText::Diff.new(diff_files).begin!
      end
    end
  end

  # Also perform this operation for any locale files directly inside of the locale directory

  if MissingText.search_direct_locale

    direct_locale_files = self.skip_files(Dir.glob("#{MissingText.app_root}/#{MissingText.locale_root}*.yml") + 
      Dir.glob("#{MissingText.app_root}/#{MissingText.locale_root}*.rb"), "#{MissingText.app_root}/#{MissingText.locale_root}")

    if direct_locale_files.present?
      direct_locale_files = get_file_info(direct_locale_files)
      MissingText::Diff.new(direct_locale_files).begin!
    end

  end
end