nabokov 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +43 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +113 -0
  6. data/.travis.yml +14 -0
  7. data/CHANGELOG.md +5 -0
  8. data/Gemfile +9 -0
  9. data/LICENSE +21 -0
  10. data/README.md +16 -0
  11. data/Rakefile +22 -0
  12. data/bin/nabokov +5 -0
  13. data/lib/nabokov/commands/runner.rb +22 -0
  14. data/lib/nabokov/commands/setup.rb +75 -0
  15. data/lib/nabokov/commands/syncers/localizations_repo_syncer.rb +101 -0
  16. data/lib/nabokov/commands/syncers/project_syncer.rb +106 -0
  17. data/lib/nabokov/commands/syncers/syncer.rb +68 -0
  18. data/lib/nabokov/core/file_manager.rb +36 -0
  19. data/lib/nabokov/core/nabokovfile.rb +66 -0
  20. data/lib/nabokov/core/nabokovfile_content_validator.rb +51 -0
  21. data/lib/nabokov/core/nabokovfile_keys.rb +34 -0
  22. data/lib/nabokov/git/git_repo.rb +137 -0
  23. data/lib/nabokov/helpers/informator.rb +83 -0
  24. data/lib/nabokov/helpers/merger.rb +86 -0
  25. data/lib/nabokov/models/strings_file.rb +7 -0
  26. data/lib/nabokov/version.rb +8 -0
  27. data/lib/nabokov.rb +14 -0
  28. data/nabokov.gemspec +31 -0
  29. data/spec/fixtures/.DS_Store +0 -0
  30. data/spec/fixtures/README.md +1 -0
  31. data/spec/fixtures/de.strings +1 -0
  32. data/spec/fixtures/en.strings +1 -0
  33. data/spec/fixtures/nabokovfile_example.yaml +9 -0
  34. data/spec/fixtures/nabokovfile_example_invalid.yaml +2 -0
  35. data/spec/fixtures/nabokovfile_example_without_master_branch.yaml +8 -0
  36. data/spec/fixtures/test_git_setup/existed_pre_commit_file +0 -0
  37. data/spec/fixtures/test_git_setup/existed_pre_commit_file_alias +0 -0
  38. data/spec/fixtures/test_git_setup/not_executable_pre_commit_file +0 -0
  39. data/spec/fixtures/test_localizations_repo_syncer/localizations_repo_fixtures/README.md +1 -0
  40. data/spec/fixtures/test_localizations_repo_syncer/nabokovfile.yaml +8 -0
  41. data/spec/fixtures/test_project_syncer/localizations_repo_fixtures/de.strings +2 -0
  42. data/spec/fixtures/test_project_syncer/localizations_repo_fixtures/en.strings +2 -0
  43. data/spec/fixtures/test_project_syncer/project_repo_fixtures/de.strings +2 -0
  44. data/spec/fixtures/test_project_syncer/project_repo_fixtures/en.strings +2 -0
  45. data/spec/fixtures/test_project_syncer/project_repo_fixtures/nabokovfile.yaml +9 -0
  46. data/spec/lib/nabokov/commands/localizations_repo_syncer_spec.rb +137 -0
  47. data/spec/lib/nabokov/commands/project_syncer_spec.rb +61 -0
  48. data/spec/lib/nabokov/commands/runner_spec.rb +7 -0
  49. data/spec/lib/nabokov/commands/setup_spec.rb +101 -0
  50. data/spec/lib/nabokov/commands/syncer_spec.rb +23 -0
  51. data/spec/lib/nabokov/core/file_manager_spec.rb +115 -0
  52. data/spec/lib/nabokov/core/nabokovfile_content_validator_spec.rb +155 -0
  53. data/spec/lib/nabokov/core/nabokovfile_keyes_spec.rb +31 -0
  54. data/spec/lib/nabokov/core/nabokovfile_spec.rb +53 -0
  55. data/spec/lib/nabokov/git/git_repo_spec.rb +670 -0
  56. data/spec/lib/nabokov/helpers/informator_spec.rb +49 -0
  57. data/spec/lib/nabokov/helpers/merger_spec.rb +114 -0
  58. data/spec/lib/nabokov/models/strings_file_spec.rb +7 -0
  59. data/spec/spec_helper.rb +11 -0
  60. metadata +238 -0
