grit_service 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/LICENSE +20 -0
- data/README.md +7 -0
- data/Rakefile +19 -0
- data/bin/grit_service +19 -0
- data/grit_service.gemspec +29 -0
- data/lib/grit_service.rb +15 -0
- data/lib/grit_service/base.rb +31 -0
- data/lib/grit_service/config.erl +10 -0
- data/lib/grit_service/grit/git.rb +54 -0
- data/lib/grit_service/grit/repo.rb +17 -0
- data/lib/grit_service/service/git.rb +43 -0
- data/lib/grit_service/service/repo.rb +34 -0
- data/lib/grit_service/version.rb +3 -0
- data/spec/spec_helper.rb +11 -0
- metadata +147 -0
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@gems
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bbcoder (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rr (1.0.4)
|
11
|
+
rspec (2.9.0)
|
12
|
+
rspec-core (~> 2.9.0)
|
13
|
+
rspec-expectations (~> 2.9.0)
|
14
|
+
rspec-mocks (~> 2.9.0)
|
15
|
+
rspec-core (2.9.0)
|
16
|
+
rspec-expectations (2.9.1)
|
17
|
+
diff-lcs (~> 1.1.3)
|
18
|
+
rspec-mocks (2.9.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bbcoder!
|
25
|
+
rr
|
26
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 John "asceth" Long
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
|
7
|
+
Rspec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
gemspec = eval(File.read(File.join(Dir.pwd, "bbcoder.gemspec")))
|
10
|
+
|
11
|
+
task :build => "#{gemspec.full_name}.gem"
|
12
|
+
|
13
|
+
task :test => :spec
|
14
|
+
|
15
|
+
file "#{gemspec.full_name}.gem" => gemspec.files + ["bbcoder.gemspec"] do
|
16
|
+
system "gem build bbcoder.gemspec"
|
17
|
+
system "gem install bbcoder-#{BBCoder::VERSION}.gem"
|
18
|
+
end
|
19
|
+
|
data/bin/grit_service
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), *%w[.. lib]))
|
4
|
+
GRIT_SERVICE_ROOT = File.join(File.expand_path(File.dirname(__FILE__)), *%w[..])
|
5
|
+
|
6
|
+
File.open('/tmp/grit_service', 'w+') do |f|
|
7
|
+
original = File.read("#{GRIT_SERVICE_ROOT}/lib/grit_service/config.erl")
|
8
|
+
|
9
|
+
with_paths = original.
|
10
|
+
gsub('GRIT_SERVICE_GIT_PATH',
|
11
|
+
"#{GRIT_SERVICE_ROOT}/lib/grit_service/service/git.rb").
|
12
|
+
gsub('GRIT_SERVICE_REPO_PATH',
|
13
|
+
"#{GRIT_SERVICE_ROOT}/lib/grit_service/service/repo.rb")
|
14
|
+
|
15
|
+
|
16
|
+
f.write(with_paths)
|
17
|
+
end
|
18
|
+
|
19
|
+
exec("ernie #{ARGV[0..-1].join(' ')} -c /tmp/grit_service")
|
@@ -0,0 +1,29 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "grit_service/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "grit_service"
|
6
|
+
s.version = GritService::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["John 'asceth' Long"]
|
9
|
+
s.email = ["machinist@asceth.com"]
|
10
|
+
s.homepage = "http://github.com/asceth/grit_service"
|
11
|
+
s.summary = "Ernie's got Grit"
|
12
|
+
s.description = "Turns Grit into an Ernie service"
|
13
|
+
|
14
|
+
s.rubyforge_project = "grit_service"
|
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.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'grit'
|
22
|
+
s.add_dependency 'bert'
|
23
|
+
s.add_dependency 'bertrpc'
|
24
|
+
|
25
|
+
|
26
|
+
s.add_development_dependency 'rspec'
|
27
|
+
s.add_development_dependency 'rr'
|
28
|
+
end
|
29
|
+
|
data/lib/grit_service.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# require grit before so our overrides work as expected
|
2
|
+
require 'grit'
|
3
|
+
|
4
|
+
# Hi Bert!
|
5
|
+
require 'bertrpc'
|
6
|
+
|
7
|
+
# GritService
|
8
|
+
require 'grit_service/base'
|
9
|
+
require 'grit_service/version'
|
10
|
+
|
11
|
+
# Grit overrides
|
12
|
+
require 'grit_service/grit/git'
|
13
|
+
require 'grit_service/grit/repo'
|
14
|
+
|
15
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module GritService
|
4
|
+
def self.git(git_dir)
|
5
|
+
@gits ||= {}
|
6
|
+
@gits[git_dir] ||= Grit::Git.new(git_dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.log
|
10
|
+
@logger ||= Logger.new('/tmp/grit_service.log')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.bertrpc(host = 'localhost', port = 9999)
|
14
|
+
@bertrpc ||= BERTRPC::Service.new(host, port)
|
15
|
+
end
|
16
|
+
|
17
|
+
module Helpers
|
18
|
+
def service(method)
|
19
|
+
define_method(method) do |git_dir, *args|
|
20
|
+
GritService.log.debug("#{GritService.git(git_dir)}: #{method}(#{args.inspect})")
|
21
|
+
begin
|
22
|
+
GritService.git(git_dir).send(method, *args)
|
23
|
+
rescue Exception => e
|
24
|
+
GritService.log.error(e.to_s)
|
25
|
+
e.backtrace.each {|line| GritService.log.error(line)}
|
26
|
+
raise e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Grit
|
2
|
+
class Git
|
3
|
+
def self.service(method)
|
4
|
+
define_method(method) do |*args|
|
5
|
+
GritService.bertrpc.call.git.send(method, *([self.git_dir, args].flatten))
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
service :exist?
|
10
|
+
service :put_raw_object
|
11
|
+
service :get_raw_object
|
12
|
+
service :get_git_object
|
13
|
+
service :object_exists?
|
14
|
+
service :select_existing_objects
|
15
|
+
service :fs_exist?
|
16
|
+
service :fs_read
|
17
|
+
service :fs_write
|
18
|
+
service :fs_delete
|
19
|
+
service :fs_move
|
20
|
+
service :fs_mkdir
|
21
|
+
service :fs_chmod
|
22
|
+
service :list_remotes
|
23
|
+
service :create_tempfile
|
24
|
+
service :commit_from_sha
|
25
|
+
service :check_applies
|
26
|
+
service :get_patch
|
27
|
+
service :apply_patch
|
28
|
+
|
29
|
+
# we need to undef all of the GitRuby methods so native sends them on
|
30
|
+
undef :init
|
31
|
+
undef :cat_file
|
32
|
+
undef :cat_ref
|
33
|
+
undef :ls_tree
|
34
|
+
undef :diff
|
35
|
+
undef :rev_list
|
36
|
+
undef :rev_parse
|
37
|
+
undef :refs
|
38
|
+
undef :tags
|
39
|
+
undef :file_size
|
40
|
+
undef :file_type
|
41
|
+
undef :blame_tree
|
42
|
+
|
43
|
+
# override native to send rpc
|
44
|
+
def native(cmd, options = {}, *args, &block)
|
45
|
+
GritService.bertrpc.call.git.native(self.git_dir, cmd, options, *args)
|
46
|
+
end
|
47
|
+
|
48
|
+
# not sure why I need to do this but doing it on console
|
49
|
+
# commands returned correct results...
|
50
|
+
def method_missing(cmd, options = {}, *args, &block)
|
51
|
+
native(cmd, options, *args)
|
52
|
+
end
|
53
|
+
end # Git
|
54
|
+
end # Grit
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Grit
|
2
|
+
class Repo
|
3
|
+
def self.initialize_repo(path, options)
|
4
|
+
GritService.bertrpc.call.repo.initialize_repo(path, options)
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(path, options = {})
|
8
|
+
repo_options = self.class.initialize_repo(path, options)
|
9
|
+
|
10
|
+
@bare = repo_options[:bare]
|
11
|
+
self.path = repo_options[:path]
|
12
|
+
self.working_dir = repo_options[:working_dir]
|
13
|
+
|
14
|
+
self.git = Git.new(self.path)
|
15
|
+
end
|
16
|
+
end # Repo
|
17
|
+
end # Grit
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ernie'
|
3
|
+
require 'grit'
|
4
|
+
require 'grit_service/base'
|
5
|
+
|
6
|
+
module GritService
|
7
|
+
module Service
|
8
|
+
module Git
|
9
|
+
extend GritService::Helpers
|
10
|
+
|
11
|
+
service :exist?
|
12
|
+
service :put_raw_object
|
13
|
+
service :get_raw_object
|
14
|
+
service :get_git_object
|
15
|
+
service :object_exists?
|
16
|
+
service :select_existing_objects
|
17
|
+
service :fs_exist?
|
18
|
+
service :fs_read
|
19
|
+
service :fs_write
|
20
|
+
service :fs_delete
|
21
|
+
service :fs_move
|
22
|
+
service :fs_mkdir
|
23
|
+
service :fs_chmod
|
24
|
+
service :list_remotes
|
25
|
+
service :create_tempfile
|
26
|
+
service :commit_from_sha
|
27
|
+
service :check_applies
|
28
|
+
service :get_patch
|
29
|
+
service :apply_patch
|
30
|
+
|
31
|
+
def native(git_dir, cmd, *args)
|
32
|
+
GritService.log.debug("#{GritService.git(git_dir)}: #{cmd}(#{args.inspect})")
|
33
|
+
GritService.git(git_dir).send(cmd, *args)
|
34
|
+
rescue Exception => e
|
35
|
+
GritService.log.error(e.to_s)
|
36
|
+
e.backtrace.each {|line| GritService.log.error(line)}
|
37
|
+
raise e
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Ernie.expose(:git, GritService::Service::Git)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ernie'
|
3
|
+
require 'grit'
|
4
|
+
require 'grit_service/base'
|
5
|
+
|
6
|
+
module GritService
|
7
|
+
module Service
|
8
|
+
module Repo
|
9
|
+
extend GritService::Helpers
|
10
|
+
|
11
|
+
def initialize_repo(path, options)
|
12
|
+
repo_options = {}
|
13
|
+
epath = File.expand_path(path)
|
14
|
+
|
15
|
+
if File.exist?(File.join(epath, '.git'))
|
16
|
+
repo_options[:working_dir] = epath
|
17
|
+
repo_options[:path] = File.join(epath, '.git')
|
18
|
+
repo_options[:bare] = false
|
19
|
+
elsif File.exist?(epath) && (epath =~ /\.git$/ || options[:is_bare])
|
20
|
+
repo_options[:path] = epath
|
21
|
+
repo_options[:bare] = true
|
22
|
+
elsif File.exist?(epath)
|
23
|
+
raise Grit::InvalidGitRepositoryError.new(epath)
|
24
|
+
else
|
25
|
+
raise Grit::NoSuchPathError.new(epath)
|
26
|
+
end
|
27
|
+
|
28
|
+
repo_options
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Ernie.expose(:repo, GritService::Service::Repo)
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grit_service
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John 'asceth' Long
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: grit
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bert
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bertrpc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rr
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Turns Grit into an Ernie service
|
95
|
+
email:
|
96
|
+
- machinist@asceth.com
|
97
|
+
executables:
|
98
|
+
- grit_service
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- .gemtest
|
103
|
+
- .gitignore
|
104
|
+
- .rspec
|
105
|
+
- .rvmrc
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- LICENSE
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/grit_service
|
112
|
+
- grit_service.gemspec
|
113
|
+
- lib/grit_service.rb
|
114
|
+
- lib/grit_service/base.rb
|
115
|
+
- lib/grit_service/config.erl
|
116
|
+
- lib/grit_service/grit/git.rb
|
117
|
+
- lib/grit_service/grit/repo.rb
|
118
|
+
- lib/grit_service/service/git.rb
|
119
|
+
- lib/grit_service/service/repo.rb
|
120
|
+
- lib/grit_service/version.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
homepage: http://github.com/asceth/grit_service
|
123
|
+
licenses: []
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project: grit_service
|
142
|
+
rubygems_version: 1.8.21
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: Ernie's got Grit
|
146
|
+
test_files:
|
147
|
+
- spec/spec_helper.rb
|