offline 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rvmrc +2 -0
- data/Gemfile +6 -0
- data/LICENSE +18 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/bin/offline +37 -0
- data/lib/offline/github.rb +19 -0
- data/lib/offline/helpers.rb +8 -0
- data/lib/offline/version.rb +3 -0
- data/lib/offline.rb +11 -0
- data/offline.gemspec +26 -0
- data/spec/offline/github_spec.rb +18 -0
- data/spec/spec_helper.rb +5 -0
- metadata +101 -0
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2011 Luke Chadwick
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
5
|
+
deal in the Software without restriction, including without limitation the
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Offline
|
2
|
+
|
3
|
+
Offline is an open source command line tool for mirroring github projects.
|
4
|
+
|
5
|
+
## Installation & Usage
|
6
|
+
|
7
|
+
* Install Offline:
|
8
|
+
|
9
|
+
$> gem install offline
|
10
|
+
|
11
|
+
* mirror all public repositories for a given user:
|
12
|
+
|
13
|
+
$> offline mirror vertis
|
14
|
+
|
15
|
+
* mirror specific repositories:
|
16
|
+
|
17
|
+
$> offline mirror vertis --only flynn offline
|
18
|
+
|
19
|
+
* exclude repositories
|
20
|
+
|
21
|
+
$> offline mirror vertis --without flynn offline
|
22
|
+
|
23
|
+
* your private repository
|
24
|
+
|
25
|
+
$> offline mirror vertis --only mysecretproject --password password1
|
26
|
+
|
27
|
+
##Contributing
|
28
|
+
|
29
|
+
Fork on GitHub, create a test & send a pull request.
|
30
|
+
|
31
|
+
##Bugs
|
32
|
+
|
33
|
+
Use the [Issue Tracker](http://github.com/vertis/offline/issues)
|
34
|
+
|
35
|
+
## License & Acknowledgments
|
36
|
+
|
37
|
+
Offline is distributed under the MIT license, for full details please see the LICENSE file.
|
38
|
+
|
data/Rakefile
ADDED
data/bin/offline
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
3
|
+
|
4
|
+
require "rubygems" # ruby1.9 doesn't "require" it though
|
5
|
+
require "bundler/setup"
|
6
|
+
require "thor"
|
7
|
+
require 'offline'
|
8
|
+
|
9
|
+
class OfflineApp < Thor
|
10
|
+
include Offline::Helpers
|
11
|
+
|
12
|
+
desc "mirror GITHUB_USER", "mirror the repositories of a given github user"
|
13
|
+
method_option :only, :type => :array, :required => false
|
14
|
+
method_option :without, :type => :array, :required => false
|
15
|
+
method_option :password, :type => :string, :required => false, :aliases => '-p'
|
16
|
+
method_option :output, :type => :string, :default => 'mirror', :required => false, :aliases => '-o'
|
17
|
+
def mirror(user)
|
18
|
+
mirror_directory = "#{options[:output]}/#{user}"
|
19
|
+
Pathname.new(mirror_directory).mkpath
|
20
|
+
reaper = Offline::Github.new(user, options[:password])
|
21
|
+
all_repos = reaper.repositories.map {|r| r["name"] }
|
22
|
+
repos = all_repos & (options[:only] || all_repos) # TODO: Might be a better way of doing this
|
23
|
+
repos = (repos) - Array(options[:without])
|
24
|
+
reaper.repositories.each do |repo|
|
25
|
+
next unless repos.include?(repo["name"])
|
26
|
+
puts "Mirroring: #{repo["name"]}"
|
27
|
+
target_directory = Pathname.new("#{mirror_directory}/#{repo["name"]}.git")
|
28
|
+
if target_directory.exist?
|
29
|
+
run("cd #{target_directory} && git fetch")
|
30
|
+
else
|
31
|
+
run("git clone --mirror git@github.com:#{repo["owner"]}/#{repo["name"]}.git #{target_directory}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
OfflineApp.start
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Offline
|
2
|
+
class Github
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'http://github.com/api/v2/json'
|
5
|
+
|
6
|
+
attr_reader :username
|
7
|
+
|
8
|
+
def initialize(user, pass=nil)
|
9
|
+
@username = user
|
10
|
+
if pass
|
11
|
+
self.class.basic_auth user, pass
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def repositories
|
16
|
+
self.class.get("/repos/show/#{@username}").parsed_response["repositories"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/offline.rb
ADDED
data/offline.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "offline/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "offline"
|
7
|
+
s.version = Offline::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Luke Chadwick"]
|
10
|
+
s.email = ["luke.a.chadwick@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/vertis/offline"
|
12
|
+
s.summary = %q{Tools for working with github}
|
13
|
+
s.description = %q{Tools for working with github}
|
14
|
+
|
15
|
+
s.rubyforge_project = "offline" # Not really
|
16
|
+
|
17
|
+
s.add_dependency("httparty")
|
18
|
+
s.add_dependency('thor')
|
19
|
+
|
20
|
+
s.add_development_dependency('rspec')
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Offline::Github do
|
4
|
+
it "should assign the github user to @username" do
|
5
|
+
Offline::Github.new('test').username.should == 'test'
|
6
|
+
end
|
7
|
+
|
8
|
+
context "#repositories" do
|
9
|
+
before :each do
|
10
|
+
response = mock("response", :parsed_response => {"repositories" => []})
|
11
|
+
Offline::Github.should_receive(:get).with("/repos/show/test").and_return(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return a list of repositories" do
|
15
|
+
Offline::Github.new('test').repositories.should == []
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: offline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luke Chadwick
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-08 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: thor
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
description: Tools for working with github
|
49
|
+
email:
|
50
|
+
- luke.a.chadwick@gmail.com
|
51
|
+
executables:
|
52
|
+
- offline
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- .gitignore
|
59
|
+
- .rvmrc
|
60
|
+
- Gemfile
|
61
|
+
- LICENSE
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- bin/offline
|
65
|
+
- lib/offline.rb
|
66
|
+
- lib/offline/github.rb
|
67
|
+
- lib/offline/helpers.rb
|
68
|
+
- lib/offline/version.rb
|
69
|
+
- offline.gemspec
|
70
|
+
- spec/offline/github_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
homepage: https://github.com/vertis/offline
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: offline
|
95
|
+
rubygems_version: 1.7.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Tools for working with github
|
99
|
+
test_files:
|
100
|
+
- spec/offline/github_spec.rb
|
101
|
+
- spec/spec_helper.rb
|