hub_link 0.13.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hub_link.gemspec +1 -0
- data/lib/hub_link/api/logging.rb +17 -0
- data/lib/hub_link/api/pull_request.rb +0 -1
- data/lib/hub_link/batch.rb +13 -2
- data/lib/hub_link/configuration.rb +3 -3
- data/lib/hub_link/importer.rb +4 -13
- data/lib/hub_link/insert.rb +4 -2
- data/lib/hub_link/simple_logger.rb +1 -1
- data/lib/hub_link/stream.rb +0 -1
- data/lib/hub_link/version.rb +1 -1
- data/lib/hub_link.rb +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d6145c12843d700957a88926acba9b90bb56044
|
4
|
+
data.tar.gz: 503ddec7c82a283f13c45da8b6f9ad7c2c679314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f1048505951653140943e01bbd4353d8f9400dd15e7b618efdd6943bee6701af483e026188acd10a4c9a577c1844ecc14df9a9b60409e6617ce6ea90efde8a5
|
7
|
+
data.tar.gz: d205a888fee916b2017a66248fa31dce76c0ed425cf400a3db118dd0ba4d41fba541864a571db1540ab260aef9f628448acdea211831235d779c569395a4381e
|
data/hub_link.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "dotenv"
|
23
23
|
spec.add_dependency "faraday_middleware"
|
24
24
|
spec.add_dependency "octokit"
|
25
|
+
spec.add_dependency "pastel"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.12"
|
27
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module HubLink
|
2
|
+
module Api
|
3
|
+
class Logging < Faraday::Response::Middleware
|
4
|
+
def call(env)
|
5
|
+
message = "#{env[:method].upcase} #{env[:url]}".sub("https://api.github.com/repos", "")
|
6
|
+
logger.info(UPDATE) { message }
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def logger
|
13
|
+
HubLink.logger
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/hub_link/batch.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "pastel"
|
2
|
+
require "hub_link/api/pull_request"
|
3
|
+
|
1
4
|
module HubLink
|
2
5
|
class Batch
|
3
6
|
attr_reader :options
|
@@ -42,18 +45,26 @@ module HubLink
|
|
42
45
|
logger.info(START) { title }
|
43
46
|
|
44
47
|
block.call.tap do |results|
|
45
|
-
logger.info(FINISH) { "Found #{results.size}" }
|
48
|
+
logger.info(FINISH) { pastel.green("Found #{results.size}") }
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
52
|
def fetch_results
|
50
|
-
log "Getting
|
53
|
+
log pastel.bold("Getting PRs: #{formatted_options}") do
|
51
54
|
Api::PullRequest.list(options)
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
58
|
+
def formatted_options
|
59
|
+
options.values.join(", ")
|
60
|
+
end
|
61
|
+
|
55
62
|
def logger
|
56
63
|
HubLink.logger
|
57
64
|
end
|
65
|
+
|
66
|
+
def pastel
|
67
|
+
@_pastel ||= Pastel.new
|
68
|
+
end
|
58
69
|
end
|
59
70
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
+
require "octokit"
|
1
2
|
require "faraday_middleware"
|
2
3
|
require "active_support"
|
3
4
|
require "hub_link/simple_logger"
|
4
|
-
require "hub_link/
|
5
|
-
|
5
|
+
require "hub_link/api/logging"
|
6
6
|
|
7
7
|
module HubLink
|
8
8
|
class Configuration
|
@@ -20,7 +20,7 @@ module HubLink
|
|
20
20
|
|
21
21
|
def middleware
|
22
22
|
Faraday::RackBuilder.new do |builder|
|
23
|
-
builder.use
|
23
|
+
builder.use Api::Logging
|
24
24
|
builder.request :retry
|
25
25
|
builder.use Octokit::Response::RaiseError
|
26
26
|
builder.adapter Faraday.default_adapter
|
data/lib/hub_link/importer.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "hub_link"
|
2
1
|
require "hub_link/insert"
|
3
2
|
|
4
3
|
module HubLink
|
@@ -15,7 +14,6 @@ module HubLink
|
|
15
14
|
|
16
15
|
def run
|
17
16
|
stream.in_batches do |batch|
|
18
|
-
|
19
17
|
resources.each do |source, target|
|
20
18
|
import batch.fetch(source), to: target
|
21
19
|
end
|
@@ -26,21 +24,14 @@ module HubLink
|
|
26
24
|
|
27
25
|
attr_reader :repo, :since, :resources
|
28
26
|
|
29
|
-
def import(records, to:)
|
30
|
-
logger.info(START) { "Storing #{records.size} record(s) " }
|
31
|
-
|
32
|
-
records.each do |row|
|
33
|
-
Insert.new(row: row, target: to).run
|
34
|
-
end
|
35
|
-
logger.info(FINISH) { "Total: #{to.count}" }
|
36
|
-
end
|
37
|
-
|
38
27
|
def stream
|
39
28
|
@_stream ||= Stream.new(repo, since: since)
|
40
29
|
end
|
41
30
|
|
42
|
-
def
|
43
|
-
|
31
|
+
def import(records, to:)
|
32
|
+
records.each do |row|
|
33
|
+
Insert.new(row: row, target: to).run
|
34
|
+
end
|
44
35
|
end
|
45
36
|
end
|
46
37
|
end
|
data/lib/hub_link/insert.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module HubLink
|
2
2
|
class Insert
|
3
|
-
delegate :primary_key, to: :target
|
4
|
-
|
5
3
|
def initialize(row:, target:)
|
6
4
|
@row = row
|
7
5
|
@target = target
|
@@ -21,6 +19,10 @@ module HubLink
|
|
21
19
|
row[primary_key]
|
22
20
|
end
|
23
21
|
|
22
|
+
def primary_key
|
23
|
+
target.primary_key
|
24
|
+
end
|
25
|
+
|
24
26
|
def importable_attributes
|
25
27
|
row.slice(*target_columns)
|
26
28
|
end
|
@@ -2,7 +2,7 @@ module HubLink
|
|
2
2
|
class SimpleLogger < SimpleDelegator
|
3
3
|
def initialize(output = "hub_link.log")
|
4
4
|
logger = Logger.new(output)
|
5
|
-
logger.formatter = ->(_, datetime, _, msg) { "#{datetime
|
5
|
+
logger.formatter = ->(_, datetime, _, msg) { "#{datetime} - #{msg}\n" }
|
6
6
|
__setobj__(logger)
|
7
7
|
end
|
8
8
|
end
|
data/lib/hub_link/stream.rb
CHANGED
data/lib/hub_link/version.rb
CHANGED
data/lib/hub_link.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hub_link
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pastel
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +154,7 @@ files:
|
|
140
154
|
- bin/setup
|
141
155
|
- hub_link.gemspec
|
142
156
|
- lib/hub_link.rb
|
157
|
+
- lib/hub_link/api/logging.rb
|
143
158
|
- lib/hub_link/api/pull_request.rb
|
144
159
|
- lib/hub_link/api/review.rb
|
145
160
|
- lib/hub_link/api/review_request.rb
|