offline 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.travis.yml +2 -3
- data/README.md +26 -8
- data/lib/offline/app.rb +5 -3
- data/lib/offline/github.rb +15 -5
- data/lib/offline/version.rb +1 -1
- data/offline.gemspec +3 -2
- data/spec/offline/github_spec.rb +29 -9
- metadata +18 -28
- data/.rvmrc +0 -2
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c825cc1adf35338485696ea6a5ec41acebeacd6
|
4
|
+
data.tar.gz: 125ca92bccab8d2775519ad4409b09bd25f08d17
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a1c0e337a2b49acbd05667d4791c06b7d10917fd28b2d7bb87665db59de6c4e07886ea45ce2f9f52615b08d733909a1a40462599010b29f16874af64e955d66
|
7
|
+
data.tar.gz: 4b41225dec2af4d58f41fdbda12bdb7b3c01e86f1b8389a808d411c5b2211c0f328fac18b9fbb4d6f65f90e91fb9b909a8047958f8f4cb0987ea85278fdfedc5
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# Offline
|
2
2
|
|
3
|
-
Offline is an open source command line tool for mirroring github projects.
|
3
|
+
Offline is an open source command line tool for mirroring & cloning github projects.
|
4
4
|
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
* Install Offline:
|
5
|
+
## Installation
|
8
6
|
|
9
7
|
$> gem install offline
|
10
8
|
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Offline has two modes of operation: mirror & clone. All of Offline's commands can use mirror mode and clone mode interchangeably. Mirroring creates bare repositories, like the ones you push to on a server or use locally for a gem cache. Cloning is a normal `git clone`, so has a working directory. [More info about git's clone types](http://stackoverflow.com/a/3960063/320438).
|
12
|
+
|
11
13
|
* mirror all public repositories for a given user:
|
12
14
|
|
13
15
|
$> offline mirror vertis
|
@@ -20,19 +22,35 @@ Offline is an open source command line tool for mirroring github projects.
|
|
20
22
|
|
21
23
|
$> offline mirror vertis --without flynn offline
|
22
24
|
|
23
|
-
*
|
25
|
+
* single private repository
|
24
26
|
|
25
27
|
$> offline mirror vertis --only mysecretproject --password password1
|
26
28
|
|
27
|
-
|
29
|
+
* clone all private repositories
|
30
|
+
|
31
|
+
$> offline clone -p password --private-only MYUSER
|
32
|
+
|
33
|
+
* clone another user's private repositories
|
34
|
+
|
35
|
+
$> offline clone -u myuser -p password --private-only OTHERUSER
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
In order to run the specs you will need to provide a valid oauth token.
|
40
|
+
```
|
41
|
+
VALID_TEST_ACCESS_TOKEN=<your token> bundle exec rspec spec
|
42
|
+
```
|
43
|
+
|
44
|
+
NB: Travis CI will not run the oauth test, because have no way of supplying a key and not compromising an account.
|
45
|
+
|
46
|
+
## Contributing
|
28
47
|
|
29
48
|
Fork on GitHub, create a test & send a pull request.
|
30
49
|
|
31
|
-
##Bugs
|
50
|
+
## Bugs
|
32
51
|
|
33
52
|
Use the [Issue Tracker](http://github.com/vertis/offline/issues)
|
34
53
|
|
35
54
|
## License & Acknowledgments
|
36
55
|
|
37
56
|
Offline is distributed under the MIT license, for full details please see the LICENSE file.
|
38
|
-
|
data/lib/offline/app.rb
CHANGED
@@ -34,15 +34,17 @@ module Offline
|
|
34
34
|
all_repos = reaper.repositories(owner, privacy).map {|r| r["name"] }
|
35
35
|
repos = all_repos & (options[:only] || all_repos) # TODO: Might be a better way of doing this
|
36
36
|
repos = (repos) - Array(options[:without])
|
37
|
-
|
37
|
+
|
38
38
|
reaper.repositories(owner, privacy).each do |repo|
|
39
39
|
next unless repos.include?(repo["name"])
|
40
40
|
puts "#{clone_type}: #{repo["name"]}"
|
41
|
-
|
41
|
+
path = "#{mirror_directory}/#{repo["name"]}"
|
42
|
+
path += ".git" if clone_type==:mirror
|
43
|
+
target_directory = Pathname.new(path)
|
42
44
|
if target_directory.exist?
|
43
45
|
run("cd #{target_directory} && git fetch")
|
44
46
|
else
|
45
|
-
run("git clone #{"--mirror" if clone_type==:mirror} git@github.com:#{repo[
|
47
|
+
run("git clone #{"--mirror" if clone_type==:mirror} git@github.com:#{repo['full_name']}.git #{target_directory}")
|
46
48
|
end
|
47
49
|
puts "" # blank line
|
48
50
|
end
|
data/lib/offline/github.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Offline
|
2
2
|
class Github
|
3
3
|
include HTTParty
|
4
|
-
base_uri '
|
4
|
+
base_uri 'https://api.github.com'
|
5
|
+
headers 'User-Agent' => "Offline v#{Offline::VERSION} - https://github.com/vertis/offline"
|
5
6
|
|
6
7
|
attr_reader :username
|
7
8
|
|
@@ -9,15 +10,24 @@ module Offline
|
|
9
10
|
@username = user
|
10
11
|
if pass
|
11
12
|
self.class.basic_auth user, pass
|
12
|
-
|
13
|
+
response = self.class.get("/user")
|
14
|
+
if response.code==401
|
13
15
|
raise Exception.new({"error"=>"not authorized"})
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
def repositories(owner
|
19
|
-
|
20
|
-
|
20
|
+
def repositories(owner, privacy=:all)
|
21
|
+
res = nil
|
22
|
+
if owner == @username
|
23
|
+
res = self.class.get("/user/repos?per_page=100")
|
24
|
+
else
|
25
|
+
res = self.class.get("/users/#{owner}/repos?per_page=100")
|
26
|
+
if res.code == 404
|
27
|
+
res = self.class.get("/orgs/#{owner}/repos?per_page=100")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
repos = res.parsed_response
|
21
31
|
if privacy==:"private-only"
|
22
32
|
repos = repos.select {|r| r["private"]==true }
|
23
33
|
end
|
data/lib/offline/version.rb
CHANGED
data/offline.gemspec
CHANGED
@@ -7,11 +7,12 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Offline::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Luke Chadwick"]
|
10
|
-
s.email = ["
|
10
|
+
s.email = ["me@vertis.io"]
|
11
11
|
s.homepage = "https://github.com/vertis/offline"
|
12
12
|
s.summary = %q{Tools for working with github}
|
13
13
|
s.description = %q{Tools for working with github}
|
14
|
-
|
14
|
+
|
15
|
+
s.required_ruby_version = '>= 1.9.3'
|
15
16
|
s.rubyforge_project = "offline" # Not really
|
16
17
|
|
17
18
|
s.add_dependency("httparty")
|
data/spec/offline/github_spec.rb
CHANGED
@@ -7,23 +7,43 @@ describe Offline::Github do
|
|
7
7
|
|
8
8
|
context "authenticated user" do
|
9
9
|
it "should fail if I give the wrong password" do
|
10
|
-
expect { Offline::Github.new('vertis', 'password') }.
|
10
|
+
expect { Offline::Github.new('vertis', 'password') }.to raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
unless ENV['TRAVIS']
|
14
|
+
it "should accept an oauth token as the password" do
|
15
|
+
raise "Must set VALID_TEST_ACCESS_TOKEN environment variable" unless ENV['VALID_TEST_ACCESS_TOKEN']
|
16
|
+
expect { Offline::Github.new(ENV['VALID_TEST_ACCESS_TOKEN'], 'x-oauth-basic') }.not_to raise_error
|
17
|
+
end
|
18
|
+
else
|
19
|
+
puts "Skipping oauth test because Travis CU doesn't have access to a valid token"
|
11
20
|
end
|
12
21
|
end
|
13
22
|
|
14
23
|
describe "#repositories" do
|
15
24
|
it "should return a list of repositories" do
|
16
|
-
user_response =
|
17
|
-
response =
|
18
|
-
|
19
|
-
Offline::Github.
|
25
|
+
user_response = double("response", :parsed_response => {})
|
26
|
+
response = double("response", :parsed_response => [])
|
27
|
+
response.should_receive(:code).and_return(200)
|
28
|
+
Offline::Github.should_receive(:get).with("/users/test/repos?per_page=100").and_return(response)
|
29
|
+
Offline::Github.new('user').repositories('test').should == []
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return a list of the users repositories" do
|
33
|
+
user_response = double("response", :parsed_response => {})
|
34
|
+
user_response.should_receive(:code).and_return(200)
|
35
|
+
response = double("response", :parsed_response => [])
|
36
|
+
Offline::Github.should_receive(:get).with("/user").and_return(user_response)
|
37
|
+
Offline::Github.should_receive(:get).with("/user/repos?per_page=100").and_return(response)
|
38
|
+
Offline::Github.new('test', 'password').repositories('test').should == []
|
20
39
|
end
|
21
40
|
|
22
41
|
it "should return only private repositories if requested" do
|
23
|
-
user_response =
|
24
|
-
|
25
|
-
|
26
|
-
Offline::Github.should_receive(:get).with("/
|
42
|
+
user_response = double("response")
|
43
|
+
user_response.should_receive(:code).and_return(200)
|
44
|
+
response = double("response", :parsed_response => [{"name" => 'public_repo', "private"=>false}, {"name" => 'private_repo', "private"=>true}])
|
45
|
+
Offline::Github.should_receive(:get).with("/user").and_return(user_response)
|
46
|
+
Offline::Github.should_receive(:get).with("/user/repos?per_page=100").and_return(response)
|
27
47
|
repos = Offline::Github.new('test', 'password').repositories('test', :"private-only")
|
28
48
|
repos.count.should == 1
|
29
49
|
repos.should == [{"name" => 'private_repo', "private"=>true}]
|
metadata
CHANGED
@@ -1,90 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: offline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Luke Chadwick
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: httparty
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: thor
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Tools for working with github
|
79
70
|
email:
|
80
|
-
-
|
71
|
+
- me@vertis.io
|
81
72
|
executables:
|
82
73
|
- offline
|
83
74
|
extensions: []
|
84
75
|
extra_rdoc_files: []
|
85
76
|
files:
|
86
77
|
- .gitignore
|
87
|
-
- .
|
78
|
+
- .rspec
|
88
79
|
- .travis.yml
|
89
80
|
- Gemfile
|
90
81
|
- LICENSE
|
@@ -105,27 +96,26 @@ files:
|
|
105
96
|
- spec/spec_helper.rb
|
106
97
|
homepage: https://github.com/vertis/offline
|
107
98
|
licenses: []
|
99
|
+
metadata: {}
|
108
100
|
post_install_message:
|
109
101
|
rdoc_options: []
|
110
102
|
require_paths:
|
111
103
|
- lib
|
112
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
105
|
requirements:
|
115
|
-
- -
|
106
|
+
- - '>='
|
116
107
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
108
|
+
version: 1.9.3
|
118
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
110
|
requirements:
|
121
|
-
- -
|
111
|
+
- - '>='
|
122
112
|
- !ruby/object:Gem::Version
|
123
113
|
version: '0'
|
124
114
|
requirements: []
|
125
115
|
rubyforge_project: offline
|
126
|
-
rubygems_version:
|
116
|
+
rubygems_version: 2.0.3
|
127
117
|
signing_key:
|
128
|
-
specification_version:
|
118
|
+
specification_version: 4
|
129
119
|
summary: Tools for working with github
|
130
120
|
test_files:
|
131
121
|
- spec/offline/app_spec.rb
|
data/.rvmrc
DELETED