git-grabber 0.0.1
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/LICENSE.txt +22 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/bin/gitgrabber +7 -0
- data/git_grabber.gemspec +27 -0
- data/lib/git_grabber.rb +27 -0
- data/lib/git_grabber/api.rb +13 -0
- data/lib/git_grabber/config.rb +20 -0
- data/lib/git_grabber/puller.rb +28 -0
- data/lib/git_grabber/version.rb +3 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fd8b36e159cb22d0c3921cc03ae0f6615f40dfe9
|
4
|
+
data.tar.gz: 68fb24b38ca0b89fc41b12f825b23e2e5b683b74
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54ff437ea434e432d986c923903819a1348112032bc573e05e80332b519303a7e13cfe56df5d8504552195ea8676e902423b25065c8021c19133630b85d4d2e9
|
7
|
+
data.tar.gz: 18f25133ab80dc29f23e44ac62ed61ff2a4af4656485a5af4498ad09b3c22d02c42e19724b39230c5b4f0272916c0ee6bf2a8c32370c303f16456aff3dbd657b
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Peter Mellett
|
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
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/gitgrabber
ADDED
data/git_grabber.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'git_grabber/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "git-grabber"
|
8
|
+
spec.version = GitGrabber::VERSION
|
9
|
+
spec.authors = ["Peter Mellett"]
|
10
|
+
spec.email = ["pjm@petermellett.co.uk"]
|
11
|
+
spec.summary = "Simple application to back up github repositories"
|
12
|
+
spec.homepage = "http://www.github.com/wadtech/gitgrabber"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = %w(LICENSE.txt README.md Rakefile git_grabber.gemspec)
|
16
|
+
spec.files += Dir.glob("lib/**/*.rb")
|
17
|
+
spec.files += Dir.glob("bin/**/*")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
|
26
|
+
spec.add_runtime_dependency "octokit"
|
27
|
+
end
|
data/lib/git_grabber.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'git_grabber/version'
|
2
|
+
require 'git_grabber/config'
|
3
|
+
require 'git_grabber/api'
|
4
|
+
require 'git_grabber/puller'
|
5
|
+
|
6
|
+
module GitGrabber
|
7
|
+
class Application
|
8
|
+
def config(path)
|
9
|
+
@config = git_grabber::Config.new path
|
10
|
+
@api = git_grabber::Api.new @config.github_personal_token
|
11
|
+
end
|
12
|
+
|
13
|
+
def go
|
14
|
+
puller = git_grabber::Puller.new @config.backup_directory
|
15
|
+
|
16
|
+
while true
|
17
|
+
repos = @api.fetch_all
|
18
|
+
|
19
|
+
repos.each do |details|
|
20
|
+
puller.update("https://github.com/#{details.full_name}", "#{details.name}.git")
|
21
|
+
end
|
22
|
+
|
23
|
+
sleep(@config.interval)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module GitGrabber
|
4
|
+
class Config
|
5
|
+
attr_accessor :interval, :github_personal_token, :backup_directory
|
6
|
+
|
7
|
+
def initialize(path)
|
8
|
+
config = JSON.parse(File.read path)
|
9
|
+
%w{ interval github_personal_token backup_directory }.each do |required|
|
10
|
+
if config[required].nil?
|
11
|
+
raise "missing required config option #{required}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
self.interval = config["interval"]
|
16
|
+
self.github_personal_token = config["github_personal_token"]
|
17
|
+
self.backup_directory = config["backup_directory"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GitGrabber
|
2
|
+
class Puller
|
3
|
+
def initialize(backup_dir)
|
4
|
+
@base_dir = backup_dir
|
5
|
+
end
|
6
|
+
|
7
|
+
def update(addr, path)
|
8
|
+
if File.directory? File.join(@base_dir, path)
|
9
|
+
fetch_repository(addr, path)
|
10
|
+
else
|
11
|
+
clone_repository(addr, path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def fetch_repository(addr, path)
|
17
|
+
puts "fetch #{addr} to #{File.join @base_dir, path}"
|
18
|
+
Dir.chdir(File.join @base_dir, path) do
|
19
|
+
%x{ git fetch --all }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def clone_repository(addr, path)
|
24
|
+
puts "clone #{addr} to #{File.join @base_dir, path}"
|
25
|
+
%x{ git clone --bare #{addr} #{File.join @base_dir, path} }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-grabber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Mellett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- pjm@petermellett.co.uk
|
72
|
+
executables:
|
73
|
+
- gitgrabber
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- git_grabber.gemspec
|
81
|
+
- lib/git_grabber/puller.rb
|
82
|
+
- lib/git_grabber/version.rb
|
83
|
+
- lib/git_grabber/config.rb
|
84
|
+
- lib/git_grabber/api.rb
|
85
|
+
- lib/git_grabber.rb
|
86
|
+
- bin/gitgrabber
|
87
|
+
homepage: http://www.github.com/wadtech/gitgrabber
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.0.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Simple application to back up github repositories
|
111
|
+
test_files: []
|