octokit_issue_export 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +22 -0
- data/Gemfile +14 -1
- data/README.md +20 -4
- data/Rakefile +3 -0
- data/lib/octokit/client/issue_export.rb +24 -24
- data/lib/octokit_issue_export/version.rb +1 -1
- data/octokit_issue_export.gemspec +10 -10
- data/spec/helper.rb +80 -0
- data/spec/octokit/client/issue_export_spec.rb +95 -0
- metadata +9 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e38477fabf995883e73cfb76f28bf9b52404ba5f
|
4
|
+
data.tar.gz: cd389596f72a50ad0e0647248002398b9a12d9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3850ef232393cae4891dcb606d0670235be9fb7e5dd76b68f23ecaa077316646db13b14e555d13dfe645caf977c1625c99aacdb80795b63946022ce08609c33c
|
7
|
+
data.tar.gz: 764d3654fde92dda3f732df49f3e9ed3d6617bfae80204b039e2df6f71ebc3ddec994d0afbd01f22f271e9e6d31659aab455c56ff59513d66978adf98150058b
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 2.0.0
|
5
|
+
|
6
|
+
before_install:
|
7
|
+
- gem update bundler
|
8
|
+
|
9
|
+
script:
|
10
|
+
- bundle exec rake spec
|
11
|
+
|
12
|
+
notifications:
|
13
|
+
email:
|
14
|
+
recipients:
|
15
|
+
- linyows@gmail.com
|
16
|
+
on_success: change
|
17
|
+
on_failure: always
|
18
|
+
irc:
|
19
|
+
on_success: change
|
20
|
+
on_failure: always
|
21
|
+
channels:
|
22
|
+
- 'irc.freenode.org#linyows'
|
data/Gemfile
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
group :development do
|
4
|
+
gem 'pry'
|
5
|
+
gem 'awesome_print'
|
6
|
+
end
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'rspec', '>= 2.14'
|
10
|
+
gem 'rake'
|
11
|
+
gem 'simplecov', require: false
|
12
|
+
gem 'coveralls', require: false
|
13
|
+
gem 'webmock'
|
14
|
+
gem 'vcr'
|
15
|
+
end
|
16
|
+
|
4
17
|
gemspec
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
Octokit IssueExport
|
2
2
|
===================
|
3
3
|
|
4
|
-
[![Gem Version]
|
5
|
-
[
|
4
|
+
[![Gem Version][gem_badge]][gem]
|
5
|
+
[![Build Status][travis_badge]][travis]
|
6
|
+
[![Dependency Status][gemnasium_badge]][gemnasium]
|
7
|
+
[![Code Climate][codeclimate_badge]][codeclimate]
|
8
|
+
[![Coverage Status][coveralls_badge]][coveralls]
|
6
9
|
|
7
|
-
Export issues from projects on GitHub
|
10
|
+
Octokit IssueExport is [Octokit][octokit] extension. Export issues from projects on GitHub.
|
8
11
|
|
9
12
|
Installation
|
10
13
|
------------
|
@@ -63,10 +66,23 @@ Contributing
|
|
63
66
|
Author
|
64
67
|
------
|
65
68
|
|
66
|
-
- [@linyows]
|
69
|
+
- [@linyows][linyows]
|
67
70
|
|
68
71
|
|
69
72
|
License
|
70
73
|
-------
|
71
74
|
|
72
75
|
MIT
|
76
|
+
|
77
|
+
[gem]: https://rubygems.org/gems/octokit_issue_export
|
78
|
+
[gem_badge]: https://badge.fury.io/rb/octokit_issue_export.png
|
79
|
+
[travis]: http://travis-ci.org/linyows/octokit_issue_export
|
80
|
+
[travis_badge]: https://secure.travis-ci.org/linyows/octokit_issue_export.png?branch=master
|
81
|
+
[gemnasium]: https://gemnasium.com/linyows/octokit_issue_export
|
82
|
+
[gemnasium_badge]: https://gemnasium.com/linyows/octokit_issue_export.png?travis
|
83
|
+
[codeclimate]: https://codeclimate.com/github/linyows/octokit_issue_export
|
84
|
+
[codeclimate_badge]: https://codeclimate.com/github/linyows/octokit_issue_export.png
|
85
|
+
[coveralls]: https://coveralls.io/r/linyows/octokit_issue_export
|
86
|
+
[coveralls_badge]: https://coveralls.io/repos/linyows/octokit_issue_export/badge.png?branch=master
|
87
|
+
[octokit]: https://github.com/octokit/octokit.rb
|
88
|
+
[linyows]: https://github.com/linyows
|
data/Rakefile
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
module Octokit
|
2
2
|
class Client
|
3
3
|
module IssueExport
|
4
|
-
def export_issues(
|
4
|
+
def export_issues(repo)
|
5
|
+
puts "[#{repo}]"
|
6
|
+
if repo(repo).has_issues?
|
7
|
+
self._dir_for_export = File.join(%w(.) + repo.split('/'))
|
8
|
+
_export_issues(repo)
|
9
|
+
else
|
10
|
+
puts "- project without issues"
|
11
|
+
end
|
12
|
+
Time.now
|
13
|
+
end
|
14
|
+
|
15
|
+
def export_user_issues(username = nil)
|
5
16
|
username = login if username.nil?
|
6
|
-
repos(username).each { |
|
17
|
+
repos(username).each { |resource| export_issues(resource.full_name) }
|
7
18
|
Time.now
|
8
19
|
end
|
9
20
|
|
10
21
|
def export_organization_issues(organization)
|
11
|
-
org_repos(organization).each { |
|
22
|
+
org_repos(organization).each { |resource| export_issues(resource.full_name) }
|
12
23
|
Time.now
|
13
24
|
end
|
14
25
|
alias :export_org_issues :export_organization_issues
|
15
26
|
|
16
|
-
def
|
17
|
-
puts "[#{repo.full_name}]"
|
18
|
-
if repo(repo.full_name).has_issues?
|
19
|
-
self._dir_for_export = File.join(%w(.) + repo.full_name.split('/'))
|
20
|
-
_export_issues_by_repository(repo.full_name)
|
21
|
-
else
|
22
|
-
puts "- project without issues"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
alias :export_issues_by_repo :export_issues_by_repository
|
26
|
-
|
27
|
-
def _export_issues_by_repository(repo)
|
27
|
+
def _export_issues(repo)
|
28
28
|
%i(open closed).each { |state|
|
29
29
|
page = 1
|
30
30
|
loop do
|
@@ -42,15 +42,6 @@ module Octokit
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
def _output_for_export(number, state, comments, title)
|
46
|
-
puts <<-OUTPUT.gsub(/\s{10}/, '').gsub(/\n/, '')
|
47
|
-
- #{"##{number}".rjust(4)},
|
48
|
-
state: #{state.to_s.rjust(6)},
|
49
|
-
comments: #{comments.to_s.rjust(3)},
|
50
|
-
title: "#{title.to_s}"
|
51
|
-
OUTPUT
|
52
|
-
end
|
53
|
-
|
54
45
|
def _export_issue(repo, issue)
|
55
46
|
data = _dump_resources(issue)
|
56
47
|
|
@@ -71,6 +62,15 @@ module Octokit
|
|
71
62
|
_export_json(data, file)
|
72
63
|
end
|
73
64
|
|
65
|
+
def _output_for_export(number, state, comments, title)
|
66
|
+
puts <<-OUTPUT.gsub(/\s{10}/, '').gsub(/\n/, '')
|
67
|
+
- #{"##{number}".rjust(4)},
|
68
|
+
state: #{state.to_s.rjust(6)},
|
69
|
+
comments: #{comments.to_s.rjust(3)},
|
70
|
+
title: "#{title.to_s}"
|
71
|
+
OUTPUT
|
72
|
+
end
|
73
|
+
|
74
74
|
def _dump_resources(resources)
|
75
75
|
return resources unless resources.respond_to?(:attrs)
|
76
76
|
resources.attrs.each_with_object({}) do |(k,v), result|
|
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'octokit_issue_export/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'octokit_issue_export'
|
8
8
|
spec.version = OctokitIssueExport::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['linyows']
|
10
|
+
spec.email = ['linyows@gmail.com']
|
11
11
|
spec.description = %q{Octokit Extension}
|
12
12
|
spec.summary = %q{Export issues from projects on github}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/linyows/octokit_issue_export'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
21
|
+
spec.add_dependency 'octokit', '~> 2.5.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
25
|
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'octokit_issue_export'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
SimpleCov.start
|
12
|
+
|
13
|
+
require 'json'
|
14
|
+
require 'octokit'
|
15
|
+
require 'rspec'
|
16
|
+
require 'webmock/rspec'
|
17
|
+
|
18
|
+
WebMock.disable_net_connect!(allow: 'coveralls.io')
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'vcr'
|
25
|
+
VCR.configure do |c|
|
26
|
+
c.configure_rspec_metadata!
|
27
|
+
c.default_cassette_options = {
|
28
|
+
:serialize_with => :json,
|
29
|
+
:preserve_exact_body_bytes => true,
|
30
|
+
:decode_compressed_response => true,
|
31
|
+
:record => ENV['TRAVIS'] ? :none : :once
|
32
|
+
}
|
33
|
+
c.cassette_library_dir = 'spec/cassettes'
|
34
|
+
c.hook_into :webmock
|
35
|
+
end
|
36
|
+
|
37
|
+
def stub_delete(url)
|
38
|
+
stub_request(:delete, github_url(url))
|
39
|
+
end
|
40
|
+
|
41
|
+
def stub_get(url)
|
42
|
+
stub_request(:get, github_url(url))
|
43
|
+
end
|
44
|
+
|
45
|
+
def stub_head(url)
|
46
|
+
stub_request(:head, github_url(url))
|
47
|
+
end
|
48
|
+
|
49
|
+
def stub_patch(url)
|
50
|
+
stub_request(:patch, github_url(url))
|
51
|
+
end
|
52
|
+
|
53
|
+
def stub_post(url)
|
54
|
+
stub_request(:post, github_url(url))
|
55
|
+
end
|
56
|
+
|
57
|
+
def stub_put(url)
|
58
|
+
stub_request(:put, github_url(url))
|
59
|
+
end
|
60
|
+
|
61
|
+
def fixture_path
|
62
|
+
File.expand_path("../fixtures", __FILE__)
|
63
|
+
end
|
64
|
+
|
65
|
+
def fixture(file)
|
66
|
+
File.new(fixture_path + '/' + file)
|
67
|
+
end
|
68
|
+
|
69
|
+
def json_response(file)
|
70
|
+
{
|
71
|
+
:body => fixture(file),
|
72
|
+
:headers => {
|
73
|
+
:content_type => 'application/json; charset=utf-8'
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def github_url(url)
|
79
|
+
url =~ /^http/ ? url : "https://api.github.com#{url}"
|
80
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Octokit::Client::IssueExport do
|
4
|
+
let(:owner) { 'linyows' }
|
5
|
+
let(:organization) { 'rails' }
|
6
|
+
let(:repo) { "#{owner}/octokit_issue_export" }
|
7
|
+
|
8
|
+
let(:output_repo) do
|
9
|
+
"[#{repo}]"
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:output_example1) do
|
13
|
+
'- #1, state: open, comments: 0, title: "This issue is test"'
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:output_example2) do
|
17
|
+
'- #2, state: closed, comments: 4, title: "Closed Issue"'
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.export_issues', :vcr do
|
21
|
+
before do
|
22
|
+
expect_any_instance_of(Kernel).to receive(:puts).with(output_repo)
|
23
|
+
expect_any_instance_of(Kernel).to receive(:puts).with(output_example1)
|
24
|
+
expect_any_instance_of(Kernel).to receive(:puts).with(output_example2)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'calls puts, Dir.mkdir and File.open' do
|
28
|
+
expect(Octokit.export_issues repo).not_to be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'requests HTTP' do
|
32
|
+
assert_requested :get, github_url("/repos/#{repo}")
|
33
|
+
assert_requested :get, github_url("/repos/#{repo}/issues?page=1&per_page=100&state=open")
|
34
|
+
assert_requested :get, github_url("/repos/#{repo}/issues?page=2&per_page=100&state=open")
|
35
|
+
assert_requested :get, github_url("/repos/#{repo}/issues?page=1&per_page=100&state=closed")
|
36
|
+
assert_requested :get, github_url("/repos/#{repo}/issues?page=2&per_page=100&state=closed")
|
37
|
+
assert_requested :get, github_url("/repos/#{repo}/issues/1/comments?page=1&per_page=100")
|
38
|
+
assert_requested :get, github_url("/repos/#{repo}/issues/2/comments?page=1&per_page=100")
|
39
|
+
assert_requested :get, github_url("/repos/#{repo}/issues/2/comments?page=2&per_page=100")
|
40
|
+
expect(Octokit.export_issues repo).not_to be_nil
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns export finish time' do
|
44
|
+
expect(Octokit.export_issues repo).to be_kind_of Time
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.export_user_issues' do
|
49
|
+
before do
|
50
|
+
expect_any_instance_of(Octokit::Client).to receive(:repos).with(owner) {
|
51
|
+
1.upto(3).map do |i|
|
52
|
+
repo_name = "#{owner}/repository-#{i}"
|
53
|
+
repo = double('repository')
|
54
|
+
expect(repo).to receive(:full_name) { repo_name }
|
55
|
+
expect_any_instance_of(Octokit::Client).to receive(:export_issues).with(repo_name)
|
56
|
+
repo
|
57
|
+
end
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'calls #repos and #export_issues' do
|
62
|
+
expect(Octokit.export_user_issues owner).not_to be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns time' do
|
66
|
+
expect(Octokit.export_user_issues owner).to be_kind_of Time
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '.export_organization_issues' do
|
71
|
+
before do
|
72
|
+
expect_any_instance_of(Octokit::Client).to receive(:repos).with(organization) {
|
73
|
+
1.upto(3).map do |i|
|
74
|
+
repo_name = "#{owner}/repository-#{i}"
|
75
|
+
repo = double('repository')
|
76
|
+
expect(repo).to receive(:full_name) { repo_name }
|
77
|
+
expect_any_instance_of(Octokit::Client).to receive(:export_issues).with(repo_name)
|
78
|
+
repo
|
79
|
+
end
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'calls #repos and #export_issues' do
|
84
|
+
expect(Octokit.export_organization_issues organization).not_to be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns time' do
|
88
|
+
expect(Octokit.export_organization_issues organization).to be_kind_of Time
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'alias #export_org_issues' do
|
92
|
+
expect(Octokit.respond_to? :export_org_issues).to be_true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit_issue_export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- linyows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
description: Octokit Extension
|
70
56
|
email:
|
71
57
|
- linyows@gmail.com
|
@@ -74,6 +60,8 @@ extensions: []
|
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
76
62
|
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- .travis.yml
|
77
65
|
- Gemfile
|
78
66
|
- LICENSE.txt
|
79
67
|
- README.md
|
@@ -83,6 +71,8 @@ files:
|
|
83
71
|
- lib/octokit_issue_export/client.rb
|
84
72
|
- lib/octokit_issue_export/version.rb
|
85
73
|
- octokit_issue_export.gemspec
|
74
|
+
- spec/helper.rb
|
75
|
+
- spec/octokit/client/issue_export_spec.rb
|
86
76
|
homepage: https://github.com/linyows/octokit_issue_export
|
87
77
|
licenses:
|
88
78
|
- MIT
|
@@ -107,4 +97,6 @@ rubygems_version: 2.0.3
|
|
107
97
|
signing_key:
|
108
98
|
specification_version: 4
|
109
99
|
summary: Export issues from projects on github
|
110
|
-
test_files:
|
100
|
+
test_files:
|
101
|
+
- spec/helper.rb
|
102
|
+
- spec/octokit/client/issue_export_spec.rb
|