metahub 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rvmrc +2 -0
- data/Gemfile +10 -0
- data/LICENSE +22 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/bin/metahub +27 -0
- data/lib/metahub.rb +11 -0
- data/lib/metahub/auth.rb +22 -0
- data/lib/metahub/backup.rb +33 -0
- data/lib/metahub/github.rb +68 -0
- data/lib/metahub/version.rb +3 -0
- data/metahub.gemspec +17 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5bd5d186b064b2f24cd7d6ebcf17fcb51bad9dbf
|
4
|
+
data.tar.gz: 360f528163016f5a368dc2bfb8cfa3bbfa5926a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 515e34d15a74996506338ad431b9424f6365aa6269218a6f281a30b17120d79ba52f93db6687f68733f5adc7a24d50a034c60dee86d42d249c7ecbc62695fd48
|
7
|
+
data.tar.gz: 1f967a8ad3bbb7a0ea26c75accae1df1d4427a3e36f7fa258cfeb4b4e0f95ca211e6e214842158f58914bd09ddc3783350aa6101066071cbae16ba42f8517e57
|
data/.gitignore
ADDED
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Brian Leonard
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Metahub
|
2
|
+
|
3
|
+
Do things to all your github repositories.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
$ git clone git@github.com:bleonard/metahub.git
|
8
|
+
$ cd metahub
|
9
|
+
$ bundle install
|
10
|
+
|
11
|
+
## Backup
|
12
|
+
|
13
|
+
$ bundle exec ./bin/metahub backup
|
14
|
+
|
15
|
+
Github Username: bleonard
|
16
|
+
Github Password: ***********
|
17
|
+
|
18
|
+
assaf/vanity...
|
19
|
+
git clone git@github.com:assaf/vanity.git /Users/brian/bleonard/metahub/2014.3.10/assaf/vanity
|
20
|
+
Cloning into '/Users/brian/bleonard/metahub/2014.3.10/assaf/vanity'...
|
21
|
+
remote: Reusing existing pack: 4550, done.
|
22
|
+
remote: Total 4550 (delta 0), reused 0 (delta 0)
|
23
|
+
Receiving objects: 100% (4550/4550), 2.87 MiB | 86.00 KiB/s, done.
|
24
|
+
Resolving deltas: 100% (2049/2049), done.
|
25
|
+
Checking connectivity... done
|
26
|
+
...done!
|
27
|
+
|
28
|
+
bleonard/actionHero...
|
29
|
+
git clone git@github.com:bleonard/actionHero.git /Users/brian/bleonard/metahub/2014.3.10/bleonard/actionHero
|
30
|
+
Cloning into '/Users/brian/bleonard/metahub/2014.3.10/bleonard/actionHero'...
|
31
|
+
remote: Counting objects: 3360, done.
|
32
|
+
remote: Compressing objects: 100% (1868/1868), done.
|
33
|
+
|
34
|
+
... lots of those
|
35
|
+
|
36
|
+
## Repositories
|
37
|
+
|
38
|
+
$ bundle exec ./bin/metahub repositories
|
39
|
+
|
40
|
+
Github Username: bleonard
|
41
|
+
Github Password: ***********
|
42
|
+
|
43
|
+
assaf/vanity
|
44
|
+
bleonard/actionHero
|
45
|
+
bleonard/blackbook
|
46
|
+
bleonard/bleonard.github.com
|
47
|
+
bleonard/bootstrap
|
48
|
+
|
49
|
+
... lots of those
|
50
|
+
|
51
|
+
## TODO
|
52
|
+
|
53
|
+
* Probably more commands to come
|
data/Rakefile
ADDED
data/bin/metahub
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'commander/import'
|
4
|
+
require 'metahub'
|
5
|
+
|
6
|
+
program :name, 'metahub'
|
7
|
+
program :version, Metahub::VERSION
|
8
|
+
program :description, 'Do things to lots of repos.'
|
9
|
+
|
10
|
+
command :backup do |c|
|
11
|
+
c.syntax = 'metahub backup'
|
12
|
+
c.summary = ''
|
13
|
+
c.description = 'Download them all'
|
14
|
+
c.action do |args, options|
|
15
|
+
Metahub::Backup.now!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
command :repositories do |c|
|
20
|
+
c.syntax = 'metahub repositories'
|
21
|
+
c.description = 'Lists known repositories'
|
22
|
+
c.action do |args, options|
|
23
|
+
Metahub::GithubService.owner.repositories.each do |name|
|
24
|
+
puts name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/metahub.rb
ADDED
data/lib/metahub/auth.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Metahub
|
2
|
+
module Auth
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def fetch
|
6
|
+
username
|
7
|
+
password
|
8
|
+
end
|
9
|
+
|
10
|
+
def username
|
11
|
+
@username ||= ask("Github Username: ")
|
12
|
+
end
|
13
|
+
|
14
|
+
def password
|
15
|
+
@password ||= ask("Github Password: ") { |q| q.echo = "*" }
|
16
|
+
end
|
17
|
+
|
18
|
+
def otp_code
|
19
|
+
@otp_code ||= ask("Github OTP Code (via phone): ") { |q| q.echo = "*" }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Metahub
|
2
|
+
module Backup
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def now!
|
6
|
+
directory
|
7
|
+
GithubService.owner.repositories.each do |name|
|
8
|
+
dir = "#{directory}/#{name}"
|
9
|
+
if File.exist?(dir)
|
10
|
+
FileUtils.rm_rf(dir)
|
11
|
+
end
|
12
|
+
FileUtils.mkdir_p(dir)
|
13
|
+
|
14
|
+
puts "#{name}..."
|
15
|
+
cmd = "git clone git@github.com:#{name}.git #{dir}"
|
16
|
+
puts cmd
|
17
|
+
system cmd
|
18
|
+
puts " ...done!"
|
19
|
+
puts ""
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def directory
|
24
|
+
return @directory if @directory
|
25
|
+
time = Time.now
|
26
|
+
|
27
|
+
@directory = File.join(File.expand_path("."), "#{time.year}.#{time.month}.#{time.day}")
|
28
|
+
FileUtils.mkdir_p(@directory) unless File.exist?(@directory)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
Octokit.user_agent = "Metahub : Octokit Ruby Gem #{Octokit::VERSION}"
|
3
|
+
|
4
|
+
module Metahub
|
5
|
+
class GithubService
|
6
|
+
def self.owner
|
7
|
+
@owner ||= self.new
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_reader :client
|
11
|
+
def initialize
|
12
|
+
client_options = { :login => Auth.username,
|
13
|
+
:password => Auth.password,
|
14
|
+
:auto_traversal => true
|
15
|
+
}
|
16
|
+
token_options = { :scopes => ["repo"],
|
17
|
+
:client_id => "099bb3db6bf979a92391",
|
18
|
+
:client_secret => "ad2cbeac50c2d19478b1d9041b72fd7b9a3b0d26",
|
19
|
+
:idempotent => true
|
20
|
+
}
|
21
|
+
|
22
|
+
simple = Octokit::Client.new(client_options)
|
23
|
+
begin
|
24
|
+
token = simple.create_authorization(token_options)
|
25
|
+
@client = Octokit::Client.new(:access_token => token[:token])
|
26
|
+
rescue Octokit::OneTimePasswordRequired => e
|
27
|
+
token = simple.create_authorization(token_options.merge(:headers => { "X-GitHub-OTP" => Auth.otp_code }))
|
28
|
+
@client = Octokit::Client.new(:access_token => token[:token])
|
29
|
+
end
|
30
|
+
# puts @client.ratelimit_remaining
|
31
|
+
end
|
32
|
+
|
33
|
+
def repositories
|
34
|
+
repos = []
|
35
|
+
|
36
|
+
client.repositories.each do |hash|
|
37
|
+
repos << hash.full_name
|
38
|
+
end
|
39
|
+
|
40
|
+
self.organizations(client.login).each do |org_name|
|
41
|
+
client.organization_repositories(org_name).each do |hash|
|
42
|
+
repos << hash.full_name
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# return these, ignoring requested ones
|
47
|
+
repos.compact.uniq
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def organizations(username)
|
53
|
+
names = []
|
54
|
+
|
55
|
+
client.organizations.each do |hash|
|
56
|
+
names << hash.login
|
57
|
+
end
|
58
|
+
|
59
|
+
unless username == client.login
|
60
|
+
client.organizations(username).each do |hash|
|
61
|
+
names << hash.login
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
names.compact.uniq
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/metahub.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/metahub/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Brian Leonard"]
|
6
|
+
gem.email = ["brian@bleonard.com"]
|
7
|
+
gem.description = %q{Stuff with lots of repos}
|
8
|
+
gem.summary = %q{Stuff with lots of repos}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "metahub"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Metahub::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metahub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Leonard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Stuff with lots of repos
|
14
|
+
email:
|
15
|
+
- brian@bleonard.com
|
16
|
+
executables:
|
17
|
+
- metahub
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .rvmrc
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- bin/metahub
|
28
|
+
- lib/metahub.rb
|
29
|
+
- lib/metahub/auth.rb
|
30
|
+
- lib/metahub/backup.rb
|
31
|
+
- lib/metahub/github.rb
|
32
|
+
- lib/metahub/version.rb
|
33
|
+
- metahub.gemspec
|
34
|
+
homepage: ''
|
35
|
+
licenses: []
|
36
|
+
metadata: {}
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 2.0.3
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Stuff with lots of repos
|
57
|
+
test_files: []
|