gitback 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,19 +11,13 @@ begin
11
11
  gem.homepage = "http://github.com/brycethornton/gitback"
12
12
  gem.authors = ["Bryce Thornton"]
13
13
  gem.add_dependency "grit", ">= 2.0.0"
14
+ gem.add_development_dependency "shoulda"
14
15
  end
15
16
  Jeweler::GemcutterTasks.new
16
17
  rescue LoadError
17
18
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
19
  end
19
20
 
20
- require 'rake/testtask'
21
- Rake::TestTask.new(:test) do |test|
22
- test.libs << 'lib' << 'test'
23
- test.pattern = 'test/**/test_*.rb'
24
- test.verbose = true
25
- end
26
-
27
21
  begin
28
22
  require 'rcov/rcovtask'
29
23
  Rcov::RcovTask.new do |test|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,67 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{gitback}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Bryce Thornton"]
12
+ s.date = %q{2010-05-20}
13
+ s.description = %q{Provide a list of files and/or directories and gitback will copy them to your git repo, commit and push when there are changes.}
14
+ s.email = %q{brycethornton@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "gitback.gemspec",
27
+ "lib/gitback.rb",
28
+ "lib/gitback/repository.rb",
29
+ "test/data/another/file.txt",
30
+ "test/data/another/test.txt",
31
+ "test/data/some/deep/.bash_profile",
32
+ "test/data/some/deep/directory/fstab",
33
+ "test/data/some/deep/directory/test.conf",
34
+ "test/data/some/deep/nginx.conf",
35
+ "test/data/some/test_file.txt",
36
+ "test/data/testing.txt",
37
+ "test/helper.rb",
38
+ "test/repos/.gitignore",
39
+ "test/test_gitback.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/brycethornton/gitback}
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.3.7}
45
+ s.summary = %q{A simple ruby library for backing up files to git}
46
+ s.test_files = [
47
+ "test/helper.rb",
48
+ "test/test_gitback.rb"
49
+ ]
50
+
51
+ if s.respond_to? :specification_version then
52
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<grit>, [">= 2.0.0"])
57
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<grit>, [">= 2.0.0"])
60
+ s.add_dependency(%q<shoulda>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<grit>, [">= 2.0.0"])
64
+ s.add_dependency(%q<shoulda>, [">= 0"])
65
+ end
66
+ end
67
+
@@ -38,7 +38,7 @@ module Gitback
38
38
 
39
39
  # Make sure the path exists in the repo
40
40
  if !File.exists?(dirname)
41
- FileUtils.mkpath(dirname)
41
+ FileUtils.mkdir_p(dirname)
42
42
  end
43
43
 
44
44
  # Copy the file(s) to the repo
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ hiya!
File without changes
@@ -0,0 +1 @@
1
+ This is just test data.
@@ -1,7 +1,114 @@
1
- require 'helper'
1
+ require "#{File.dirname(__FILE__)}/helper"
2
2
 
3
3
  class TestGitback < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
