github_cloner 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,18 +1,23 @@
1
1
  = github_cloner
2
2
 
3
- With github_cloner you have an easy way to clone your all projects from github.
3
+ With github_cloner you have an easy way to clone all your projects from github.
4
4
 
5
5
  == Usage
6
6
 
7
7
  gem install github_cloner
8
8
 
9
- $ github_cloner [github_username] [github option] [path to collection]
10
-
11
- github_username - your github username (Thanks, Captain Obvious)
12
- github option - ssh(Read-Write), http (Read-Only), git(Read-Only)
13
- path - path to the collection of projects
14
-
15
- $ github_cloner nashby http ~/Desktop/github_projects
9
+ Usage: github_cloner [options]
10
+
11
+ Specific options:
12
+ -u, --username GITHUB_USERNAME Require the GITHUB_USERNAME before executing your script
13
+ -p, --path [PATH] PATH to new repos collection (default: current directory)
14
+ -m, --method [METHOD] git clone [METHOD] (http, git, ssh. default: http)
15
+ -r, --repos x,y,z List of needed repos (default: all repos from your profile)
16
+
17
+ Common options:
18
+ -h, --help Show this message
19
+
20
+ $ github_cloner --username nashby --method http --path ~/Desktop/github_projects
16
21
 
17
22
  == Contributing to github_cloner
18
23
 
data/Rakefile CHANGED
@@ -17,11 +17,11 @@ Jeweler::Tasks.new do |gem|
17
17
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
18
  gem.name = "github_cloner"
19
19
  gem.homepage = "http://github.com/nashby/github_cloner"
20
- gem.version = "0.1"
20
+ gem.version = "0.2"
21
21
  gem.license = "MIT"
22
22
  gem.executables = ["github_cloner"]
23
- gem.summary = %Q{an easy way to clone your all projects from github}
24
- gem.description = %Q{an easy way to clone your all projects from github}
23
+ gem.summary = %Q{an easy way to clone all your projects from github}
24
+ gem.description = %Q{an easy way to clone all your projects from github}
25
25
  gem.email = "younash@gmail.com"
26
26
  gem.authors = ["Vasiliy Ermolovich"]
27
27
  end
data/bin/github_cloner CHANGED
@@ -1,10 +1,66 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require 'optparse'
5
+ require 'ostruct'
3
6
  require 'github_cloner'
7
+
4
8
  include Github
5
- if ARGV.size >= 3
6
- cloner = Github::Cloner.new ARGV[0].to_s, ARGV[1].to_s, ARGV[2].to_s
9
+
10
+ class OptionParser
11
+ def self.parse(args)
12
+ options = OpenStruct.new
13
+ options.username = nil
14
+ options.git_method = 'http'
15
+ options.path = "."
16
+ options.repos = []
17
+
18
+ opts = OptionParser.new do |opts|
19
+ opts.banner = "Usage: github_cloner [options]"
20
+
21
+ opts.separator ""
22
+ opts.separator "Specific options:"
23
+
24
+ # Mandatory argument.
25
+ opts.on("-u", "--username GITHUB_USERNAME",
26
+ "Require the GITHUB_USERNAME before executing your script") do |username|
27
+ options.username = username
28
+ end
29
+
30
+ # Optional argument
31
+ opts.on("-p", "--path [PATH]",
32
+ "PATH to new repos collection (default: current directory)") do |path|
33
+ options.path = path
34
+ end
35
+
36
+ opts.on("-m", "--method [METHOD]", ['http', 'git', 'ssh'],
37
+ "git clone [METHOD] (http, git, ssh. default: http)") do |git_method|
38
+ options.git_method = git_method
39
+ end
40
+
41
+ # List ofrepos.
42
+ opts.on("-r", "--repos x,y,z", Array, "List of needed repos (default: all)") do |repos|
43
+ options.repos = repos
44
+ end
45
+
46
+ opts.separator ""
47
+ opts.separator "Common options:"
48
+
49
+ opts.on_tail("-h", "--help", "Show this message") do
50
+ puts opts
51
+ exit
52
+ end
53
+ end
54
+ opts.parse!(args)
55
+ options
56
+ end
57
+ end
58
+
59
+ options = OptionParser.parse(ARGV)
60
+
61
+ unless options.username.nil?
62
+ cloner = Github::Cloner.new options.username.to_s, options.git_method.to_s, options.path.to_s, options.repos
7
63
  cloner.clone
