rjgit_grack 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +16 -9
  4. data/lib/rjgit_grack.rb +28 -38
  5. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c120bee899ad48c317673385f483c4bf782f4462
4
- data.tar.gz: b3a4605897c893252bede1547f0a27b4d2d88bc7
3
+ metadata.gz: 84344229b7966b8960708f9ca83b982ec60de07c
4
+ data.tar.gz: ddb642960dc5175ac9de200260beec3a00f63bf2
5
5
  SHA512:
6
- metadata.gz: 86a8ec1ada212e5b94d9507ac5c4f7fd7f2f4677593492fc8dc6998cd0c90dadad8c3b91b5b53f0fdab3f4d862c4bdac6270c7cb63b1a873315d50ff9fefb6c9
7
- data.tar.gz: 776bc8fda334167d6b84f497c49134a7fe0727bbddceb4ba0e436c5cf952972a28b201afd3bdda7ed90f13d3f5e8fb730cf21b51d8a65f3e436e664b7d9beb44
6
+ metadata.gz: 4f7f0d798f28ec5cfb730ec7b5f694d2c692a43e8e18a1c1f595b472122a2aa527fa374faaa96e813e0b26e93a7fb8d3390b7385865055844e5b38eca839ec09
7
+ data.tar.gz: 4565154688cea2e309af64fbbe89f30b5394ab84d908150ac38c1bc7c71b60224f29827d578afb9fd4ebbf3ca6bacc6583786489ad4549255f8b2b4b43f7c90c
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem 'coveralls', require: false
6
6
  group :test do
7
7
  gem "test"
8
8
  gem "mocha"
9
+ gem "grack", :git => 'https://github.com/grackorg/grack'
9
10
  gem "simplecov", :require => false
10
11
  end
11
12
 
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  rjgit_grack
2
2
  ===========
3
3
  [![Gem Version](https://badge.fury.io/rb/rjgit_grack.svg)](http://badge.fury.io/rb/rjgit_grack)
4
- [![Build Status](https://travis-ci.org/dometto/rjgit_grack.svg?branch=master)](https://travis-ci.org/dometto/rjgit_grack)
5
- [![Dependency Status](https://gemnasium.com/dometto/rjgit_grack.svg)](https://gemnasium.com/dometto/rjgit_grack)
4
+ [![Build Status](https://travis-ci.org/dometto/rjgit_grack.svg?branch=master)](https://travis-ci.org/grackorg/rjgit_grack)
5
+ [![Dependency Status](https://gemnasium.com/dometto/rjgit_grack.svg)](https://gemnasium.com/grackorg/rjgit_grack)
6
6
 
7
- 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 repos. Together with Grack, this yields a pure jruby implementation of git's smart-http protocol.
7
+ Alternative Adapter for [grack](http://github.com/grackorg/grack); uses the [RJGit](http://github.com/repotag/rjgit) gem for a pure jruby interface to git repos. Together with Grack, this yields a pure jruby implementation of git's smart-http protocol.
8
8
 
9
9
  Installation
10
10
  ===========
@@ -15,14 +15,21 @@ Usage
15
15
  ===========
16
16
 
17
17
  1. Get grack.
18
- 2. After requiring `rjgit_grack.rb`, you can tell Grack to use the `RJGitAdapter` by editing its configuration, like so:
18
+ 2. After requiring `rjgit_grack.rb`, you can tell Grack to use the `RJGitAdapter` by editing its configuration, for example:
19
19
 
20
20
  ```ruby
21
+ require 'grack/app'
22
+ require 'grack/git_adapter'
23
+ require 'rjgit_grack'
24
+
21
25
  config = {
22
- :adapter => Grack::RJGitAdapter,
23
- :upload_pack => true,
24
- :receive_pack => true,
26
+ :root => '/path/to/bare/repositories',
27
+ :allow_push => true,
28
+ :allow_pull => true,
29
+ :git_adapter_factory => ->{ Grack::RJGitAdapter.new }
25
30
  }
31
+
32
+ run Grack::App.new(config)
26
33
  ```
27
34
 
28
35
  Specs
@@ -35,8 +42,8 @@ Run the specs:
35
42
  Dependencies
36
43
  ===========
37
44
 
38
- - [Grack](http://github.com/schacon/grack)
39
- - The [RJGit](http://github.com/repotag/rjgit) gem, which requires jruby
45
+ - [Grack](http://github.com/grackorg/grack) >= 0.1.0.pre
46
+ - The [RJGit](http://github.com/repotag/rjgit) gem, which requires JRuby
40
47
 
41
48
  License
42
49
  ========================
data/lib/rjgit_grack.rb CHANGED
@@ -2,63 +2,53 @@ require "rjgit"
2
2
 
3
3
  module Grack
4
4
 
5
- class RJGitAdapter
5
+ class RJGitAdapter < GitAdapter
6
6
 
7
- def repo(repository_path)
8
- RJGit::Repo.new(repository_path)
7
+ def initialize
8
+ @repository_path = nil
9
9
  end
10
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
11
+ def handle_pack(pack_type, io_in, io_out, opts = {})
12
+ pack = case pack_type
13
+ when 'git-upload-pack'
14
+ RJGit::RJGitUploadPack.new(repo)
15
+ when 'git-receive-pack'
16
+ RJGit::RJGitReceivePack.new(repo)
19
17
  end
20
18
  return nil unless pack
21
19
  if opts[:advertise_refs] then
22
- return pack.advertise_refs
20
+ io_out.write advertisement_prefix(pack_type)
21
+ result = pack.advertise_refs
23
22
  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)
23
+ result = pack.process(io_in.read).first.read
24
+ end
25
+ io_out.write(result)
40
26
  end
41
-
42
- def update_server_info(repository_path, opts = {}, &block)
43
- repo(repository_path).update_server_info
27
+
28
+ def update_server_info
29
+ repo.update_server_info
44
30
  end
45
31
 
46
- def get_config_setting(repository_path, key)
47
- repository = repo(repository_path)
48
- domains = key.split(".")
32
+ def config(key)
49
33
  begin
50
- loop_settings = repository.config
34
+ settings = repo.config
51
35
  rescue
52
36
  return nil
53
37
  end
54
- domains.each do |domain|
38
+ key.split(".").each do |domain|
55
39
  begin
56
- loop_settings = loop_settings[domain]
40
+ settings = settings[domain]
57
41
  rescue
58
42
  return nil
59
43
  end
60
44
  end
61
- return loop_settings.is_a?(Hash) ? loop_settings : loop_settings.to_s
45
+ settings.is_a?(Hash) ? settings : settings.to_s
46
+ end
47
+
48
+ private
49
+
50
+ def repo
51
+ RJGit::Repo.new(repository_path)
62
52
  end
63
53
 
64
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjgit_grack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dawa Ometto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-02 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rjgit
@@ -16,15 +16,15 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '4.0'
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: '0.3'
24
+ version: '4.0'
25
25
  prerelease: false
26
26
  type: :runtime
27
- description: Alternative Adapter for grack; uses the RJGit gem for a pure jruby interface to git repos. Together with Grack, this yields a pure jruby implementation of git's smart-http protocol.
27
+ description: Alternative Adapter for grack; uses the RJGit gem for a pure jruby interface to git repos. Together with Grack, this yields a pure JRuby implementation of git's smart-http protocol.
28
28
  email: d.ometto@gmail.com
29
29
  executables: []
30
30
  extensions: []
@@ -34,7 +34,7 @@ files:
34
34
  - LICENSE
35
35
  - README.md
36
36
  - lib/rjgit_grack.rb
37
- homepage: http://github.com/dometto/rjgit_grack
37
+ homepage: http://github.com/grackorg/rjgit_grack
38
38
  licenses:
39
39
  - MIT
40
40
  metadata: {}
@@ -57,5 +57,5 @@ rubyforge_project:
57
57
  rubygems_version: 2.4.5
58
58
  signing_key:
59
59
  specification_version: 4
60
- summary: Adapts grack (http://github.com/schacon/grack) to use JGit.
60
+ summary: Adapts grack (http://github.com/grackorg/grack) to use JGit.
61
61
  test_files: []