Class: MissingTranslation::Util
- Inherits:
-
Object
- Object
- MissingTranslation::Util
- Defined in:
- lib/missing_translation/util.rb
Class Method Summary collapse
- .commit_all_changes(message) ⇒ Object
- .sort(file_pattern = "./config/locales/#{file_extension}/*.yml") ⇒ Object
- .sort_file(filepath) ⇒ Object
- .uncommitted_changes? ⇒ Boolean
Class Method Details
.commit_all_changes(message) ⇒ Object
15 16 17 18 |
# File 'lib/missing_translation/util.rb', line 15 def self.commit_all_changes() status = `git add .` status = system "git commit -m \"#{message}\"" end |
.sort(file_pattern = "./config/locales/#{file_extension}/*.yml") ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/missing_translation/util.rb', line 28 def self.sort(file_pattern = "./config/locales/#{file_extension}/*.yml") file_pathnames = Dir[file_pattern] return unless file_pathnames && file_pathnames.size > 0 file_pathnames.each do |filepath| sort_file(filepath) end end |
.sort_file(filepath) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/missing_translation/util.rb', line 20 def self.sort_file(filepath) content = YAML.load_file(filepath) hash = MissingTranslation::YamlProcessor.denormalize_translations_hash(content) translations = MissingTranslation::YamlProcessor.normalize_translations_hash(hash) File.write(filepath, translations.to_yaml) end |
.uncommitted_changes? ⇒ Boolean
7 8 9 10 11 12 13 |
# File 'lib/missing_translation/util.rb', line 7 def self.uncommitted_changes? status = `git status --porcelain` return false if status.empty? puts "You have uncommitted code. Please commit or stash your changes before continuing" true end |