giexp 0.1.0

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.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Katsunori Kanda
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ github Issues Exporter
2
+ ===============
3
+
4
+ *giexp* is a tool to export issues from github. Currently, an available format is json only.
5
+
6
+ Installation
7
+ ------------
8
+ rubygems
9
+
10
+ ```
11
+ $gem install giexp
12
+ ```
13
+
14
+ Usage
15
+ -----
16
+
17
+ ### Export issues for each repositories of the authorized user
18
+
19
+ ```
20
+ $giexp -u someone -p
21
+ ```
22
+
23
+ ### Export issues for each repositories owned by an organization
24
+
25
+ ```
26
+ $giexp -u someone -p -o someorg
27
+ ```
28
+
29
+ Copyright
30
+ ---------
31
+
32
+ Copyright (c) 2012 Katsunori Kanda. <potix2@gmail.com>
33
+
34
+ License
35
+ -------
36
+
37
+ MIT License
38
+
data/Rakefile ADDED
@@ -0,0 +1,106 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ def name
6
+ @name ||= Dir['*.gemspec'].first.split('.').first
7
+ end
8
+
9
+ def version
10
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
11
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
12
+ end
13
+
14
+ def date
15
+ Date.today.to_s
16
+ end
17
+
18
+ def rubyforge_projects
19
+ name
20
+ end
21
+
22
+ def gemspec_file
23
+ "#{name}.gemspec"
24
+ end
25
+
26
+ def gem_file
27
+ "#{name}-#{version}.gem"
28
+ end
29
+
30
+ def replace_header(head, header_name)
31
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
32
+ end
33
+
34
+ #
35
+ # Standard tasks
36
+ #
37
+
38
+ task :default => :spec
39
+
40
+ require 'rspec/core'
41
+ require 'rspec/core/rake_task'
42
+ RSpec::Core::RakeTask.new(:spec) do |spec|
43
+ spec.pattern = FileList['spec/**/*_spec.rb']
44
+ end
45
+
46
+ require 'rdoc/task'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "ghexp #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
55
+
56
+ #
57
+ # Packaging tasks
58
+ #
59
+ desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
60
+ task :release => :build do
61
+ unless `git branch` =~ /^\* master$/
62
+ puts "You must be on the master branch to relase!"
63
+ exit!
64
+ end
65
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
66
+ sh "git tag v#{version}"
67
+ sh "git push origin master"
68
+ sh "git push origin v#{version}"
69
+ sh "gem push pkg/#{name}-#{version}.gem"
70
+ end
71
+
72
+ desc "Build #{gem_file} into the pkg directory"
73
+ task :build => :gemspec do
74
+ sh "mkdir -p pkg"
75
+ sh "gem build #{gemspec_file}"
76
+ sh "mv #{gem_file} pkg"
77
+ end
78
+
79
+ desc "Generate #{gemspec_file}"
80
+ task :gemspec do
81
+ # read spec file and split out manifest section
82
+ spec = File.read(gemspec_file)
83
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
84
+
85
+ # replace name version and date
86
+ replace_header(head, :name)
87
+ replace_header(head, :version)
88
+ replace_header(head, :date)
89
+ #comment this out if your rubyforge_project has a different name
90
+ replace_header(head, :rubyforge_project)
91
+
92
+ # determine file list from git ls-files
93
+ files = `git ls-files`.
94
+ split("\n").
95
+ sort.
96
+ reject { |file| file =~ /^\./ }.
97
+ reject { |file| file =~ /^(rdoc|pkg|examples|ideas|init|site)/ }.
98
+ map { |file| " #{file}" }.
99
+ join("\n")
100
+
101
+ # piece file back together and write
102
+ manifest = " s.files = %w[\n#{files}\n ]\n"
103
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
104
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
105
+ puts "Updated #{gemspec_file}"
106
+ end
data/bin/giexp ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ STDOUT.sync = true
4
+
5
+ $:.unshift File.join(File.dirname(__FILE__), *%w{.. lib})
6
+
7
+ require 'rubygems'
8
+ require 'optparse'
9
+
10
+ def input_password(prompt)
11
+ $stderr.print prompt
12
+ system "stty -echo"
13
+ password = $stdin.gets.chop
14
+ system "stty echo"
15
+
16
+ password
17
+ end
18
+
19
+ begin
20
+ ORIGINAL_ARGV = ARGV.dup
21
+
22
+ options = {}
23
+ opts = OptionParser.new do |opts|
24
+ opts.banner = <<-EOF
25
+ Usage:
26
+ giexp <options>
27
+
28
+ Options:
29
+ -h, --help Print Help
30
+ EOF
31
+
32
+ opts.on("-u User", "--user USER", "User") do |x|
33
+ options[:login] = x
34
+ end
35
+
36
+ opts.on("-p [PASSWORD]", "--password [PASSWORD]", "Password") do |x|
37
+ if x
38
+ options[:password] = x
39
+ else
40
+ options[:require_password] = true
41
+ end
42
+ end
43
+
44
+ opts.on("-o ORGANIZATION", "--organization ORGANIZATION", "Organization name") do |x|
45
+ options[:organization] = x
46
+ end
47
+
48
+ # opts.on("-f FORMAT", "--format", "Output format [json|csv]") do |x|
49
+ # options[:format] = x
50
+ # end
51
+
52
+ opts.on("-v", "--version", "Print the version number and exit") do
53
+ options[:version] = true
54
+ end
55
+ end
56
+
57
+ opts.parse!
58
+
59
+ # if ARGV.size >= 1
60
+ # options[:repository] = ARGV.shift
61
+ # else
62
+ # options[:all] = true
63
+ # end
64
+ options[:all] = true
65
+
66
+ if options[:require_password]
67
+ options[:password] = input_password("password: ")
68
+ options.delete(:require_password)
69
+ end
70
+
71
+ if !options.key?(:organization) && options.key?(:login)
72
+ options[:user] = options[:login]
73
+ end
74
+
75
+ if options[:version]
76
+ require 'giexp'
77
+ puts "Version #{Giexp.Version}"
78
+ exit
79
+ else
80
+ require 'giexp/run'
81
+ runner = Giexp::Run.new(options)
82
+ runner.start(options)
83
+ end
84
+ rescue Exception => e
85
+ if e.instance_of?(SystemExit)
86
+ raise
87
+ else
88
+ puts 'Uncaught exception'
89
+ puts e.message
90
+ puts e.backtrace.join("\n")
91
+ end
92
+ end
data/giexp.gemspec ADDED
@@ -0,0 +1,57 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.specification_version = 2 if s.respond_to? :specification_version=
4
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
5
+
6
+ s.name = 'giexp'
7
+ s.version = '0.1.0'
8
+ s.date = '2012-03-12'
9
+
10
+ s.summary = "a tool to export issues on github"
11
+ s.description = "a tool to export issues on github"
12
+
13
+ s.author = 'Katsunori Kanda'
14
+ s.email = 'potix2@gmail.com'
15
+ s.homepage = 'http://github.com/potix2/github-issues-exporter/'
16
+
17
+ s.rubyforge_project = "giexp"
18
+ s.rubygems_version = ""
19
+ s.require_paths = %w[ lib ]
20
+
21
+ s.executables = ["giexp"]
22
+
23
+ s.has_rdoc = false
24
+ s.extra_rdoc_files = %w[ README.md ]
25
+
26
+ s.add_development_dependency("rspec", "~> 2.8.0")
27
+ s.add_development_dependency("rake", "~> 0.9")
28
+ s.add_development_dependency("octokit", "~> 1.0.0")
29
+ s.add_development_dependency("webmock", "~> 1.8.2")
30
+
31
+ # = MANIFEST =
32
+ s.files = %w[
33
+ Gemfile
34
+ LICENSE
35
+ README.md
36
+ Rakefile
37
+ bin/giexp
38
+ giexp.gemspec
39
+ lib/giexp.rb
40
+ lib/giexp/client.rb
41
+ lib/giexp/config.rb
42
+ lib/giexp/run.rb
43
+ spec/fixtures/issues_close.json
44
+ spec/fixtures/issues_open.json
45
+ spec/fixtures/repo.json
46
+ spec/fixtures/repos_org.json
47
+ spec/fixtures/repos_user.json
48
+ spec/giexp_spec.rb
49
+ spec/helper.rb
50
+ spec/issues_spec.rb
51
+ spec/repos_spec.rb
52
+ spec/spec_helper.rb
53
+ ]
54
+ # = MANIFEST =
55
+
56
+ s.test_files = s.files.select { |path| path =~ /^spec\/*_spec\.rb/ }
57
+ end
@@ -0,0 +1,51 @@
1
+ module Giexp
2
+ class Client
3
+ require 'rubygems'
4
+ require 'octokit'
5
+
6
+ def initialize(options)
7
+ options.merge({:auto_traversal => true})
8
+ @client = Octokit::Client.new(options)
9
+ end
10
+
11
+ def repositories(params)
12
+ if params.key?(:organization)
13
+ @client.organization_repositories(params[:organization])
14
+ else
15
+ @client.repositories(params[:user])
16
+ end
17
+ end
18
+
19
+ def issues(params)
20
+ if params.key?(:organization)
21
+ user = params[:organization]
22
+ else
23
+ user = params[:user]
24
+ end
25
+
26
+ self.repositories(params).map { |repo|
27
+ repoName = "%s/%s" % [user, repo.name]
28
+
29
+ if @client.repository(repoName).has_issues
30
+ issues = []
31
+ ['open', 'closed'].each { |status|
32
+ issues.concat(@client.issues(repoName, {:status => status}))
33
+ }
34
+ repo["issues"] = issues
35
+ repo
36
+ else
37
+ repo
38
+ end
39
+ }
40
+ end
41
+
42
+ def authenticated?
43
+ @client.authenticated?
44
+ end
45
+
46
+ def oauthed?
47
+ @client.oauthed?
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ module Giexp
2
+ module Config
3
+ def setup_options(options)
4
+ end
5
+ end
6
+
7
+ end
data/lib/giexp/run.rb ADDED
@@ -0,0 +1,19 @@
1
+ module Giexp
2
+ require 'giexp/client'
3
+
4
+ class Run
5
+ def initialize(options = {})
6
+ @client = Giexp::Client.new(options)
7
+ end
8
+
9
+ def start(options = {})
10
+ if options[:all]
11
+ require 'pp'
12
+ issues = @client.issues(options)
13
+ pp issues
14
+ else
15
+ raise "Not implement"
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/giexp.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Giexp
2
+ VERSION = '0.1.0' unless defined?(Giexp::VERSION)
3
+
4
+ end
@@ -0,0 +1,114 @@
1
+ [
2
+ {
3
+ "assignee": {
4
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
5
+ "gravatar_id": "somehexcode",
6
+ "id": 1,
7
+ "login": "octocat",
8
+ "url": "https://api.github.com/users/octocat"
9
+ },
10
+ "body": "I'm having a problem with this.",
11
+ "closed_at": null,
12
+ "comments": 0,
13
+ "created_at": "2011-04-22T13:33:48Z",
14
+ "html_url": "https://github.com/octocat/DummyRepo/issues/1",
15
+ "labels": [
16
+ {
17
+ "color": "f29513",
18
+ "name": "bug",
19
+ "url": "https://api.github.com/repos/octocat/DummyRepo/labels/bug"
20
+ }
21
+ ],
22
+ "milestone": {
23
+ "closed_issues": 8,
24
+ "created_at": "2011-04-10T20:09:31Z",
25
+ "creator": {
26
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
27
+ "gravatar_id": "somehexcode",
28
+ "id": 1,
29
+ "login": "octocat",
30
+ "url": "https://api.github.com/users/octocat"
31
+ },
32
+ "description": "",
33
+ "due_on": null,
34
+ "number": 1,
35
+ "open_issues": 4,
36
+ "state": "open",
37
+ "title": "v1.0",
38
+ "url": "https://api.github.com/repos/octocat/DummyRepo/milestones/1"
39
+ },
40
+ "number": 1345,
41
+ "pull_request": {
42
+ "diff_url": "https://github.com/octocat/DummyRepo/issues/1.diff",
43
+ "html_url": "https://github.com/octocat/DummyRepo/issues/1",
44
+ "patch_url": "https://github.com/octocat/DummyRepo/issues/1.patch"
45
+ },
46
+ "state": "closed",
47
+ "title": "Found a bug",
48
+ "updated_at": "2011-04-22T13:33:48Z",
49
+ "url": "https://api.github.com/repos/octocat/DummyRepo/issues/1",
50
+ "user": {
51
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
52
+ "gravatar_id": "somehexcode",
53
+ "id": 1,
54
+ "login": "octocat",
55
+ "url": "https://api.github.com/users/octocat"
56
+ }
57
+ },
58
+ {
59
+ "assignee": {
60
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
61
+ "gravatar_id": "somehexcode",
62
+ "id": 1,
63
+ "login": "octocat",
64
+ "url": "https://api.github.com/users/octocat"
65
+ },
66
+ "body": "I'm having a problem with this.",
67
+ "closed_at": null,
68
+ "comments": 0,
69
+ "created_at": "2011-04-22T13:33:48Z",
70
+ "html_url": "https://github.com/octocat/DummyRepo/issues/2",
71
+ "labels": [
72
+ {
73
+ "color": "f29513",
74
+ "name": "bug",
75
+ "url": "https://api.github.com/repos/octocat/DummyRepo/labels/bug"
76
+ }
77
+ ],
78
+ "milestone": {
79
+ "closed_issues": 8,
80
+ "created_at": "2011-04-10T20:09:31Z",
81
+ "creator": {
82
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
83
+ "gravatar_id": "somehexcode",
84
+ "id": 1,
85
+ "login": "octocat",
86
+ "url": "https://api.github.com/users/octocat"
87
+ },
88
+ "description": "",
89
+ "due_on": null,
90
+ "number": 1,
91
+ "open_issues": 4,
92
+ "state": "open",
93
+ "title": "v1.0",
94
+ "url": "https://api.github.com/repos/octocat/DummyRepo/milestones/1"
95
+ },
96
+ "number": 1346,
97
+ "pull_request": {
98
+ "diff_url": "https://github.com/octocat/DummyRepo/issues/2.diff",
99
+ "html_url": "https://github.com/octocat/DummyRepo/issues/2",
100
+ "patch_url": "https://github.com/octocat/DummyRepo/issues/2.patch"
101
+ },
102
+ "state": "closed",
103
+ "title": "Found a bug",
104
+ "updated_at": "2011-04-22T13:33:48Z",
105
+ "url": "https://api.github.com/repos/octocat/DummyRepo/issues/2",
106
+ "user": {
107
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
108
+ "gravatar_id": "somehexcode",
109
+ "id": 1,
110
+ "login": "octocat",
111
+ "url": "https://api.github.com/users/octocat"
112
+ }
113
+ }
114
+ ]
@@ -0,0 +1,114 @@
1
+ [
2
+ {
3
+ "assignee": {
4
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
5
+ "gravatar_id": "somehexcode",
6
+ "id": 1,
7
+ "login": "octocat",
8
+ "url": "https://api.github.com/users/octocat"
9
+ },
10
+ "body": "I'm having a problem with this.",
11
+ "closed_at": null,
12
+ "comments": 0,
13
+ "created_at": "2011-04-22T13:33:48Z",
14
+ "html_url": "https://github.com/octocat/DummyRepo/issues/1",
15
+ "labels": [
16
+ {
17
+ "color": "f29513",
18
+ "name": "bug",
19
+ "url": "https://api.github.com/repos/octocat/DummyRepo/labels/bug"
20
+ }
21
+ ],
22
+ "milestone": {
23
+ "closed_issues": 8,
24
+ "created_at": "2011-04-10T20:09:31Z",
25
+ "creator": {
26
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
27
+ "gravatar_id": "somehexcode",
28
+ "id": 1,
29
+ "login": "octocat",
30
+ "url": "https://api.github.com/users/octocat"
31
+ },
32
+ "description": "",
33
+ "due_on": null,
34
+ "number": 1,
35
+ "open_issues": 4,
36
+ "state": "open",
37
+ "title": "v1.0",
38
+ "url": "https://api.github.com/repos/octocat/DummyRepo/milestones/1"
39
+ },
40
+ "number": 1347,
41
+ "pull_request": {
42
+ "diff_url": "https://github.com/octocat/DummyRepo/issues/1.diff",
43
+ "html_url": "https://github.com/octocat/DummyRepo/issues/1",
44
+ "patch_url": "https://github.com/octocat/DummyRepo/issues/1.patch"
45
+ },
46
+ "state": "open",
47
+ "title": "Found a bug",
48
+ "updated_at": "2011-04-22T13:33:48Z",
49
+ "url": "https://api.github.com/repos/octocat/DummyRepo/issues/1",
50
+ "user": {
51
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
52
+ "gravatar_id": "somehexcode",
53
+ "id": 1,
54
+ "login": "octocat",
55
+ "url": "https://api.github.com/users/octocat"
56
+ }
57
+ },
58
+ {
59
+ "assignee": {
60
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
61
+ "gravatar_id": "somehexcode",
62
+ "id": 1,
63
+ "login": "octocat",
64
+ "url": "https://api.github.com/users/octocat"
65
+ },
66
+ "body": "I'm having a problem with this.",
67
+ "closed_at": null,
68
+ "comments": 0,
69
+ "created_at": "2011-04-22T13:33:48Z",
70
+ "html_url": "https://github.com/octocat/DummyRepo/issues/2",
71
+ "labels": [
72
+ {
73
+ "color": "f29513",
74
+ "name": "bug",
75
+ "url": "https://api.github.com/repos/octocat/DummyRepo/labels/bug"
76
+ }
77
+ ],
78
+ "milestone": {
79
+ "closed_issues": 8,
80
+ "created_at": "2011-04-10T20:09:31Z",
81
+ "creator": {
82
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
83
+ "gravatar_id": "somehexcode",
84
+ "id": 1,
85
+ "login": "octocat",
86
+ "url": "https://api.github.com/users/octocat"
87
+ },
88
+ "description": "",
89
+ "due_on": null,
90
+ "number": 1,
91
+ "open_issues": 4,
92
+ "state": "open",
93
+ "title": "v1.0",
94
+ "url": "https://api.github.com/repos/octocat/DummyRepo/milestones/1"
95
+ },
96
+ "number": 1348,
97
+ "pull_request": {
98
+ "diff_url": "https://github.com/octocat/DummyRepo/issues/2.diff",
99
+ "html_url": "https://github.com/octocat/DummyRepo/issues/2",
100
+ "patch_url": "https://github.com/octocat/DummyRepo/issues/2.patch"
101
+ },
102
+ "state": "open",
103
+ "title": "Found a bug",
104
+ "updated_at": "2011-04-22T13:33:48Z",
105
+ "url": "https://api.github.com/repos/octocat/DummyRepo/issues/2",
106
+ "user": {
107
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
108
+ "gravatar_id": "somehexcode",
109
+ "id": 1,
110
+ "login": "octocat",
111
+ "url": "https://api.github.com/users/octocat"
112
+ }
113
+ }
114
+ ]
@@ -0,0 +1,95 @@
1
+ {
2
+ "clone_url": "https://github.com/octocat/DummyRepo.git",
3
+ "created_at": "2011-01-26T19:01:12Z",
4
+ "description": "This your first repo!",
5
+ "fork": false,
6
+ "forks": 9,
7
+ "git_url": "git://github.com/octocat/DummyRepo.git",
8
+ "has_downloads": true,
9
+ "has_issues": true,
10
+ "has_wiki": true,
11
+ "homepage": "https://github.com",
12
+ "html_url": "https://github.com/octocat/DummyRepo",
13
+ "language": null,
14
+ "master_branch": "master",
15
+ "name": "DummyRepo",
16
+ "open_issues": 0,
17
+ "organization": {
18
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
19
+ "gravatar_id": "somehexcode",
20
+ "id": 1,
21
+ "login": "octocat",
22
+ "type": "Organization",
23
+ "url": "https://api.github.com/users/octocat"
24
+ },
25
+ "owner": {
26
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
27
+ "gravatar_id": "somehexcode",
28
+ "id": 1,
29
+ "login": "octocat",
30
+ "url": "https://api.github.com/users/octocat"
31
+ },
32
+ "parent": {
33
+ "clone_url": "https://github.com/octocat/DummyRepo.git",
34
+ "created_at": "2011-01-26T19:01:12Z",
35
+ "description": "This your first repo!",
36
+ "fork": false,
37
+ "forks": 9,
38
+ "git_url": "git://github.com/octocat/DummyRepo.git",
39
+ "homepage": "https://github.com",
40
+ "html_url": "https://github.com/octocat/DummyRepo",
41
+ "language": null,
42
+ "master_branch": "master",
43
+ "name": "DummyRepo",
44
+ "open_issues": 0,
45
+ "owner": {
46
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
47
+ "gravatar_id": "somehexcode",
48
+ "id": 1,
49
+ "login": "octocat",
50
+ "url": "https://api.github.com/users/octocat"
51
+ },
52
+ "private": false,
53
+ "pushed_at": "2011-01-26T19:06:43Z",
54
+ "size": 108,
55
+ "ssh_url": "git@github.com:octocat/DummyRepo.git",
56
+ "svn_url": "https://svn.github.com/octocat/DummyRepo",
57
+ "url": "https://api.github.com/repos/octocat/DummyRepo",
58
+ "watchers": 80
59
+ },
60
+ "private": false,
61
+ "pushed_at": "2011-01-26T19:06:43Z",
62
+ "size": 108,
63
+ "source": {
64
+ "clone_url": "https://github.com/octocat/DummyRepo.git",
65
+ "created_at": "2011-01-26T19:01:12Z",
66
+ "description": "This your first repo!",
67
+ "fork": false,
68
+ "forks": 9,
69
+ "git_url": "git://github.com/octocat/DummyRepo.git",
70
+ "homepage": "https://github.com",
71
+ "html_url": "https://github.com/octocat/DummyRepo",
72
+ "language": null,
73
+ "master_branch": "master",
74
+ "name": "DummyRepo",
75
+ "open_issues": 0,
76
+ "owner": {
77
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
78
+ "gravatar_id": "somehexcode",
79
+ "id": 1,
80
+ "login": "octocat",
81
+ "url": "https://api.github.com/users/octocat"
82
+ },
83
+ "private": false,
84
+ "pushed_at": "2011-01-26T19:06:43Z",
85
+ "size": 108,
86
+ "ssh_url": "git@github.com:octocat/DummyRepo.git",
87
+ "svn_url": "https://svn.github.com/octocat/DummyRepo",
88
+ "url": "https://api.github.com/repos/octocat/DummyRepo",
89
+ "watchers": 80
90
+ },
91
+ "ssh_url": "git@github.com:octocat/DummyRepo.git",
92
+ "svn_url": "https://svn.github.com/octocat/DummyRepo",
93
+ "url": "https://api.github.com/repos/octocat/DummyRepo",
94
+ "watchers": 80
95
+ }
@@ -0,0 +1,36 @@
1
+ [
2
+ {
3
+ "has_downloads": true,
4
+ "has_issues": true,
5
+ "master_branch": null,
6
+ "forks": 1,
7
+ "svn_url": "https://github.com/iroha/DummyRepo",
8
+ "homepage": "",
9
+ "has_wiki": true,
10
+ "updated_at": "2012-03-07T07:27:58Z",
11
+ "fork": false,
12
+ "clone_url": "https://github.com/iroha/DummyRepo.git",
13
+ "mirror_url": null,
14
+ "language": "C++",
15
+ "private": true,
16
+ "html_url": "https://github.com/iroha/DummyRepo",
17
+ "ssh_url": "git@github.com:iroha/DummyRepo.git",
18
+ "size": 88,
19
+ "open_issues": 0,
20
+ "url": "https://api.github.com/repos/iroha/DummyRepo",
21
+ "watchers": 2,
22
+ "pushed_at": "2012-03-07T06:04:25Z",
23
+ "created_at": "2012-03-07T06:03:14Z",
24
+ "owner": {
25
+ "login": "iroha",
26
+ "avatar_url": "https://secure.gravatar.com/avatar/151c577a23fd8ad6178ab19b83a253d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png",
27
+ "url": "https://api.github.com/users/iroha",
28
+ "gravatar_id": "151c577a23fd8ad6178ab19b83a253d4",
29
+ "id": 1501323
30
+ },
31
+ "name": "DummyRepo",
32
+ "id": 3646278,
33
+ "git_url": "git://github.com/iroha/DummyRepo.git",
34
+ "description": ""
35
+ }
36
+ ]
@@ -0,0 +1,36 @@
1
+ [
2
+ {
3
+ "has_downloads": true,
4
+ "has_issues": true,
5
+ "master_branch": null,
6
+ "forks": 1,
7
+ "svn_url": "https://github.com/iroha/DummyRepo",
8
+ "homepage": "",
9
+ "has_wiki": true,
10
+ "updated_at": "2012-03-07T07:27:58Z",
11
+ "fork": false,
12
+ "clone_url": "https://github.com/iroha/DummyRepo.git",
13
+ "mirror_url": null,
14
+ "language": "C++",
15
+ "private": true,
16
+ "html_url": "https://github.com/iroha/DummyRepo",
17
+ "ssh_url": "git@github.com:iroha/DummyRepo.git",
18
+ "size": 88,
19
+ "open_issues": 0,
20
+ "url": "https://api.github.com/repos/iroha/DummyRepo",
21
+ "watchers": 2,
22
+ "pushed_at": "2012-03-07T06:04:25Z",
23
+ "created_at": "2012-03-07T06:03:14Z",
24
+ "owner": {
25
+ "login": "iroha",
26
+ "avatar_url": "https://secure.gravatar.com/avatar/151c577a23fd8ad6178ab19b83a253d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png",
27
+ "url": "https://api.github.com/users/iroha",
28
+ "gravatar_id": "151c577a23fd8ad6178ab19b83a253d4",
29
+ "id": 1501323
30
+ },
31
+ "name": "DummyRepo",
32
+ "id": 3646278,
33
+ "git_url": "git://github.com/iroha/DummyRepo.git",
34
+ "description": ""
35
+ }
36
+ ]
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+ require 'giexp'
3
+
4
+ describe Giexp do
5
+ describe "with a issues command" do
6
+ it "should not raise an error" do
7
+ lambda {
8
+ Giexp.initialize({:login => "octocat", :password => "passpass"})
9
+ }.should_not raise_error
10
+ end
11
+ end
12
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'octokit'
2
+ require 'rspec'
3
+ require 'webmock/rspec'
4
+
5
+ def stub_get(url)
6
+ stub_request(:get, github_url(url))
7
+ end
8
+
9
+ def fixture_path
10
+ File.expand_path("../fixtures", __FILE__)
11
+ end
12
+
13
+ def fixture(file)
14
+ File.new(fixture_path + '/' + file)
15
+ end
16
+
17
+ def github_url(url)
18
+ if url =~ /^http/
19
+ url
20
+ elsif @client && @client.authenticated?
21
+ "https://octocat:passpass@api.github.com#{url}"
22
+ elsif @client && @client.oauthed?
23
+ "https://api.github.com#{url}?access_token=#{@client.oauth_token}"
24
+ else
25
+ "https://api.github.com#{url}"
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'helper'
3
+ require 'giexp/client'
4
+
5
+ describe Giexp::Client do
6
+ before do
7
+ @client = Giexp::Client.new(:login => 'octocat', :password => 'passpass')
8
+ end
9
+
10
+ describe ".issues" do
11
+
12
+ context "with a user name" do
13
+ it "should return user's repositories that includes issues" do
14
+ stub_get("/users/octocat/repos").
15
+ to_return(:body => fixture("repos_user.json"))
16
+
17
+ stub_get("/repos/octocat/DummyRepo").
18
+ to_return(:body => fixture("repo.json"))
19
+
20
+ stub_get("/repos/octocat/DummyRepo/issues?status=open").
21
+ to_return(:body => fixture("issues_open.json"))
22
+
23
+ stub_get("/repos/octocat/DummyRepo/issues?status=closed").
24
+ to_return(:body => fixture("issues_close.json"))
25
+
26
+ issues = @client.issues(:user => "octocat")
27
+ issues.first.name.should == "DummyRepo"
28
+ issues.first.issues.should have(4).items
29
+ issues.first.issues.first.number == "1347"
30
+ end
31
+ end
32
+
33
+ context "with a organization name" do
34
+ it "should return organization's repositories that includes issues" do
35
+ stub_get("/orgs/iroha/repos").
36
+ to_return(:body => fixture("repos_org.json"))
37
+
38
+ stub_get("/repos/iroha/DummyRepo").
39
+ to_return(:body => fixture("repo.json"))
40
+
41
+ stub_get("/repos/iroha/DummyRepo/issues?status=open").
42
+ to_return(:body => fixture("issues_open.json"))
43
+
44
+ stub_get("/repos/iroha/DummyRepo/issues?status=closed").
45
+ to_return(:body => fixture("issues_close.json"))
46
+
47
+ issues = @client.issues(:organization => "iroha")
48
+ issues.first.name.should == "DummyRepo"
49
+ issues.first.issues.should have(4).items
50
+ issues.first.issues.first.number == "1348"
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'helper'
3
+ require 'giexp/client'
4
+
5
+ describe Giexp::Client do
6
+ before do
7
+ @client = Giexp::Client.new(:login => 'octocat', :password => 'passpass')
8
+ end
9
+
10
+ describe ".repositories" do
11
+
12
+ context "with a user name" do
13
+ it "should return user's repositories" do
14
+ stub_get("/users/octocat/repos").
15
+ to_return(:body => fixture("repos_user.json"))
16
+ repositories = @client.repositories(:user => "octocat")
17
+ repositories.first.name.should == "DummyRepo"
18
+ end
19
+ end
20
+
21
+ context "with a organization name" do
22
+ it "should return organization's repositories" do
23
+ stub_get("/orgs/iroha/repos").
24
+ to_return(:body => fixture("repos_org.json"))
25
+ repositories = @client.repositories(:organization => "iroha")
26
+ repositories.first.name.should == "DummyRepo"
27
+ repositories.first.private.should be_true
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,29 @@
1
+ require 'octokit'
2
+ require 'rspec'
3
+ require 'webmock/rspec'
4
+ require 'giexp'
5
+
6
+
7
+ def stub_get(url)
8
+ stub_request(:get, github_url(url))
9
+ end
10
+
11
+ def fixture_path
12
+ File.expand_path("../fixtures", __FILE__)
13
+ end
14
+
15
+ def fixture(file)
16
+ File.new(fixture_path + '/' + file)
17
+ end
18
+
19
+ def github_url(url)
20
+ if url =~ /^http/
21
+ url
22
+ elsif @client && @client.authenticated?
23
+ "https://octocat%2Ftoken:passpass@api.github.com#{url}"
24
+ elsif @client && @client.oauthed?
25
+ "https://api.github.com#{url}?access_token=#{@client.oauth_token}"
26
+ else
27
+ "https://api.github.com#{url}"
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: giexp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Katsunori Kanda
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70250251566960 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.8.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70250251566960
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70250251564800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70250251564800
36
+ - !ruby/object:Gem::Dependency
37
+ name: octokit
38
+ requirement: &70250251564140 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70250251564140
47
+ - !ruby/object:Gem::Dependency
48
+ name: webmock
49
+ requirement: &70250251563140 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.2
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70250251563140
58
+ description: a tool to export issues on github
59
+ email: potix2@gmail.com
60
+ executables:
61
+ - giexp
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - README.md
65
+ files:
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - bin/giexp
71
+ - giexp.gemspec
72
+ - lib/giexp.rb
73
+ - lib/giexp/client.rb
74
+ - lib/giexp/config.rb
75
+ - lib/giexp/run.rb
76
+ - spec/fixtures/issues_close.json
77
+ - spec/fixtures/issues_open.json
78
+ - spec/fixtures/repo.json
79
+ - spec/fixtures/repos_org.json
80
+ - spec/fixtures/repos_user.json
81
+ - spec/giexp_spec.rb
82
+ - spec/helper.rb
83
+ - spec/issues_spec.rb
84
+ - spec/repos_spec.rb
85
+ - spec/spec_helper.rb
86
+ homepage: http://github.com/potix2/github-issues-exporter/
87
+ licenses: []
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project: giexp
106
+ rubygems_version: 1.8.17
107
+ signing_key:
108
+ specification_version: 2
109
+ summary: a tool to export issues on github
110
+ test_files: []