Class: GAI18n::GitComparison
- Inherits:
-
Object
- Object
- GAI18n::GitComparison
- Defined in:
- lib/gai18n/git_comparison.rb
Instance Attribute Summary collapse
-
#base_git_branch ⇒ Object
readonly
Returns the value of attribute base_git_branch.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
-
#source_root_key ⇒ Object
readonly
Returns the value of attribute source_root_key.
Instance Method Summary collapse
- #changes ⇒ Object
-
#initialize(locale_file) ⇒ GitComparison
constructor
A new instance of GitComparison.
Constructor Details
#initialize(locale_file) ⇒ GitComparison
Returns a new instance of GitComparison.
5 6 7 8 9 10 |
# File 'lib/gai18n/git_comparison.rb', line 5 def initialize(locale_file) @base_git_branch = GAI18n.config.base_git_branch @project_root = GAI18n.config.project_root @source_path = locale_file.source_path @source_root_key = locale_file.source_root_key end |
Instance Attribute Details
#base_git_branch ⇒ Object (readonly)
Returns the value of attribute base_git_branch.
3 4 5 |
# File 'lib/gai18n/git_comparison.rb', line 3 def base_git_branch @base_git_branch end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
3 4 5 |
# File 'lib/gai18n/git_comparison.rb', line 3 def project_root @project_root end |
#source_path ⇒ Object (readonly)
Returns the value of attribute source_path.
3 4 5 |
# File 'lib/gai18n/git_comparison.rb', line 3 def source_path @source_path end |
#source_root_key ⇒ Object (readonly)
Returns the value of attribute source_root_key.
3 4 5 |
# File 'lib/gai18n/git_comparison.rb', line 3 def source_root_key @source_root_key end |
Instance Method Details
#changes ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/gai18n/git_comparison.rb', line 12 def changes git = Git.open(project_root, :log => Logger.new(STDOUT)) diff = git.diff(base_git_branch).path(source_path) base_content = diff.first&.blob(:src)&.contents return [] if base_content.nil? base_yaml = YAML.load(base_content)[source_root_key.to_s] current_yaml = YAML.load_file(source_path)[source_root_key.to_s] keys_with_changed_values(base_yaml, current_yaml) end |