hub_store 0.10.0 → 0.13.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
  SHA256:
3
- metadata.gz: f201ad7494f23bab6f9eb1938dad969bc434e0d5de26da14cab920414eb9ddae
4
- data.tar.gz: 23ed79127208c4a9db714970302bb9c979cdc225fac2482d8a43e7d10d00c687
3
+ metadata.gz: b28b4357b1bd0d79b8dda3ac19b4d3ee599ff1897fbf228e76b8690e2fb5655d
4
+ data.tar.gz: aa81352822f572d4efc74c5db9b19d2c15613754991e57e5f2c93986f5b0c3b2
5
5
  SHA512:
6
- metadata.gz: e9c54eb576bc9f1739c3be646e200352e3ba77fb73361d4a2f34196c324863fc2f1709212c178273abf2940e3f1956633204441edf85f46610ebe76864a71a24
7
- data.tar.gz: 7e06dd0634abbcf883c8f1ee064e7b219ab9d3b3edf562638f73b9de6e2053015fe3b80a4a509616f4a9a9b47d9c434ba7137f9a989b091c840476c9b2a36392
6
+ metadata.gz: 721377665ae7ee2800d21f03a9bc7080e12db94a6ed8cef0970ae82d76e39994d3686f687cd28f51fedcdc9cc53ddb0137f533e7c7c74e0df6a367cfa9fa758c
7
+ data.tar.gz: 0e2319f46da0b74b80c220b385a9de9071e961029f58ac84cc7516f5c7e1f7d033e361b3d69970a56e12f3c6310d6ae16b48a01d36902a47639d6e1ccc8870ed
data/exe/hub_store CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require "hub_store"
4
4
 
5
+ HubStore::Storage::Database.new.setup
5
6
  HubStore::Cli.run(ARGV)
data/hub_store.gemspec CHANGED
@@ -26,8 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
27
  spec.add_development_dependency "minitest", "~> 5.0"
28
28
  spec.add_development_dependency "pry"
29
- spec.add_development_dependency "vcr"
30
- spec.add_development_dependency "webmock"
31
29
 
32
30
  spec.add_dependency "activerecord"
33
31
  spec.add_dependency "dotenv"
data/lib/hub_store/cli.rb CHANGED
@@ -1,18 +1,9 @@
1
1
  require "hub_store/exporter"
2
-
3
- require "hub_store/storage/database"
4
2
  require "hub_store/storage/import"
5
-
6
3
  require "hub_store/ui"
7
4
 
8
5
  module HubStore
9
6
  class Cli
10
- RESOURCES = {
11
- review_requests: Storage::ReviewRequest,
12
- reviews: Storage::Review,
13
- pull_requests: Storage::PullRequest
14
- }.freeze
15
-
16
7
  def self.run(*args)
17
8
  new(*args).run
18
9
  end
@@ -22,7 +13,7 @@ module HubStore
22
13
  end
23
14
 
24
15
  def run
25
- setup_database
16
+ link_logger_to_ui
26
17
  import_data
27
18
  export_csv
28
19
  end
@@ -31,27 +22,13 @@ module HubStore
31
22
 
32
23
  attr_reader :argv
33
24
 
34
- def setup_database
35
- ui.start("Preparing database")
36
- Storage::Database.new.setup
37
- ui.stop("Done.")
25
+ def link_logger_to_ui
26
+ HubLink.config.logger = ui
38
27
  end
39
28
 
40
29
  def import_data
41
30
  repos.each do |repo|
42
- Storage::Import.new(repo: repo, resources: RESOURCES, start_date: start_date).run do |on|
43
- on.init do |query|
44
- ui.log "\n-- #{query} --"
45
- end
46
-
47
- on.start do |resource|
48
- ui.start("Importing #{resource}")
49
- end
50
-
51
- on.finish do |count|
52
- ui.stop("Total: #{count}")
53
- end
54
- end
31
+ Storage::Import.new(repo: repo, since: since).run
55
32
  end
56
33
  end
57
34
 
@@ -75,8 +52,8 @@ module HubStore
75
52
  argv[0].presence || stop
76
53
  end
77
54
 
78
- def start_date
79
- ENV["START_DATE"]
55
+ def since
56
+ ENV["SINCE"]
80
57
  end
81
58
 
82
59
  def stop
@@ -23,17 +23,22 @@ module HubStore::Storage
23
23
  ActiveRecord::Schema.define do
24
24
  unless ActiveRecord::Base.connection.table_exists?("pull_requests")
25
25
  create_table "pull_requests", force: :cascade do |t|
26
+ t.string "title"
26
27
  t.string "submitter"
