Git_Repo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Git_Repo.gemspec +26 -0
- data/Rakefile +1 -0
- data/lib/Git_Repo.rb +74 -0
- data/lib/Git_Repo/version.rb +3 -0
- data/spec/helper.rb +15 -0
- data/spec/main.rb +8 -0
- data/spec/tests/new.rb +8 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Git_Repo.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "Git_Repo/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "Git_Repo"
|
7
|
+
s.version = Git_Repo::VERSION
|
8
|
+
s.authors = ["da99"]
|
9
|
+
s.email = ["i-hate-spam-45671204@mailinator.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Helpers to manipulate Git Repos}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "Git_Repo"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.add_development_dependency 'bacon'
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# s.add_development_dependency "rspec"
|
25
|
+
# s.add_runtime_dependency "rest-client"
|
26
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/Git_Repo.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "Git_Repo/version"
|
2
|
+
|
3
|
+
|
4
|
+
class Git_Repo
|
5
|
+
|
6
|
+
Failed_Shell_Command = Class.new(RuntimeError)
|
7
|
+
|
8
|
+
module Base
|
9
|
+
|
10
|
+
attr_reader :address
|
11
|
+
def initialize dir
|
12
|
+
@address = File.expand_path(dir)
|
13
|
+
end
|
14
|
+
|
15
|
+
def init
|
16
|
+
shell "git init"
|
17
|
+
end
|
18
|
+
|
19
|
+
def add str
|
20
|
+
shell "git add #{str}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
add '.'
|
25
|
+
add '-u'
|
26
|
+
end
|
27
|
+
|
28
|
+
def tag str
|
29
|
+
shell "git tag #{str}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def reset
|
33
|
+
shell "git reset"
|
34
|
+
end
|
35
|
+
|
36
|
+
def commit msg
|
37
|
+
shell "git commit -m \"#{msg.gsub(%r!\r|\n!, ' ').gsub('"', "'")}\""
|
38
|
+
end
|
39
|
+
|
40
|
+
def status
|
41
|
+
shell "git status"
|
42
|
+
end
|
43
|
+
|
44
|
+
def nothing_to_commit?
|
45
|
+
!!( status['nothing to commit (working directory clean)'] )
|
46
|
+
end
|
47
|
+
|
48
|
+
def commit_pending?
|
49
|
+
!nothing_to_commit?
|
50
|
+
end
|
51
|
+
|
52
|
+
def staged?
|
53
|
+
commit_pending?
|
54
|
+
end
|
55
|
+
|
56
|
+
def bundle_update
|
57
|
+
shell "bundle update"
|
58
|
+
end
|
59
|
+
|
60
|
+
def shell cmd
|
61
|
+
val = `cd #{address} && #{cmd} 2>&1`.to_s.strip
|
62
|
+
puts cmd
|
63
|
+
if $?.exitstatus != 0
|
64
|
+
raise Failed_Shell_Command, "Results:\n#{val}"
|
65
|
+
end
|
66
|
+
puts val
|
67
|
+
val
|
68
|
+
end
|
69
|
+
|
70
|
+
end # === module Base
|
71
|
+
|
72
|
+
include Base
|
73
|
+
|
74
|
+
end # === class Git_Repo
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'bacon'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
|
15
|
+
Bacon.summary_on_exit
|
data/spec/main.rb
ADDED
data/spec/tests/new.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Git_Repo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- da99
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-08 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bacon
|
16
|
+
requirement: &7163800 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *7163800
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &7121840 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *7121840
|
36
|
+
description: Helpers to manipulate Git Repos
|
37
|
+
email:
|
38
|
+
- i-hate-spam-45671204@mailinator.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- Git_Repo.gemspec
|
46
|
+
- Rakefile
|
47
|
+
- lib/Git_Repo.rb
|
48
|
+
- lib/Git_Repo/version.rb
|
49
|
+
- spec/helper.rb
|
50
|
+
- spec/main.rb
|
51
|
+
- spec/tests/new.rb
|
52
|
+
homepage: ''
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project: Git_Repo
|
72
|
+
rubygems_version: 1.8.11
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Helpers to manipulate Git Repos
|
76
|
+
test_files: []
|