backup-github 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +71 -0
- data/LICENSE.txt +20 -0
- data/README.md +48 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/backup-github.gemspec +78 -0
- data/bin/gh-backup-issues +9 -0
- data/lib/backup-github.rb +92 -0
- data/lib/backup-github/cli.rb +43 -0
- data/spec/backup-github_spec.rb +79 -0
- data/spec/spec_helper.rb +12 -0
- metadata +164 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem "rspec", "~> 2.8.0"
|
5
|
+
gem "rdoc", "~> 3.12"
|
6
|
+
gem "bundler", "~> 1.0.0"
|
7
|
+
gem "jeweler", "~> 1.8.3"
|
8
|
+
gem "mocha", "~> 0.10.3"
|
9
|
+
# gem "pry" # active for debug
|
10
|
+
end
|
11
|
+
|
12
|
+
group :default do
|
13
|
+
gem "octokit", "~> 0.6.5"
|
14
|
+
gem "json", "~> 1.6.4"
|
15
|
+
gem "grit", "~> 2.4.1"
|
16
|
+
gem "trollop", "~> 1.16.2"
|
17
|
+
end
|
18
|
+
|
19
|
+
# yo dawg, i herd u lieked jeweler
|
20
|
+
group :xzibit do
|
21
|
+
# steal a page from bundler's gemspec:
|
22
|
+
# add this directory as jeweler, in order to bundle exec jeweler and use the current working directory
|
23
|
+
gem 'backup-github', :path => '.'
|
24
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
backup-github (1.1.0)
|
5
|
+
grit (~> 2.4.1)
|
6
|
+
json (~> 1.6.4)
|
7
|
+
octokit (~> 0.6.5)
|
8
|
+
trollop (~> 1.16.2)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.2.6)
|
14
|
+
diff-lcs (1.1.3)
|
15
|
+
faraday (0.7.6)
|
16
|
+
addressable (~> 2.2)
|
17
|
+
multipart-post (~> 1.1)
|
18
|
+
rack (~> 1.1)
|
19
|
+
faraday_middleware (0.7.0)
|
20
|
+
faraday (~> 0.7.3)
|
21
|
+
git (1.2.5)
|
22
|
+
grit (2.4.1)
|
23
|
+
diff-lcs (~> 1.1)
|
24
|
+
mime-types (~> 1.15)
|
25
|
+
hashie (1.2.0)
|
26
|
+
jeweler (1.8.3)
|
27
|
+
bundler (~> 1.0)
|
28
|
+
git (>= 1.2.5)
|
29
|
+
rake
|
30
|
+
rdoc
|
31
|
+
json (1.6.5)
|
32
|
+
metaclass (0.0.1)
|
33
|
+
mime-types (1.17.2)
|
34
|
+
mocha (0.10.3)
|
35
|
+
metaclass (~> 0.0.1)
|
36
|
+
multi_json (1.0.4)
|
37
|
+
multipart-post (1.1.4)
|
38
|
+
octokit (0.6.5)
|
39
|
+
addressable (~> 2.2.6)
|
40
|
+
faraday (~> 0.7.4)
|
41
|
+
faraday_middleware (~> 0.7.0)
|
42
|
+
hashie (~> 1.2.0)
|
43
|
+
multi_json (~> 1.0.2)
|
44
|
+
rack (1.4.1)
|
45
|
+
rake (0.9.2.2)
|
46
|
+
rdoc (3.12)
|
47
|
+
json (~> 1.4)
|
48
|
+
rspec (2.8.0)
|
49
|
+
rspec-core (~> 2.8.0)
|
50
|
+
rspec-expectations (~> 2.8.0)
|
51
|
+
rspec-mocks (~> 2.8.0)
|
52
|
+
rspec-core (2.8.0)
|
53
|
+
rspec-expectations (2.8.0)
|
54
|
+
diff-lcs (~> 1.1.2)
|
55
|
+
rspec-mocks (2.8.0)
|
56
|
+
trollop (1.16.2)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
backup-github!
|
63
|
+
bundler (~> 1.0.0)
|
64
|
+
grit (~> 2.4.1)
|
65
|
+
jeweler (~> 1.8.3)
|
66
|
+
json (~> 1.6.4)
|
67
|
+
mocha (~> 0.10.3)
|
68
|
+
octokit (~> 0.6.5)
|
69
|
+
rdoc (~> 3.12)
|
70
|
+
rspec (~> 2.8.0)
|
71
|
+
trollop (~> 1.16.2)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Zauber (http://www.zaubersoftware.com)
|
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,48 @@
|
|
1
|
+
# backup-github
|
2
|
+
|
3
|
+
Utility tool to backup github repository issues. It will backup up all the issues from all the repositories from a given github account.
|
4
|
+
|
5
|
+
It works with a local git repository, on which issues from all repositories of a github account are serialized to json and commited. Thanks to git, all changes are versioned, and saved.
|
6
|
+
|
7
|
+
To install you can just download the gem with:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install backup-github
|
11
|
+
```
|
12
|
+
|
13
|
+
Then, to run the backup command:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
backup-github -r path/to/my/backup/dir -u github_user -p github_pwd
|
17
|
+
```
|
18
|
+
|
19
|
+
If, instead you want to backup up all the issues from an Organization within github, then you run:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
backup-github -r path/to/my/backup/dir -u github_user -p github_pwd -o org_name
|
23
|
+
```
|
24
|
+
|
25
|
+
**Important**: The github user used, should have access to all the organization repositories.
|
26
|
+
|
27
|
+
To properly configure the backup system, we recommend setting a cron job to run the command once a day.
|
28
|
+
|
29
|
+
## Contributing to backup-github
|
30
|
+
|
31
|
+
* Check out the latest master to make sure the feature hasn't been implemented
|
32
|
+
or the bug hasn't been fixed yet.
|
33
|
+
* Check out the issue tracker to make sure someone already hasn't requested it
|
34
|
+
and/or contributed it.
|
35
|
+
* Fork the project.
|
36
|
+
* Start a feature/bugfix branch.
|
37
|
+
* Commit and push until you are happy with your contribution.
|
38
|
+
* Make sure to add tests for it. This is important so I don't break it in a
|
39
|
+
future version unintentionally.
|
40
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to
|
41
|
+
have your own version, or is otherwise necessary, that is fine, but please
|
42
|
+
isolate to its own commit so I can cherry-pick around it.
|
43
|
+
|
44
|
+
## Copyright
|
45
|
+
|
46
|
+
Copyright (c) 2012 Zauber. See LICENSE.txt for
|
47
|
+
further details.
|
48
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "backup-github"
|
18
|
+
gem.homepage = "http://github.com/zauberlabs/backup-github"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Backups Github Issues}
|
21
|
+
gem.description = %Q{Command to backup Github Issues as JSON files in a Git Repository}
|
22
|
+
gem.email = "mariano@zauberlabs.com"
|
23
|
+
gem.authors = ["Mariano A. Cortesi"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rdoc/task'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "backup-github #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "backup-github"
|
8
|
+
s.version = "1.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Mariano A. Cortesi"]
|
12
|
+
s.date = "2012-02-01"
|
13
|
+
s.description = "Command to backup Github Issues as JSON files in a Git Repository"
|
14
|
+
s.email = "mariano@zauberlabs.com"
|
15
|
+
s.executables = ["gh-backup-issues"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"backup-github.gemspec",
|
30
|
+
"bin/gh-backup-issues",
|
31
|
+
"lib/backup-github.rb",
|
32
|
+
"lib/backup-github/cli.rb",
|
33
|
+
"spec/backup-github_spec.rb",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/zauberlabs/backup-github"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = "1.8.15"
|
40
|
+
s.summary = "Backups Github Issues"
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<octokit>, ["~> 0.6.5"])
|
47
|
+
s.add_runtime_dependency(%q<json>, ["~> 1.6.4"])
|
48
|
+
s.add_runtime_dependency(%q<grit>, ["~> 2.4.1"])
|
49
|
+
s.add_runtime_dependency(%q<trollop>, ["~> 1.16.2"])
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
54
|
+
s.add_development_dependency(%q<mocha>, ["~> 0.10.3"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<octokit>, ["~> 0.6.5"])
|
57
|
+
s.add_dependency(%q<json>, ["~> 1.6.4"])
|
58
|
+
s.add_dependency(%q<grit>, ["~> 2.4.1"])
|
59
|
+
s.add_dependency(%q<trollop>, ["~> 1.16.2"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
64
|
+
s.add_dependency(%q<mocha>, ["~> 0.10.3"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<octokit>, ["~> 0.6.5"])
|
68
|
+
s.add_dependency(%q<json>, ["~> 1.6.4"])
|
69
|
+
s.add_dependency(%q<grit>, ["~> 2.4.1"])
|
70
|
+
s.add_dependency(%q<trollop>, ["~> 1.16.2"])
|
71
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
72
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
74
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
75
|
+
s.add_dependency(%q<mocha>, ["~> 0.10.3"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Don't try to run this binary directory. Instead:
|
4
|
+
# * `bundle exec backup-github` if doing backup-github development
|
5
|
+
# * `backup-github` if installed through rubygems, relying on the rubygem wrapper
|
6
|
+
|
7
|
+
require "backup-github/cli"
|
8
|
+
|
9
|
+
BackupGithub::Cli::run()
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'octokit'
|
4
|
+
require 'json'
|
5
|
+
require 'grit'
|
6
|
+
require 'ostruct'
|
7
|
+
require 'pathname'
|
8
|
+
require 'logger'
|
9
|
+
|
10
|
+
$logger = Logger.new($stdout)
|
11
|
+
|
12
|
+
class GithubBackup
|
13
|
+
|
14
|
+
def initialize(github)
|
15
|
+
@github = github
|
16
|
+
end
|
17
|
+
|
18
|
+
def serialize_issue(issue)
|
19
|
+
JSON.pretty_generate( issue.content )
|
20
|
+
end
|
21
|
+
|
22
|
+
def save_issue(dir, issue)
|
23
|
+
file = dir + ('%04d.js' % issue.number)
|
24
|
+
file.open('w') { |f| f.write(serialize_issue(issue)) }
|
25
|
+
@gitrepo.add(file.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
def run( orgname, local_repo )
|
29
|
+
Dir.chdir(local_repo) do |path|
|
30
|
+
@gitrepo = begin
|
31
|
+
Grit::Repo.new(".")
|
32
|
+
rescue Grit::InvalidGitRepositoryError => e
|
33
|
+
$logger.warn "Not a git Repository, creating a new one"
|
34
|
+
Grit::Repo.init(".")
|
35
|
+
end
|
36
|
+
|
37
|
+
orgdir = Pathname.new orgname
|
38
|
+
|
39
|
+
repositories = @github.repositories orgname
|
40
|
+
|
41
|
+
repositories.each do |repo|
|
42
|
+
reponame = "#{orgname}/#{repo.name}"
|
43
|
+
$logger.info "Backuping #{reponame}"
|
44
|
+
|
45
|
+
if @github.has_issues? reponame
|
46
|
+
projectdir = orgdir + repo.name
|
47
|
+
projectdir.mkpath
|
48
|
+
|
49
|
+
@github.on_issues(reponame) {|issue| save_issue(projectdir, issue)}
|
50
|
+
else
|
51
|
+
$logger.info "No issues for #{reponame}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
@gitrepo.commit_index("Backup...")
|
56
|
+
$logger.info 'Backup Finished'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
class GithubAPIAdapter
|
64
|
+
@@ISSUE_STATES = %w{open closed}
|
65
|
+
|
66
|
+
def initialize(client)
|
67
|
+
@client = client
|
68
|
+
end
|
69
|
+
|
70
|
+
def has_issues?(reponame)
|
71
|
+
@client.repository(reponame).has_issues
|
72
|
+
end
|
73
|
+
|
74
|
+
def on_issues(reponame, &block)
|
75
|
+
@@ISSUE_STATES.each do |status|
|
76
|
+
page = 0
|
77
|
+
|
78
|
+
begin
|
79
|
+
issues = @client.list_issues( reponame, :page => page, :state => status )
|
80
|
+
issues.each do |issue|
|
81
|
+
yield OpenStruct.new(:number => issue.number,
|
82
|
+
:content => @client.issue(reponame, issue.number))
|
83
|
+
end
|
84
|
+
page += 1
|
85
|
+
end until issues.length != 10
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def repositories(orgname)
|
90
|
+
@client.repositories(orgname)
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'trollop'
|
2
|
+
require 'backup-github'
|
3
|
+
|
4
|
+
module BackupGithub
|
5
|
+
module Cli
|
6
|
+
|
7
|
+
def self.parse_options
|
8
|
+
opts = Trollop::options do
|
9
|
+
banner "hola mundo"
|
10
|
+
opt :localrepo, "Path to the local repository where backups are saved",
|
11
|
+
:short => "-r",
|
12
|
+
:type => String,
|
13
|
+
:required => true
|
14
|
+
opt :organization, "Organization name if you want to backup repositories from one",
|
15
|
+
:short => "-o",
|
16
|
+
:type => String,
|
17
|
+
:required => false
|
18
|
+
opt :github_user, "Github User",
|
19
|
+
:short => "-u",
|
20
|
+
:type => String,
|
21
|
+
:required => true
|
22
|
+
opt :github_password, "Github Password",
|
23
|
+
:short => "-p",
|
24
|
+
:type => String,
|
25
|
+
:required => true
|
26
|
+
end
|
27
|
+
Trollop::die :localrepo, "must exist" unless File.directory? opts[:localrepo]
|
28
|
+
opts
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.run
|
32
|
+
opts = parse_options
|
33
|
+
account = opts[:organization] || opts[:github_user]
|
34
|
+
github = GithubAPIAdapter.new(
|
35
|
+
Octokit::Client.new(
|
36
|
+
:login => opts[:github_user],
|
37
|
+
:password => opts[:github_password]))
|
38
|
+
GithubBackup.new(github).run(account, opts[:localrepo])
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require "mocha"
|
4
|
+
require "ostruct"
|
5
|
+
require_relative "../lib/backup-github"
|
6
|
+
|
7
|
+
describe GithubAPIAdapter do
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@client = double()
|
11
|
+
@github = GithubAPIAdapter.new(@client)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "repositories" do
|
15
|
+
it "should retrieve repositories for an organization" do
|
16
|
+
@client.should_receive(:repositories) {%w{repo1 repo2 repo3}}
|
17
|
+
|
18
|
+
@github.repositories("org1").should eq(%w{repo1 repo2 repo3})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "on_issues" do
|
23
|
+
it "should retrieve open issues" do
|
24
|
+
@client.should_receive(:list_issues).with("repo", {:page => 0, :state => "open"}) do
|
25
|
+
[1,2,4].collect {|i| OpenStruct.new(:number => i)}
|
26
|
+
end
|
27
|
+
@client.should_receive(:list_issues).with("repo", {:page => 0, :state => "closed"}) {[]}
|
28
|
+
@client.should_receive(:issue).at_least(:once) {"content"}
|
29
|
+
|
30
|
+
data = []
|
31
|
+
@github.on_issues("repo") {|r| data << r}
|
32
|
+
data.should have(3).items
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should retrieve closed issues" do
|
36
|
+
@client.should_receive(:list_issues).with("repo", {:page => 0, :state => "closed"}) do
|
37
|
+
[1,2,4].collect {|i| OpenStruct.new(:number => i)}
|
38
|
+
end
|
39
|
+
@client.should_receive(:list_issues).with("repo", {:page => 0, :state => "open"}) {[]}
|
40
|
+
@client.should_receive(:issue).at_least(:once) {"content"}
|
41
|
+
|
42
|
+
data = []
|
43
|
+
@github.on_issues("repo") {|r| data << r}
|
44
|
+
data.should have(3).items
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should retrieve all issues pages" do
|
48
|
+
@client.should_receive(:list_issues).exactly(12).times do |repo, opt |
|
49
|
+
values = if opt[:page] < 5
|
50
|
+
(1..10)
|
51
|
+
else
|
52
|
+
(1..4)
|
53
|
+
end
|
54
|
+
values.collect {|i| OpenStruct.new(:number => i)}
|
55
|
+
end
|
56
|
+
@client.should_receive(:issue).at_least(:once) {"content"}
|
57
|
+
|
58
|
+
data = []
|
59
|
+
@github.on_issues("repo") { |r| data << r }
|
60
|
+
data.should have(5*10*2 + 4*2).items
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should retrieve issue content for each issue" do
|
64
|
+
@client.should_receive(:list_issues).twice do |repo, opt|
|
65
|
+
if opt[:state] == "open"
|
66
|
+
[1].collect {|i| OpenStruct.new(:number => i)}
|
67
|
+
else
|
68
|
+
[]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
@client.should_receive(:issue).at_least(:once) {"content"}
|
72
|
+
|
73
|
+
data = []
|
74
|
+
@github.on_issues("repo") {|r| data << r}
|
75
|
+
data.should have(1).items
|
76
|
+
data[0].content.should eq("content")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'backup-github'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backup-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mariano A. Cortesi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: octokit
|
16
|
+
requirement: &70183486958840 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.6.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70183486958840
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
requirement: &70183486957760 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.4
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70183486957760
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: grit
|
38
|
+
requirement: &70183486956980 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.4.1
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70183486956980
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: trollop
|
49
|
+
requirement: &70183486956320 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.16.2
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70183486956320
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &70183486955700 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.8.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70183486955700
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
requirement: &70183486954960 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.12'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70183486954960
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: bundler
|
82
|
+
requirement: &70183486954280 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.0.0
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70183486954280
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: jeweler
|
93
|
+
requirement: &70183486951860 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.8.3
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70183486951860
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: mocha
|
104
|
+
requirement: &70183486948440 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.10.3
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70183486948440
|
113
|
+
description: Command to backup Github Issues as JSON files in a Git Repository
|
114
|
+
email: mariano@zauberlabs.com
|
115
|
+
executables:
|
116
|
+
- gh-backup-issues
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files:
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.md
|
121
|
+
files:
|
122
|
+
- .document
|
123
|
+
- .rspec
|
124
|
+
- Gemfile
|
125
|
+
- Gemfile.lock
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- VERSION
|
130
|
+
- backup-github.gemspec
|
131
|
+
- bin/gh-backup-issues
|
132
|
+
- lib/backup-github.rb
|
133
|
+
- lib/backup-github/cli.rb
|
134
|
+
- spec/backup-github_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
homepage: http://github.com/zauberlabs/backup-github
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: 3014412636560081919
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.15
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Backups Github Issues
|
164
|
+
test_files: []
|