27
28
  t.string "number"
28
29
  t.string "labels"
29
30
  t.string "repo"
31
+ t.string "state"
32
+ t.string "html_url"
30
33
  t.integer "approval_time"
31
34
  t.integer "time_to_first_review"
32
35
  t.integer "merge_time"
33
36
  t.integer "additions"
34
- t.integer "review_count"
37
+ t.integer "comments_count"
38
+ t.integer "review_comments_count"
35
39
  t.boolean "straight_approval"
36
40
  t.datetime "closed_at"
41
+ t.datetime "merged_at"
37
42
  t.datetime "created_at", null: false
38
43
  t.datetime "updated_at", null: false
39
44
  end
@@ -45,7 +50,10 @@ module HubStore::Storage
45
50
  t.datetime "submitted_at"
46
51
  t.string "reviewer"
47
52
  t.string "state"
53
+ t.boolean "reply"
54
+ t.string "html_url"
48
55
  t.boolean "approval"
56
+ t.text "body"
49
57
  end
50
58
  end
51
59
 
@@ -1,26 +1,25 @@
1
1
  require "hub_link/importer"
2
- require "hub_store/storage/pull_request"
3
- require "hub_store/storage/review"
4
- require "hub_store/storage/review_request"
2
+ require "hub_store/storage/database"
5
3
 
6
- module HubStore::Storage
7
- class Import
8
- def initialize(repo:, resources:, start_date: nil)
9
- @repo = repo
10
- @resources = resources
11
- @start_date = start_date
12
- end
4
+ module HubStore
5
+ module Storage
6
+ class Import
7
+ def initialize(repo:, since: nil)
8
+ @repo = repo
9
+ @since = since
10
+ end
13
11
 
14
- def run(&block)
15
- HubLink::Importer.run(repo: repo, start_date: start_date, resources: resources, &block)
16
- end
12
+ def run(&block)
13
+ HubLink::Importer.run(repo: repo, since: since, resources: RESOURCES, &block)
14
+ end
17
15
 
18
- private
16
+ private
19
17
 
20
- attr_reader :repo, :resources
18
+ attr_reader :repo, :resources
21
19
 
22
- def start_date
23
- @start_date.presence || PullRequest.for(repo).latest_update
24
- end
20
+ def since
21
+ @since.presence || PullRequest.for(repo).latest_update
22
+ end
23
+ end
25
24
  end
26
25
  end
data/lib/hub_store/ui.rb CHANGED
@@ -2,17 +2,39 @@ require "tty/spinner"
2
2
 
3
3
  module HubStore
4
4
  class Ui
5
+ FORMAT = ":spinner :title :status"
6
+
7
+ def initialize
8
+ @spinner = TTY::Spinner.new(FORMAT, format: :dots_3, hide_cursor: true, interval: 20)
9
+ end
10
+
11
+ def info(progname, &block)
12
+ case progname
13
+ when HubLink::START
14
+ start block.call
15
+ when HubLink::FINISH
16
+ stop block.call
17
+ else
18
+ update block.call
19
+ end
20
+ end
21
+
5
22
  def start(msg)
6
- @spinner = TTY::Spinner.new(":spinner #{msg}...", format: :dots_3)
7
- @spinner.auto_spin
23
+ spinner.update(title: msg, status: nil)
24
+ spinner.auto_spin
8
25
  end
9
26
 
10
- def stop(msg)
11
- @spinner.success("(#{msg})")
27
+ def update(msg)
28
+ spinner.update(status: msg)
12
29
  end
13
30
 
14
- def log(msg)
15
- puts msg
31
+ def stop(msg)
32
+ spinner.update(status: nil)
33
+ spinner.success("(#{msg})")
16
34
  end
35
+
36
+ private
37
+
38
+ attr_reader :spinner
17
39
  end
18
40
  end
@@ -1,3 +1,3 @@
1
1
  module HubStore
2
- VERSION = "0.10.0"
2
+ VERSION = "0.13.0"
3
3
  end
data/lib/hub_store.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  require "dotenv/load"
2
2
  require "hub_store/version"
3
3
  require "hub_store/cli"
4
+ require "hub_store/storage/pull_request"
5
+ require "hub_store/storage/review"
6
+ require "hub_store/storage/review_request"
4
7
 
5
8
  module HubStore
9
+ RESOURCES = {
10
+ review_requests: Storage::ReviewRequest,
11
+ reviews: Storage::Review,
12
+ pull_requests: Storage::PullRequest
13
+ }.freeze
6
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,34 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: vcr
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: webmock
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: activerecord
99
71
  requirement: !ruby/object:Gem::Requirement