github_issue_exporter 0.2.0 → 0.2.1

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: 83363ad95196320642cfe5355440361c0ecbf873
4
- data.tar.gz: 88c3ee537a792ea633a8a006686d47365fdf5a09
3
+ metadata.gz: e6b637b45fea0775f61dbec3788145b2a8fc345e
4
+ data.tar.gz: 67e5feafb6fb20a48d73b1ebeea3e6f00c11f1ca
5
5
  SHA512:
6
- metadata.gz: 4fcc17bad5c974b172e589b085f9c29fb3c705e2757e3b3bdb142c581a182f895999373f79ef259a3e30265471f1a601759e75a50c1e5b938f75521767d64a5a
7
- data.tar.gz: 90dd4ee16a41cb77ba3adf2f234f11fab999926d38637c24ce3e3ba6f0f49184340dd40d5f6c8a1f159da991cdc5a10bd2da812e67d48ed4b08657a66255be9c
6
+ metadata.gz: 540fa1dc0bf08ead897b173d2430da55094498bc147880f39f7ac393e2a6fdcee2be4d53cd7e4cba0aec0c7c3b65078e105cae43eb7524fb6630139bd66f3cde
7
+ data.tar.gz: 079061fdd23c1b48d9a3756481efc76f3b9f6852c823192e5f3e6c3ae8d7bbd346dd78db017b60db67a83dafd7c1a34cb1c8148f118214fc5e3976e1ed23fea6
data/README.md CHANGED
@@ -31,6 +31,8 @@ The Exporter has a couple of options.
31
31
 
32
32
  `--output` Set the directory to store the issues in. By default it is the current directory.
33
33
 
34
+ `--closed` By default, only Open issues are exported. Adding this flag will include Closed ones as well.
35
+
34
36
  The issues will be exported into either a single `issues.json` file or multiple `issue-[NUMBER].json` files.
35
37
 
36
38
  ### Example
@@ -38,6 +40,8 @@ The issues will be exported into either a single `issues.json` file or multiple
38
40
  ```
39
41
  export-github-issues tallwave github_issue_exporter [TOKEN]
40
42
 
43
+ export-github-issues --closed tallwave github_issue_exporter [TOKEN]
44
+
41
45
  export-github-issues --multiple-files --output ~/issues tallwave github_issue_exporter [TOKEN]
42
46
  ```
43
47
 
@@ -61,6 +65,8 @@ import-github-issues --directory ~/issues tallwave github_issue_exporter [TOKEN]
61
65
  ## Roadmap
62
66
 
63
67
  * Better error handling.
68
+ * Properly import closed issues.
69
+ * Create a GitHub 'application' so that the user doesn't need the auth token.
64
70
 
65
71
  ## Contributing
66
72
 
@@ -28,6 +28,8 @@ Example: #{$PROGRAM_NAME} swilliams issue_exporter abcdef
28
28
  --multiple-files Use a separate file for each issue
29
29
  (default: one single file)
30
30
 
31
+ --closed include closed issues (default: false)
32
+
31
33
  -h, --help display this help and exit
32
34
  --version display the version
33
35
 
@@ -39,6 +41,7 @@ HERE
39
41
  super
40
42
  @output = nil
41
43
  @multiple_files = false
44
+ @include_closed_issues = false
42
45
  end
43
46
 
44
47
  def correct_number_of_args(arg_count)
@@ -47,7 +50,8 @@ HERE
47
50
 
48
51
  def define_options(opts)
49
52
  opts.on("-o", "--output ARG") { |arg| @output = arg }
50
- opts.on("--multiple-files") { @multiple_files = true }
53
+ opts.on("--multiple-files") { @multiple_files = true }
54
+ opts.on("--closed") { @include_closed_issues = true }
51
55
  end
52
56
 
53
57
  def process_input(arg, index)
@@ -62,7 +66,9 @@ HERE
62
66
  end
63
67
 
64
68
  def perform_action
65
- options = { path: @output, multiple_files: @multiple_files }
69
+ options = { path: @output,
70
+ multiple_files: @multiple_files,
71
+ include_closed_issues: @include_closed_issues }
66
72
  exporter = IssueExporting::Exporter.new(@owner, @repo, @token, options)
67
73
  exporter.export
68
74
  end
@@ -12,12 +12,14 @@ module IssueExporting
12
12
  @owner = owner
13
13
  @repo = repo
14
14
  @token = token
15
- @outputter = FileOutputter.new options
15
+ @options = options
16
+ outputter_options = options.select { |k,v| [:path, :multiple_files].include? k }
17
+ @outputter = FileOutputter.new outputter_options
16
18
  end
17
19
 
18
20
  def export
19
21
  error_handler = ErrorHandler.new
20
- url = IssueExporting.make_uri @owner, @repo, @token
22
+ url = IssueExporting.make_uri @owner, @repo, @token, @options
21
23
  response = Net::HTTP::get url
22
24
  if err = error_handler.error_message(response)
23
25
  error_handler.handle_error err
@@ -25,7 +27,6 @@ module IssueExporting
25
27
  outputter.write response
26
28
  end
27
29
  end
28
-
29
30
  end
30
31
  end
31
32
 
@@ -1,14 +1,27 @@
1
+ require "open-uri"
2
+
1
3
  module IssueExporting
2
4
  def self.api_url
3
5
  "https://api.github.com/repos/%s/%s/issues?access_token=%s"
4
6
  end
5
7
 
6
- def self.make_url(owner, repo, token)
8
+ def self.make_url(owner, repo, token, options = {})
7
9
  url_format = IssueExporting.api_url
8
- url_format % [owner, repo, token]
10
+ root_url = url_format % [owner, repo, token]
11
+ return root_url unless options[:include_closed_issues] == true
12
+ root_url + "&state=all"
13
+ end
14
+
15
+ def self.make_uri(owner, repo, token, options = {})
16
+ URI.parse IssueExporting.make_url(owner, repo, token, options)
9
17
  end
10
18
 
11
- def self.make_uri(owner, repo, token)
12
- URI.parse IssueExporting.make_url(owner, repo, token)
19
+ def self.turn_options_into_querystring(options)
20
+ querystring = ''
21
+ options.each do |k, v|
22
+ escaped_k, escaped_v = URI::encode(k), URI::encode(v)
23
+ querystring += "#{escaped_k}=#{escaped_v}&"
24
+ end
25
+ querystring.chop
13
26
  end
14
27
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2015 Scott Williams
2
2
 
3
3
  module IssueExporting
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_issue_exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-17 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Download Issues from a GitHub repository.