git-grabber 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd8b36e159cb22d0c3921cc03ae0f6615f40dfe9
4
- data.tar.gz: 68fb24b38ca0b89fc41b12f825b23e2e5b683b74
3
+ metadata.gz: 35e2d2b91c9aa98f3a397984cef79927498327db
4
+ data.tar.gz: 1325bade58dae8a60afa2904ef930f31ee298f5c
5
5
  SHA512:
6
- metadata.gz: 54ff437ea434e432d986c923903819a1348112032bc573e05e80332b519303a7e13cfe56df5d8504552195ea8676e902423b25065c8021c19133630b85d4d2e9
7
- data.tar.gz: 18f25133ab80dc29f23e44ac62ed61ff2a4af4656485a5af4498ad09b3c22d02c42e19724b39230c5b4f0272916c0ee6bf2a8c32370c303f16456aff3dbd657b
6
+ metadata.gz: 947fa222c6e446af4a4505369ce778bcf5f83b52d935a2bf08c9fc441f94ebcca38c788868d0c950d6b1d027f454cacdd1fb62cc02b9526e507fb86b8282cda5
7
+ data.tar.gz: eae55e29b7d946a0b7e2e60d46061ab95fee651073ddbbdd41f7f174a121046ccc35895277aefe68204896f08323db2b7c28f458e38c352e5795e9c2ccca0f24
data/README.md CHANGED
@@ -1,3 +1,37 @@
1
- # git_grabber
1
+ # Git Grabber
2
2
 
3
- Ridiculous proof-of-concept git backupy thing.
3
+ A simple github backup tool, for peace of mind.
4
+
5
+ ## Usage
6
+
7
+ Add settings to config.json:
8
+
9
+ 1. Generate a github personal token
10
+ 2. Set an interval (min 60 seconds. Depending on your usage once or twice a day is probably enough, your mileage may vary.)
11
+ 3. Set a backup directory where projects should be cloned/fetched.
12
+
13
+ Run the application `gitgrabber` from your command line (you can fork it to the background in bash with `gitgrabber &`) the application will log its progress so redirect to a file or `/dev/null` if you're not interested.
14
+
15
+ For issues, please use the issue tracker on the repository.
16
+
17
+ Pull requests welcome.
18
+
19
+ Copyright (c) 2014 Peter Mellett
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ of this software and associated documentation files (the "Software"), to deal
23
+ in the Software without restriction, including without limitation the rights
24
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ copies of the Software, and to permit persons to whom the Software is
26
+ furnished to do so, subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in all
29
+ copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'git_grabber'
3
3
 
4
- g = git_grabber::Application.new
4
+ g = GitGrabber::Application.new
5
5
 
6
6
  g.config './config.json'
7
7
  g.go
@@ -6,12 +6,12 @@ require 'git_grabber/puller'
6
6
  module GitGrabber
7
7
  class Application
8
8
  def config(path)
9
- @config = git_grabber::Config.new path
10
- @api = git_grabber::Api.new @config.github_personal_token
9
+ @config = GitGrabber::Config.new File.read path
10
+ @api = GitGrabber::Api.new @config.github_personal_token
11
11
  end
12
12
 
13
13
  def go
14
- puller = git_grabber::Puller.new @config.backup_directory
14
+ puller = GitGrabber::Puller.new @config.backup_directory
15
15
 
16
16
  while true
17
17
  repos = @api.fetch_all
@@ -4,17 +4,21 @@ module GitGrabber
4
4
  class Config
5
5
  attr_accessor :interval, :github_personal_token, :backup_directory
6
6
 
7
- def initialize(path)
8
- config = JSON.parse(File.read path)
7
+ def initialize(conf)
8
+ missing = []
9
+ config = JSON.parse(conf)
10
+
9
11
  %w{ interval github_personal_token backup_directory }.each do |required|
10
12
  if config[required].nil?
11
- raise "missing required config option #{required}"
13
+ missing << required
12
14
  end
13
15
  end
14
16
 
15
- self.interval = config["interval"]
16
- self.github_personal_token = config["github_personal_token"]
17
- self.backup_directory = config["backup_directory"]
17
+ raise "missing required options #{missing.join(', ')}" unless missing.empty?
18
+
19
+ @interval = [config["interval"], 60].max # force 60 seconds min interval
20
+ @github_personal_token = config["github_personal_token"]
21
+ @backup_directory = config["backup_directory"]
18
22
  end
19
23
  end
20
24
  end
@@ -16,13 +16,13 @@ module GitGrabber
16
16
  def fetch_repository(addr, path)
17
17
  puts "fetch #{addr} to #{File.join @base_dir, path}"
18
18
  Dir.chdir(File.join @base_dir, path) do
19
- %x{ git fetch --all }
19
+ `git fetch --all`
20
20
  end
21
21
  end
22
22
 
23
23
  def clone_repository(addr, path)
24
24
  puts "clone #{addr} to #{File.join @base_dir, path}"
25
- %x{ git clone --bare #{addr} #{File.join @base_dir, path} }
25
+ `git clone --bare #{addr} #{File.join @base_dir, path}`
26
26
  end
27
27
  end
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module GitGrabber
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-grabber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mellett