@@ -0,0 +1,49 @@
1
+ require "nabokov/helpers/informator"
2
+
3
+ describe Nabokov::Informator do
4
+ let(:ui) { object_double(Cork::Board.new(silent: true, verbose: true)) }
5
+
6
+ describe "show_prompt" do
7
+ it "prints bold greed symbol" do
8
+ expect(ui).to receive(:print).with("> ".bold.green)
9
+ Nabokov::Informator.new(ui).show_prompt
10
+ end
11
+ end
12
+
13
+ describe "say" do
14
+ it "prints plain message" do
15
+ expect(ui).to receive(:puts).with("Hey!")
16
+ Nabokov::Informator.new(ui).say("Hey!")
17
+ end
18
+ end
19
+
20
+ describe "inform" do
21
+ it "prints green message" do
22
+ expect(ui).to receive(:puts).with("Nabokov is working".green)
23
+ Nabokov::Informator.new(ui).inform("Nabokov is working")
24
+ end
25
+ end
26
+
27
+ describe "important" do
28
+ it "prints green message in the box" do
29
+ expect(ui).to receive(:puts).with("------------".green).ordered
30
+ expect(ui).to receive(:puts).with("--- Hey! ---".green).ordered
31
+ expect(ui).to receive(:puts).with("------------".green).ordered
32
+ Nabokov::Informator.new(ui).important("Hey!")
33
+ end
34
+ end
35
+
36
+ describe "error" do
37
+ it "prints red message" do
38
+ expect(ui).to receive(:puts).with("Something went wrong".red)
39
+ Nabokov::Informator.new(ui).error("Something went wrong")
40
+ end
41
+ end
42
+
43
+ describe "warn" do
44
+ it "prints yellow message" do
45
+ expect(ui).to receive(:puts).with("Something went wrong".yellow)
46
+ Nabokov::Informator.new(ui).warn("Something went wrong")
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,114 @@
1
+ require "nabokov/helpers/merger"
2
+ require "git"
3
+
4
+ describe Nabokov::Merger do
5
+ describe "initialize" do
6
+ context "when informator is nil" do
7
+ it "raises an error" do
8
+ git_repo = double(Nabokov::GitRepo)
9
+ expect { Nabokov::Merger.new(nil, git_repo) }.to raise_error("'informator' is a required parameter")
10
+ end
11
+ end
12
+
13
+ context "when git_repo is nil" do
14
+ it "raises an error" do
15
+ informator = double(Nabokov::Informator)
16
+ expect { Nabokov::Merger.new(informator, nil) }.to raise_error("'git_repo' is a required parameter")
17
+ end
18
+ end
19
+ end
20
+
21
+ describe "merge" do
22
+ before do
23
+ @informator = double(Nabokov::Informator)
24
+ @git_repo = double(Nabokov::GitRepo)
25
+ allow(@git_repo).to receive(:local_path).and_return("nabokov/temporary_git_repo")
26
+ @merger = Nabokov::Merger.new(@informator, @git_repo, "1234567890")
27
+ end
28
+
29
+ context "when there are no conflicts" do
30
+ it "succeeds" do
31
+ allow(@git_repo).to receive(:merge_branches).with("master", "synchronization")
32
+ expect(@merger.merge("master", "synchronization")).to eql(Nabokov::MergerResult::SUCCEEDED)
33
+ end
34
+ end
35
+
36
+ context "when there are conflicts" do
37
+ before do
38
+ allow(@git_repo).to receive(:changes?)
39
+ allow(@git_repo).to receive(:merge_branches).with("master", "synchronization").and_raise(Git::GitExecuteError.new("conflicts!!!"))
40
+ allow(@informator).to receive(:error).with(anything)
41
+ allow(@informator).to receive(:ask_with_answers).with(anything, anything)
42
+ end
43
+
44
+ it "shows error" do
45
+ expect(@informator).to receive(:error).with("Merge failed with conflicts. Nabokov needs your help to continue")
46
+ @merger.merge("master", "synchronization")
47
+ end
48
+
49
+ it "asks question how to proceed" do
50
+ expect(@informator).to receive(:ask_with_answers).with("Would you like to resolve the conflicts manually or abort the synchronization?\n", ["resolve", "abort"])
51
+ @merger.merge("master", "synchronization")
52
+ end
53
+
54
+ context "when user wants to abort the merge" do
55
+ before do
56
+ allow(@informator).to receive(:ask_with_answers).with("Would you like to resolve the conflicts manually or abort the synchronization?\n", ["resolve", "abort"]).and_return("abort")
57
+ allow(@git_repo).to receive(:abort_merge)
58
+ allow(@git_repo).to receive(:reset_to_commit).with(anything, anything)
59
+ end
60
+
61
+ it "aborts" do
62
+ expect(@merger.merge("master", "synchronization")).to eql(Nabokov::MergerResult::ABORTED)
63
+ end
64
+
65
+ it "aborts merge in the repo" do
66
+ expect(@git_repo).to receive(:abort_merge)
67
+ @merger.merge("master", "synchronization")
68
+ end
69
+
70
+ it "resets the HEAD to last commit" do
71
+ expect(@git_repo).to receive(:reset_to_commit).with("1234567890", { hard: true })
72
+ @merger.merge("master", "synchronization")
73
+ end
74
+ end
75
+
76
+ context "when user wants to resolve the merge conflicts" do
77
+ before do
78
+ allow(@informator).to receive(:say)
79
+ allow(@informator).to receive(:warn)
80
+ allow(@informator).to receive(:wait_for_return)
81
+ allow(@informator).to receive(:ask_with_answers).with("Would you like to resolve the conflicts manually or abort the synchronization?\n", ["resolve", "abort"]).and_return("resolve")
82
+ allow(@git_repo).to receive(:unmerged_files).and_return(["file1.txt", "file2.txt"])
83
+ allow(@git_repo).to receive(:add).with(anything)
84
+ allow(@git_repo).to receive(:commit).with(anything)
85
+ allow(@git_repo).to receive(:changes?).and_return(true)
86
+ end
87
+
88
+ it "succeeds" do
89
+ expect(@merger.merge("master", "synchronization")).to eql(Nabokov::MergerResult::SUCCEEDED)
90
+ end
91
+
92
+ it "shows the unmerged files pathes" do
93
+ expect(@informator).to receive(:say).with("Great! Please resolve conflict in the following files:")
94
+ expect(@informator).to receive(:say).with("* nabokov/temporary_git_repo/file1.txt")
95
+ expect(@informator).to receive(:say).with("* nabokov/temporary_git_repo/file2.txt")
96
+ expect(@informator).to receive(:say).with("Please press return when you're ready to move on...")
97
+ expect(@informator).to receive(:wait_for_return)
98
+ @merger.merge("master", "synchronization")
99
+ end
100
+
101
+ it "adds merged files to index" do
102
+ expect(@git_repo).to receive(:add).with("nabokov/temporary_git_repo/file1.txt")
103
+ expect(@git_repo).to receive(:add).with("nabokov/temporary_git_repo/file2.txt")
104
+ @merger.merge("master", "synchronization")
105
+ end
106
+
107
+ it "commits merge files" do
108
+ expect(@git_repo).to receive(:commit).with("Nabokov merge conflicts manually have been resolved...")
109
+ @merger.merge("master", "synchronization")
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,7 @@
1
+ require "nabokov/models/strings_file"
2
+
3
+ describe Nabokov::StringsFile do
4
+ it "has a .strings extension" do
5
+ expect(Nabokov::StringsFile.extension).to eql("strings")
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+
3
+ def prepare_repo(future_repo_local_path, initial_repo_fixtures)
4
+ FileUtils.mkdir_p(future_repo_local_path)
5
+ repo = Git.init(future_repo_local_path)
6
+ repo.config("user.name", "nabokov")
7
+ repo.config("user.email", "nabokov@nabokov.com")
8
+ FileUtils.cp_r(initial_repo_fixtures, future_repo_local_path)
9
+ repo.add
10
+ repo.commit("initial commit")
11
+ end
metadata ADDED
@@ -0,0 +1,238 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nabokov
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton Domashnev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: claide
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cork
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.42'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.42'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: |-
112
+ One of the way to work on the localization - store it in the separate github repo
113
+ and asks localization team to update files in that repo.
114
+ This solution brings as well advantages but as well a disadvantages, to minimize the disadvantages
115
+ nabokov was invented. It helps developer to automatically keep remote localzation up to date and
116
+ also remain the project localization up to date as well.
117
+ email:
118
+ - antondomashnev@gmail.com
119
+ executables:
120
+ - nabokov
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".gitattributes"
125
+ - ".gitignore"
126
+ - ".rspec"
127
+ - ".rubocop.yml"
128
+ - ".travis.yml"
129
+ - CHANGELOG.md
130
+ - Gemfile
131
+ - LICENSE
132
+ - README.md
133
+ - Rakefile
134
+ - bin/nabokov
135
+ - lib/nabokov.rb
136
+ - lib/nabokov/commands/runner.rb
137
+ - lib/nabokov/commands/setup.rb
138
+ - lib/nabokov/commands/syncers/localizations_repo_syncer.rb
139
+ - lib/nabokov/commands/syncers/project_syncer.rb
140
+ - lib/nabokov/commands/syncers/syncer.rb
141
+ - lib/nabokov/core/file_manager.rb
142
+ - lib/nabokov/core/nabokovfile.rb
143
+ - lib/nabokov/core/nabokovfile_content_validator.rb
144
+ - lib/nabokov/core/nabokovfile_keys.rb
145
+ - lib/nabokov/git/git_repo.rb
146
+ - lib/nabokov/helpers/informator.rb
147
+ - lib/nabokov/helpers/merger.rb
148
+ - lib/nabokov/models/strings_file.rb
149
+ - lib/nabokov/version.rb
150
+ - nabokov.gemspec
151
+ - spec/fixtures/.DS_Store
152
+ - spec/fixtures/README.md
153
+ - spec/fixtures/de.strings
154
+ - spec/fixtures/en.strings
155
+ - spec/fixtures/nabokovfile_example.yaml
156
+ - spec/fixtures/nabokovfile_example_invalid.yaml
157
+ - spec/fixtures/nabokovfile_example_without_master_branch.yaml
158
+ - spec/fixtures/test_git_setup/existed_pre_commit_file
159
+ - spec/fixtures/test_git_setup/existed_pre_commit_file_alias
160
+ - spec/fixtures/test_git_setup/not_executable_pre_commit_file
161
+ - spec/fixtures/test_localizations_repo_syncer/localizations_repo_fixtures/README.md
162
+ - spec/fixtures/test_localizations_repo_syncer/nabokovfile.yaml
163
+ - spec/fixtures/test_project_syncer/localizations_repo_fixtures/de.strings
164
+ - spec/fixtures/test_project_syncer/localizations_repo_fixtures/en.strings
165
+ - spec/fixtures/test_project_syncer/project_repo_fixtures/de.strings
166
+ - spec/fixtures/test_project_syncer/project_repo_fixtures/en.strings
167
+ - spec/fixtures/test_project_syncer/project_repo_fixtures/nabokovfile.yaml
168
+ - spec/lib/nabokov/commands/localizations_repo_syncer_spec.rb
169
+ - spec/lib/nabokov/commands/project_syncer_spec.rb
170
+ - spec/lib/nabokov/commands/runner_spec.rb
171
+ - spec/lib/nabokov/commands/setup_spec.rb
172
+ - spec/lib/nabokov/commands/syncer_spec.rb
173
+ - spec/lib/nabokov/core/file_manager_spec.rb
174
+ - spec/lib/nabokov/core/nabokovfile_content_validator_spec.rb
175
+ - spec/lib/nabokov/core/nabokovfile_keyes_spec.rb
176
+ - spec/lib/nabokov/core/nabokovfile_spec.rb
177
+ - spec/lib/nabokov/git/git_repo_spec.rb
178
+ - spec/lib/nabokov/helpers/informator_spec.rb
179
+ - spec/lib/nabokov/helpers/merger_spec.rb
180
+ - spec/lib/nabokov/models/strings_file_spec.rb
181
+ - spec/spec_helper.rb
182
+ homepage: https://github.com/Antondomashnev/nabokov
183
+ licenses:
184
+ - MIT
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 2.0.0
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.4.8
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: "Move mobile localization boringness away from you \U0001F3C3"
206
+ test_files:
207
+ - spec/fixtures/.DS_Store
208
+ - spec/fixtures/README.md
209
+ - spec/fixtures/de.strings
210
+ - spec/fixtures/en.strings
211
+ - spec/fixtures/nabokovfile_example.yaml
212
+ - spec/fixtures/nabokovfile_example_invalid.yaml
213
+ - spec/fixtures/nabokovfile_example_without_master_branch.yaml
214
+ - spec/fixtures/test_git_setup/existed_pre_commit_file
215
+ - spec/fixtures/test_git_setup/existed_pre_commit_file_alias
216
+ - spec/fixtures/test_git_setup/not_executable_pre_commit_file
217
+ - spec/fixtures/test_localizations_repo_syncer/localizations_repo_fixtures/README.md
218
+ - spec/fixtures/test_localizations_repo_syncer/nabokovfile.yaml
219
+ - spec/fixtures/test_project_syncer/localizations_repo_fixtures/de.strings
220
+ - spec/fixtures/test_project_syncer/localizations_repo_fixtures/en.strings
221
+ - spec/fixtures/test_project_syncer/project_repo_fixtures/de.strings
222
+ - spec/fixtures/test_project_syncer/project_repo_fixtures/en.strings
223
+ - spec/fixtures/test_project_syncer/project_repo_fixtures/nabokovfile.yaml
224
+ - spec/lib/nabokov/commands/localizations_repo_syncer_spec.rb
225
+ - spec/lib/nabokov/commands/project_syncer_spec.rb
226
+ - spec/lib/nabokov/commands/runner_spec.rb
227
+ - spec/lib/nabokov/commands/setup_spec.rb
228
+ - spec/lib/nabokov/commands/syncer_spec.rb
229
+ - spec/lib/nabokov/core/file_manager_spec.rb
230
+ - spec/lib/nabokov/core/nabokovfile_content_validator_spec.rb
231
+ - spec/lib/nabokov/core/nabokovfile_keyes_spec.rb
232
+ - spec/lib/nabokov/core/nabokovfile_spec.rb
233
+ - spec/lib/nabokov/git/git_repo_spec.rb
234
+ - spec/lib/nabokov/helpers/informator_spec.rb
235
+ - spec/lib/nabokov/helpers/merger_spec.rb
236
+ - spec/lib/nabokov/models/strings_file_spec.rb
237
+ - spec/spec_helper.rb
238
+ has_rdoc: