rjgit_grack 0.1.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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -0
  3. data/LICENSE +22 -0
  4. data/README.md +54 -0
  5. data/lib/rjgit_adapter.rb +66 -0
  6. metadata +63 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49d6a227eeef56745e84391ebb01686e245124a1
4
+ data.tar.gz: 119da8866b2d3aed635524cfe0a1f321a26e05f2
5
+ SHA512:
6
+ metadata.gz: 8b26f717a15fff9b7a0b946c89615fbbef0a77bd445a5d53ac40c448831a4d5778706e92a56f8cab2710d175b405ae53a86ae9e9d05bddd622571bba7d4edc14
7
+ data.tar.gz: 24d74aaba597e60b12ab3d9da850fcd8794fb8ade24d482791c2815db5e7dc715e7d544441ded3473c367e850b5a3a88daf877f9a4d6314269c1712145e98fc1
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rjgit'
4
+ gem 'coveralls', require: false
5
+
6
+ group :test do
7
+ gem "test"
8
+ gem "mocha"
9
+ gem "rcov"
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2013 Dawa Ometto <d.ometto@gmail.com>
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ rjgit_grack
2
+ ===========
3
+
4
+ Alternative Adapter for [grack](http://github.com/schacon/grack); uses the [RJGit](http://github.com/repotag/rjgit) gem for a pure jruby interface to git repo's. Together with Grack, this yields a pure jruby implementation of git's smart-http protocol.
5
+
6
+ Installation
7
+ ===========
8
+
9
+ $ gem install rjgit_grack
10
+
11
+ Usage
12
+ ===========
13
+
14
+ 1. Get grack.
15
+ 2. After requiring rjgit_adapter.rb, you can tell Grack to use the RJGitAdapter by editing its configuration, like so:
16
+
17
+ ```ruby
18
+ config = {
19
+ :adapter => Grack::RJGitAdapter,
20
+ :upload_pack => true,
21
+ :receive_pack => true,
22
+ }
23
+ ```
24
+
25
+ Dependencies
26
+ ===========
27
+
28
+ - [Grack](http://github.com/schacon/grack)
29
+ - The [RJGit](http://github.com/repotag/rjgit) gem, which requires jruby
30
+
31
+ License
32
+ ========================
33
+ (The MIT License)
34
+
35
+ Copyright (c) 2013 Dawa Ometto <d.ometto@gmail.com>
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining
38
+ a copy of this software and associated documentation files (the
39
+ 'Software'), to deal in the Software without restriction, including
40
+ without limitation the rights to use, copy, modify, merge, publish,
41
+ distribute, sublicense, and/or sell copies of the Software, and to
42
+ permit persons to whom the Software is furnished to do so, subject to
43
+ the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be
46
+ included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
49
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
52
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
54
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ require "rjgit"
2
+
3
+ module Grack
4
+
5
+ class RJGitAdapter
6
+
7
+ def repo(repository_path)
8
+ RJGit::Repo.new(repository_path)
9
+ end
10
+
11
+ def service_command(cmd, repository_path, opts = {}, &block)
12
+ pack = case cmd
13
+ when :upload_pack
14
+ RJGit::RJGitUploadPack.new(repo repository_path)
15
+ when :receive_pack
16
+ RJGit::RJGitReceivePack.new(repo repository_path)
17
+ else
18
+ nil
19
+ end
20
+ return nil unless pack
21
+ if opts[:advertise_refs] then
22
+ return pack.advertise_refs
23
+ else
24
+ msg = opts.has_key?(:msg) ? opts[:msg] : ""
25
+ result, err = pack.process(msg)
26
+ if block_given? then
27
+ yield result
28
+ else
29
+ return result.read
30
+ end
31
+ end
32
+ end
33
+
34
+ def upload_pack(repository_path, opts = {}, &block)
35
+ self.service_command(:upload_pack, repository_path, opts, &block)
36
+ end
37
+
38
+ def receive_pack(repository_path, opts = {}, &block)
39
+ self.service_command(:receive_pack, repository_path, opts, &block)
40
+ end
41
+
42
+ def update_server_info(repository_path, opts = {}, &block)
43
+ repo(repository_path).update_server_info
44
+ end
45
+
46
+ def get_config_setting(repository_path, key)
47
+ repository = repo(repository_path)
48
+ domains = key.split(".")
49
+ begin
50
+ loop_settings = repository.config
51
+ rescue
52
+ return nil
53
+ end
54
+ domains.each do |domain|
55
+ begin
56
+ loop_settings = loop_settings[domain]
57
+ rescue
58
+ return nil
59
+ end
60
+ end
61
+ return loop_settings.is_a?(Hash) ? loop_settings : loop_settings.to_s
62
+ end
63
+
64
+ end
65
+
66
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rjgit_grack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dawa Ometto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rjgit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Alternative Adapter for grack; uses the RJGit gem for a pure jruby interface
28
+ to git repos. Together with Grack, this yields a pure jruby implementation of git's
29
+ smart-http protocol.
30
+ email: d.ometto@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - lib/rjgit_adapter.rb
36
+ - README.md
37
+ - LICENSE
38
+ - Gemfile
39
+ homepage: http://github.com/dometto/rjgit_grack
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.0.3
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Adapts grack (http://github.com/schacon/grack) to use JGit.
63
+ test_files: []