txgh 5.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 165b2501e313014a2fd9e0103d08a3ebd4799673
4
- data.tar.gz: 0a44161e943e917a9a100515e6f4b4bfb2336df8
3
+ metadata.gz: 9badcf50c28fbfa108cb28d46e8ef1ab30124c90
4
+ data.tar.gz: 630fa6728dc82d464d612b93e026d1d7b11a2ab3
5
5
  SHA512:
6
- metadata.gz: f6e04ae04fd22e0007a272821f7a7a861678117c2ec19cc6402ffad054d1ede439511608bee093c0d39e9d2c4a9e353be14840773b59bd0ee35346d066b667ba
7
- data.tar.gz: 658d4e3a4c6cfe4ef831895e9e0c9568b1f123d7212e324cd14e27a2928e3bcad11b2af7b2ecfa504f05699d9b120126b6dcc66e1085c7730422229692674106
6
+ metadata.gz: fa347e54e198f0f0ba725d82976c8b7fbbd3ca68a3b189a4c0dca453d07894568f7717f3617e3b141046cca416e6e49dec5410267e7da2939b1a6f7c67844b65
7
+ data.tar.gz: a455b27ede3021c35852d08153e4a22407530ee4eec6e8c479cfb1f7bc139e1864ba75a784962848dc6ac7c67c0efdfcf72aa12591bcc7b8115b01d8e93e332e
@@ -46,20 +46,6 @@ module Txgh
46
46
  @logger = options[:logger]
47
47
  end
48
48
 
49
- private
50
-
51
- def branch_resource
52
- @branch_resource ||= TxBranchResource.new(resource, branch)
53
- end
54
-
55
- def resource
56
- @resource ||= tx_config.resource(resource_slug)
57
- end
58
-
59
- def tx_config
60
- @tx_config ||= Txgh::Config::TxManager.tx_config(project, repo, branch)
61
- end
62
-
63
49
  end
64
50
  end
65
51
  end
@@ -4,25 +4,14 @@ module Txgh
4
4
  class PullHandler < Handler
5
5
 
6
6
  def execute
7
- languages.each do |language|
8
- next unless project.supported_language?(language['language_code'])
9
-
10
- committer.commit_resource(
11
- branch_resource, branch, language['language_code']
12
- )
13
- end
14
-
7
+ puller.pull_slug(resource_slug)
15
8
  respond_with(200, true)
16
9
  end
17
10
 
18
11
  private
19
12
 
20
- def committer
21
- @committer ||= Txgh::ResourceCommitter.new(project, repo, logger)
22
- end
23
-
24
- def languages
25
- @languages ||= project.api.get_languages(project.name)
13
+ def puller
14
+ @puller ||= Txgh::Puller.new(project, repo, branch)
26
15
  end
27
16
 
28
17
  end
@@ -4,15 +4,14 @@ module Txgh
4
4
  class PushHandler < Handler
5
5
 
6
6
  def execute
7
- ref = repo.api.get_ref(repo.name, branch)
8
- updater.update_resource(branch_resource, ref[:object][:sha])
7
+ pusher.push_slug(resource_slug)
9
8
  respond_with(200, true)
10
9
  end
11
10
 
12
11
  private
13
12
 
14
- def updater
15
- @updater ||= Txgh::ResourceUpdater.new(project, repo, logger)
13
+ def pusher
14
+ @pusher ||= Txgh::Pusher.new(project, repo, branch)
16
15
  end
17
16
 
18
17
  end
@@ -0,0 +1,57 @@
1
+ module Txgh
2
+ class Puller
3
+ attr_reader :project, :repo, :branch
4
+
5
+ def initialize(project, repo, branch = nil)
6
+ @project = project
7
+ @repo = repo
8
+ @branch = branch
9
+ end
10
+
11
+ def pull
12
+ tx_config.resources.each do |tx_resource|
13
+ if repo.process_all_branches?
14
+ tx_resource = Txgh::TxBranchResource.new(tx_resource, branch)
15
+ end
16
+
17
+ pull_resource(tx_resource)
18
+ end
19
+ end
20
+
21
+ def pull_resource(tx_resource)
22
+ each_language do |language_code|
23
+ committer.commit_resource(tx_resource, branch, language_code)
24
+ end
25
+ end
26
+
27
+ def pull_slug(resource_slug)
28
+ pull_resource(tx_config.resource(resource_slug, branch))
29
+ end
30
+
31
+ private
32
+
33
+ def committer
34
+ @committer ||= Txgh::ResourceCommitter.new(project, repo)
35
+ end
36
+
37
+ def each_language
38
+ return to_enum(__method__) unless block_given?
39
+
40
+ languages.each do |language|
41
+ language_code = language['language_code']
42
+
43
+ if project.supported_language?(language_code)
44
+ yield language_code
45
+ end
46
+ end
47
+ end
48
+
49
+ def languages
50
+ @languages ||= project.api.get_languages(project.name)
51
+ end
52
+
53
+ def tx_config
54
+ @tx_config ||= Txgh::Config::TxManager.tx_config(project, repo, branch)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,40 @@
1
+ module Txgh
2
+ class Pusher
3
+ attr_reader :project, :repo, :branch
4
+
5
+ def initialize(project, repo, branch = nil)
6
+ @project = project
7
+ @repo = repo
8
+ @branch = branch
9
+ end
10
+
11
+ def push
12
+ tx_config.resources.each do |tx_resource|
13
+ if repo.process_all_branches?
14
+ tx_resource = Txgh::TxBranchResource.new(tx_resource, branch)
15
+ end
16
+
17
+ push_resource(tx_resource)
18
+ end
19
+ end
20
+
21
+ def push_resource(tx_resource)
22
+ ref = repo.api.get_ref(repo.name, branch || repo.branch)
23
+ updater.update_resource(tx_resource, ref[:object][:sha])
24
+ end
25
+
26
+ def push_slug(resource_slug)
27
+ push_resource(tx_config.resource(resource_slug, branch))
28
+ end
29
+
30
+ private
31
+
32
+ def updater
33
+ @updater ||= Txgh::ResourceUpdater.new(project, repo)
34
+ end
35
+
36
+ def tx_config
37
+ @tx_config ||= Txgh::Config::TxManager.tx_config(project, repo, branch)
38
+ end
39
+ end
40
+ end
data/lib/txgh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Txgh
2
- VERSION = '5.1.0'
2
+ VERSION = '5.2.0'
3
3
  end
data/lib/txgh.rb CHANGED
@@ -16,6 +16,8 @@ module Txgh
16
16
  autoload :Hooks, 'txgh/app'
17
17
  autoload :MergeCalculator, 'txgh/merge_calculator'
18
18
  autoload :ParseConfig, 'txgh/parse_config'
19
+ autoload :Puller, 'txgh/puller'
20
+ autoload :Pusher, 'txgh/pusher'
19
21
  autoload :ResourceCommitter, 'txgh/resource_committer'
20
22
  autoload :ResourceContents, 'txgh/resource_contents'
21
23
  autoload :ResourceDownloader, 'txgh/resource_downloader'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txgh
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Jackowski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-09 00:00:00.000000000 Z
12
+ date: 2016-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abroad
@@ -212,6 +212,8 @@ files:
212
212
  - lib/txgh/handlers/zip_stream_response.rb
213
213
  - lib/txgh/merge_calculator.rb
214
214
  - lib/txgh/parse_config.rb
215
+ - lib/txgh/puller.rb
216
+ - lib/txgh/pusher.rb
215
217
  - lib/txgh/resource_committer.rb
216
218
  - lib/txgh/resource_contents.rb
217
219
  - lib/txgh/resource_downloader.rb