4
+ context 'Gitback' do
5
+ setup do
6
+ @dirname = File.expand_path(File.dirname(__FILE__))
7
+ @remote_path = File.expand_path(File.join(@dirname, *%w[repos remote_repo]))
8
+ @local_path = File.expand_path(File.join(@dirname, *%w[repos local_repo]))
9
+
10
+ # Cleanup the "remote" repo from previous tests
11
+ if File.exists?(@remote_path)
12
+ FileUtils.remove_dir(@remote_path)
13
+ end
14
+
15
+ # Cleanup the "local" repo from previous tests
16
+ if File.exists?(@local_path)
17
+ FileUtils.remove_dir(@local_path)
18
+ end
19
+
20
+ # Create the "remote" repo directory
21
+ FileUtils.mkdir_p(@remote_path)
22
+
23
+ Dir.chdir(@remote_path) do
24
+ # Init the "remote" git repo and make first commit
25
+ `git init`
26
+ `touch README`
27
+
28
+ @remote_repo = Grit::Repo.new(@remote_path)
29
+ @remote_repo.add(@remote_path + '/*')
30
+ @remote_repo.commit_all("first commit")
31
+ end
32
+
33
+ # Clone the "remote" repo to a "local" repo
34
+ `git clone #{@remote_path} #{@local_path}`
35
+ end
36
+
37
+ should "handle basic file backups" do
38
+ files = []
39
+ files << "#{@dirname}/data/testing.txt"
40
+ files << "#{@dirname}/data/some/deep/nginx.conf"
41
+
42
+ output = Gitback::Repository.new @local_path do |repo|
43
+ files.each do |file|
44
+ repo.backup file
45
+ end
46
+ end
47
+
48
+ assert_files(files)
49
+ end
50
+
51
+ should "handle directory backups" do
52
+ output = Gitback::Repository.new @local_path do |repo|
53
+ repo.backup "#{@dirname}/data/another/"
54
+ repo.backup "#{@dirname}/data/some/deep/nginx.conf"
55
+ end
56
+
57
+ files = []
58
+ files << "#{@dirname}/data/another/file.txt"
59
+ files << "#{@dirname}/data/another/test.txt"
60
+ files << "#{@dirname}/data/some/deep/nginx.conf"
61
+
62
+ assert_files(files)
63
+ end
64
+
65
+ should "use namespaces" do
66
+ output = Gitback::Repository.new @local_path do |repo|
67
+ repo.namespace 'blah.domain.com' do
68
+ repo.backup "#{@dirname}/data/another/"
69
+ repo.backup "#{@dirname}/data/some/deep/nginx.conf"
70
+ end
71
+ end
72
+
73
+ # Make sure local repo has the files
74
+ files = []
75
+ files << "blah.domain.com/#{@dirname}/data/another/file.txt"
76
+ files << "blah.domain.com/#{@dirname}/data/another/test.txt"
77
+ files << "blah.domain.com/#{@dirname}/data/some/deep/nginx.conf"
78
+
79
+ assert_files(files)
80
+ end
81
+
82
+ should "deal with symlinks" do
83
+ # Create a symlink
84
+ linked_file = "#{@dirname}/data/linked.txt"
85
+ File.symlink("#{@dirname}/data/testing.txt", linked_file)
86
+
87
+ Gitback::Repository.new @local_path do |repo|
88
+ repo.backup linked_file
89
+ end
90
+
91
+ files = [linked_file]
92
+
93
+ assert_files(files)
94
+
95
+ # Delete the link for future tests
96
+ File.delete(linked_file)
97
+ end
98
+ end
99
+
100
+ def assert_files(file_array)
101
+ file_array.each do |file|
102
+ assert File.exists? "#{@local_path}/#{file}"
103
+ end
104
+
105
+ # Need to reset in order for the files to not be deleted
106
+ Dir.chdir(@remote_path) do
107
+ `git reset --hard`
108
+ end
109
+
110
+ file_array.each do |file|
111
+ assert File.exists? "#{@remote_path}/#{file}"
112
+ end
6
113
  end
7
114
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitback
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 0
9
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Bryce Thornton
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-17 00:00:00 -04:00
18
+ date: 2010-05-20 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: grit
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 15
27
30
  segments:
28
31
  - 2
29
32
  - 0
@@ -31,6 +34,20 @@ dependencies:
31
34
  version: 2.0.0
32
35
  type: :runtime
33
36
  version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: shoulda
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
34
51
  description: Provide a list of files and/or directories and gitback will copy them to your git repo, commit and push when there are changes.
35
52
  email: brycethornton@gmail.com
36
53
  executables: []
@@ -47,9 +64,19 @@ files:
47
64
  - README.md
48
65
  - Rakefile
49
66
  - VERSION
67
+ - gitback.gemspec
50
68
  - lib/gitback.rb
51
69
  - lib/gitback/repository.rb
70
+ - test/data/another/file.txt
71
+ - test/data/another/test.txt
72
+ - test/data/some/deep/.bash_profile
73
+ - test/data/some/deep/directory/fstab
74
+ - test/data/some/deep/directory/test.conf
75
+ - test/data/some/deep/nginx.conf
76
+ - test/data/some/test_file.txt
77
+ - test/data/testing.txt
52
78
  - test/helper.rb
79
+ - test/repos/.gitignore
53
80
  - test/test_gitback.rb
54
81
  has_rdoc: true
55
82
  homepage: http://github.com/brycethornton/gitback
@@ -61,23 +88,27 @@ rdoc_options:
61
88
  require_paths:
62
89
  - lib
63
90
  required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
64
92
  requirements:
65
93
  - - ">="
66
94
  - !ruby/object:Gem::Version
95
+ hash: 3
67
96
  segments:
68
97
  - 0
69
98
  version: "0"
70
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
71
101
  requirements:
72
102
  - - ">="
73
103
  - !ruby/object:Gem::Version
104
+ hash: 3
74
105
  segments:
75
106
  - 0
76
107
  version: "0"
77
108
  requirements: []
78
109
 
79
110
  rubyforge_project:
80
- rubygems_version: 1.3.6
111
+ rubygems_version: 1.3.7
81
112
  signing_key:
82
113
  specification_version: 3
83
114
  summary: A simple ruby library for backing up files to git