datapimp 1.0.29 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/datapimp/cli/support/data_sync.rb +70 -0
- data/lib/datapimp/cli/sync.rb +26 -0
- data/lib/datapimp/clients/github.rb +1 -1
- data/lib/datapimp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: febfc2f5b9415229b62250b31276eda459a7f109
|
4
|
+
data.tar.gz: fb1ace6736e83d803437b984f2a6b05647b70044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15ca815bd6cfdacb8b910dc54de072eeff350e474174a0efbb512ba1b248c8d39ffb75c03042fc3ecb3d5f9fba17665156111a5084d545e4c2da6d1fc1724539
|
7
|
+
data.tar.gz: da7451e15f8b8b10ca9016b3356206fde39eca3184921df8752d19e00b5bbe38186546ddf6d19c996900a76cfdb34586e0a8e9e9c024a4c6b454b5f55bfa04a5
|
@@ -19,4 +19,74 @@ module Datapimp::DataSync
|
|
19
19
|
puts spreadsheet.to_s
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
class Github
|
24
|
+
attr_reader :options, :repository
|
25
|
+
|
26
|
+
def initialize(repository, options)
|
27
|
+
@repository = repository
|
28
|
+
@options = options
|
29
|
+
end
|
30
|
+
|
31
|
+
def sync_issues
|
32
|
+
issues = client.issues(repository, filter: "all")
|
33
|
+
issues.map! do |issue|
|
34
|
+
%w(comments events labels).each do |rel|
|
35
|
+
issue[rel] = issue.rels[rel].get.data if relations.include?(rel)
|
36
|
+
end
|
37
|
+
issue
|
38
|
+
end
|
39
|
+
serve_output(issues)
|
40
|
+
end
|
41
|
+
|
42
|
+
def sync_issue_comments(issue_id)
|
43
|
+
comments = client.issue_comments(repository, issue_id)
|
44
|
+
serve_output(comments)
|
45
|
+
end
|
46
|
+
|
47
|
+
def sync_milestones
|
48
|
+
milestones = client.milestones(repository)
|
49
|
+
serve_output(milestones)
|
50
|
+
end
|
51
|
+
|
52
|
+
def sync_releases
|
53
|
+
releases = client.releases(repository)
|
54
|
+
serve_output(releases)
|
55
|
+
end
|
56
|
+
|
57
|
+
def sync_commits
|
58
|
+
commits = client.commits(repository)
|
59
|
+
serve_output(commits)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def client
|
65
|
+
@_client ||= Datapimp::Sync.github.api
|
66
|
+
end
|
67
|
+
|
68
|
+
def relations
|
69
|
+
@_relations ||= @options.relations.to_a
|
70
|
+
end
|
71
|
+
|
72
|
+
def serve_output(output)
|
73
|
+
if output.is_a?(Array)
|
74
|
+
output.map! do |o|
|
75
|
+
o.respond_to?(:to_attrs) ? o.send(:to_attrs) : o
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
if @options.format && @options.format == "json"
|
80
|
+
output = JSON.generate(output)
|
81
|
+
end
|
82
|
+
|
83
|
+
if @options.output
|
84
|
+
Pathname(options.output).open("w+") do |f|
|
85
|
+
f.write(output)
|
86
|
+
end
|
87
|
+
else
|
88
|
+
puts output.to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
22
92
|
end
|
data/lib/datapimp/cli/sync.rb
CHANGED
@@ -21,7 +21,9 @@ command "sync data" do |c|
|
|
21
21
|
|
22
22
|
c.option '--type TYPE', String, "What type of source data is this? #{ Datapimp::Sync.data_source_types.join(", ") }"
|
23
23
|
c.option '--output FILE', String, "Write the output to a file"
|
24
|
+
c.option '--format FORMAT', String, "Which format to serialize the output in? valid options are JSON"
|
24
25
|
c.option '--columns NAMES', Array, "Extract only these columns"
|
26
|
+
c.option '--relations NAMES', Array, "Also fetch these relationships on the object if applicable"
|
25
27
|
|
26
28
|
c.example "Syncing an excel file from dropbox ", "datapimp sync data --type dropbox --columns name,description --dropbox-app-key ABC --dropbox-app-secret DEF --dropbox-client-token HIJ --dropbox-client-secret JKL spreadsheets/test.xslx"
|
27
29
|
c.example "Syncing a google spreadsheet", "datapimp sync data --type google-spreadsheet WHATEVER_THE_KEY_IS"
|
@@ -31,6 +33,30 @@ command "sync data" do |c|
|
|
31
33
|
c.action do |args, options|
|
32
34
|
if options.type == "google-spreadsheet" || options.type == "google"
|
33
35
|
Datapimp::DataSync.sync_google_spreadsheet(options, args)
|
36
|
+
|
37
|
+
# TODO
|
38
|
+
# Could totally make this cleaner if we need to support more services
|
39
|
+
elsif options.type == "github-issues"
|
40
|
+
repository = args.shift
|
41
|
+
|
42
|
+
service = Datapimp::DataSync::Github.new(repository, options)
|
43
|
+
service.sync_issues
|
44
|
+
elsif options.type == "github-milestones"
|
45
|
+
repository = args.shift
|
46
|
+
|
47
|
+
service = Datapimp::DataSync::Github.new(repository, options)
|
48
|
+
service.sync_milestones
|
49
|
+
elsif options.type == "github-releases"
|
50
|
+
repository = args.shift
|
51
|
+
|
52
|
+
service = Datapimp::DataSync::Github.new(repository, options)
|
53
|
+
service.sync_releases
|
54
|
+
elsif options.type == "github-issue-comments"
|
55
|
+
repository = args.shift
|
56
|
+
issue = args.shift
|
57
|
+
|
58
|
+
service = Datapimp::DataSync::Github.new(repository, options)
|
59
|
+
service.sync_issue_comments(issue)
|
34
60
|
end
|
35
61
|
end
|
36
62
|
end
|
data/lib/datapimp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datapimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Soeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|