8
64
  else
9
- puts 'Sorry, bro. I need your github name, git method (ssh, http, or git) and path to your new repos collection. Just use something like this: github_cloner nashby ssh ~/Desktop'
65
+ puts 'Sorry, bro. I need to know your github name'
10
66
  end
@@ -0,0 +1,66 @@
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 = %q{github_cloner}
8
+ s.version = "0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Vasiliy Ermolovich"]
12
+ s.date = %q{2011-02-22}
13
+ s.default_executable = %q{github_cloner}
14
+ s.description = %q{an easy way to clone all your projects from github}
15
+ s.email = %q{younash@gmail.com}
16
+ s.executables = ["github_cloner"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "bin/github_cloner",
28
+ "github_cloner.gemspec",
29
+ "lib/github_cloner.rb",
30
+ "pkg/github_cloner-0.1.gem",
31
+ "pkg/github_cloner-0.2.gem",
32
+ "test/helper.rb",
33
+ "test/test_github_cloner.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/nashby/github_cloner}
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.5.0}
39
+ s.summary = %q{an easy way to clone all your projects from github}
40
+ s.test_files = [
41
+ "test/helper.rb",
42
+ "test/test_github_cloner.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
52
+ s.add_development_dependency(%q<rcov>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<shoulda>, [">= 0"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
57
+ s.add_dependency(%q<rcov>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<shoulda>, [">= 0"])
61
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
63
+ s.add_dependency(%q<rcov>, [">= 0"])
64
+ end
65
+ end
66
+
data/lib/github_cloner.rb CHANGED
@@ -6,10 +6,11 @@ module Github
6
6
 
7
7
  GITHUB_URL_API = 'http://github.com/api/v2/json/repos/show/'
8
8
 
9
- def initialize(github_uname, mode, path)
9
+ def initialize(github_uname, mode, path, repos)
10
10
  @github_uname = github_uname
11
11
  @mode = mode
12
12
  @path = path
13
+ @repos = repos
13
14
  end
14
15
 
15
16
  def make_git_url(repo_name)
@@ -26,7 +27,7 @@ module Github
26
27
  def get_gits
27
28
  repos = JSON.parse(open(GITHUB_URL_API+@github_uname).read)
28
29
  gits = []
29
- repos['repositories'].each { |repo| gits << make_git_url(repo['name']) }
30
+ repos['repositories'].each { |repo| gits << make_git_url(repo['name']) if @repos.include? repo['name'] or @repos.empty? }
30
31
  gits
31
32
  end
32
33
 
Binary file
Binary file
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: github_cloner
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.1"
5
+ version: "0.2"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vasiliy Ermolovich
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-20 00:00:00 +02:00
13
+ date: 2011-02-22 00:00:00 +02:00
14
14
  default_executable: github_cloner
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,7 @@ dependencies:
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: *id004
60
- description: an easy way to clone your all projects from github
60
+ description: an easy way to clone all your projects from github
61
61
  email: younash@gmail.com
62
62
  executables:
63
63
  - github_cloner
@@ -73,7 +73,10 @@ files:
73
73
  - README.rdoc
74
74
  - Rakefile
75
75
  - bin/github_cloner
76
+ - github_cloner.gemspec
76
77
  - lib/github_cloner.rb
78
+ - pkg/github_cloner-0.1.gem
79
+ - pkg/github_cloner-0.2.gem
77
80
  - test/helper.rb
78
81
  - test/test_github_cloner.rb
79
82
  has_rdoc: true
@@ -90,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
93
  requirements:
91
94
  - - ">="
92
95
  - !ruby/object:Gem::Version
93
- hash: -746922655
96
+ hash: -971290915
94
97
  segments:
95
98
  - 0
96
99
  version: "0"
@@ -106,7 +109,7 @@ rubyforge_project:
106
109
  rubygems_version: 1.5.0
107
110
  signing_key:
108
111
  specification_version: 3
109
- summary: an easy way to clone your all projects from github
112
+ summary: an easy way to clone all your projects from github
110
113
  test_files:
111
114
  - test/helper.rb
112
115
  - test/test_github_cloner.rb