rom-git 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -2
- data/LICENSE.txt +1 -1
- data/README.md +23 -89
- data/Rakefile +3 -103
- data/lib/rom-git.rb +1 -1
- data/lib/rom/git.rb +1 -1
- data/lib/rom/git/dataset.rb +5 -13
- data/lib/rom/git/gateway.rb +20 -17
- data/lib/rom/git/relation.rb +5 -0
- data/lib/rom/git/version.rb +5 -0
- data/rom-git.gemspec +10 -12
- data/{test → spec}/fixtures/HEAD +0 -0
- data/{test → spec}/fixtures/logs/HEAD +0 -0
- data/spec/fixtures/logs/refs/heads/feature +0 -0
- data/{test → spec}/fixtures/logs/refs/heads/master +0 -0
- data/{test → spec}/fixtures/objects/0a/0d213d2bcc5d5fb3a39c134d253d160b7c14c4 +0 -0
- data/{test → spec}/fixtures/objects/10/1868c4ce62b7e96a1f7c3b64fa40285ee00d5e +0 -0
- data/{test → spec}/fixtures/objects/20/5f6b799e7d5c2524468ca006a0131aa57ecce7 +0 -0
- data/{test → spec}/fixtures/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 +0 -0
- data/{test → spec}/fixtures/objects/49/b6dbdb939f0d9494d40f210bbaeb54d6a15c35 +0 -0
- data/{test → spec}/fixtures/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
- data/{test → spec}/fixtures/objects/6f/331f786e8c5ca8ffb67d1dfd3b1e1942167e3e +0 -0
- data/{test → spec}/fixtures/objects/89/ff1a2aefcbff0f09197f0fd8beeb19a7b6e51c +0 -0
- data/{test → spec}/fixtures/objects/e7/d5223c10643012af885505e2fc7950f81214b6 +0 -0
- data/{test → spec}/fixtures/objects/f0/184ad83045ea3a7e32fb547d5275f21686558d +0 -0
- data/{test → spec}/fixtures/objects/fe/326fd5cb986e6ef3d83f02857fb5bc10333aa4 +0 -0
- data/{test/fixtures/refs/heads/master → spec/fixtures/refs/heads/feature} +0 -0
- data/spec/fixtures/refs/heads/master +1 -0
- data/spec/integration/gateway_spec.rb +71 -0
- data/spec/spec_helper.rb +17 -0
- metadata +37 -93
- data/test/integration/gateway_test.rb +0 -58
- data/test/integration/relation_test.rb +0 -31
- data/test/test_helper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc7c7847111033dcda9033ead9ae4d8c9181ed41
|
4
|
+
data.tar.gz: 60278f7a76878300cced492b235021a591a51ccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc659a12eab3caf1e9d79994313ee7292965d6bea104fe8aa2bd719858e2b5e0a6e25c36187dcb2823130d825d3b7fc322a1f26429bc5c2794f4e40435cf06c
|
7
|
+
data.tar.gz: 8254494552c97aec04ed92b82751a447713faad2f114eabc832fb28e77527b358f985b249ef315d280ec96c174ecda230f5c7b741394befc1aca4834ca3d8dc9
|
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -1,4 +1,21 @@
|
|
1
1
|
language: ruby
|
2
|
+
bundler_args: --without tools
|
3
|
+
script: "bundle exec rake spec"
|
2
4
|
rvm:
|
5
|
+
- 2.0
|
3
6
|
- 2.1
|
7
|
+
- 2.2
|
8
|
+
- rbx-2
|
9
|
+
- jruby-9.0.5.0
|
4
10
|
- ruby-head
|
11
|
+
matrix:
|
12
|
+
allow_failures:
|
13
|
+
- rvm: ruby-head
|
14
|
+
- rvm: jruby-9.0.5.0
|
15
|
+
notifications:
|
16
|
+
webhooks:
|
17
|
+
urls:
|
18
|
+
- https://webhooks.gitter.im/e/39e1225f489f38b0bd09
|
19
|
+
on_success: change
|
20
|
+
on_failure: always
|
21
|
+
on_start: false
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,106 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
[gem]: https://rubygems.org/gems/rom-git
|
2
|
+
[travis]: https://travis-ci.org/rom-rb/rom-git
|
3
|
+
[gemnasium]: https://gemnasium.com/rom-rb/rom-git
|
4
|
+
[codeclimate]: https://codeclimate.com/github/rom-rb/rom-git
|
5
|
+
[inchpages]: http://inch-ci.org/github/rom-rb/rom-git
|
4
6
|
|
7
|
+
# rom-git
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
And then execute:
|
13
|
-
|
14
|
-
$ bundle
|
15
|
-
|
16
|
-
Or install it yourself as:
|
17
|
-
|
18
|
-
$ gem install rom-git
|
19
|
-
|
20
|
-
Alternatively, you can spawn a `pry` console right away by just running:
|
21
|
-
|
22
|
-
$ rake console
|
23
|
-
|
24
|
-
|
25
|
-
## Usage
|
26
|
-
|
27
|
-
### Set up the adapter, relation and mapper
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
setup = ROM.setup("git://path/to_some_git_repo", branch: 'refs/heads/master')
|
31
|
-
|
32
|
-
setup.schema do
|
33
|
-
base_relation(:commits) do
|
34
|
-
repository :default
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/rom-git.svg)][gem]
|
10
|
+
[![Build Status](https://travis-ci.org/rom-rb/rom-git.svg?branch=master)][travis]
|
11
|
+
[![Dependency Status](https://gemnasium.com/rom-rb/rom-git.svg)][gemnasium]
|
12
|
+
[![Code Climate](https://codeclimate.com/github/rom-rb/rom-git/badges/gpa.svg)][codeclimate]
|
13
|
+
[![Test Coverage](https://codeclimate.com/github/rom-rb/rom-git/badges/coverage.svg)][codeclimate]
|
14
|
+
[![Inline docs](http://inch-ci.org/github/rom-rb/rom-git.svg?branch=master)][inchpages]
|
35
15
|
|
36
|
-
attribute "sha1"
|
37
|
-
attribute "message"
|
38
|
-
attribute "committer"
|
39
|
-
end
|
40
|
-
end
|
41
16
|
|
42
|
-
|
43
|
-
def by_committer(committer_name)
|
44
|
-
find_all { |row| row[:committer] == committer_name }
|
45
|
-
end
|
17
|
+
Git adapter for [Ruby Object Mapper](https://github.com/rom-rb/rom).
|
46
18
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
setup.mappers do
|
54
|
-
define(:commits) do
|
55
|
-
model (Class.new do
|
56
|
-
include Anima.new(:sha1, :message, :committer)
|
57
|
-
end)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
setup
|
61
|
-
end
|
62
|
-
|
63
|
-
rom = setup.finalize
|
64
|
-
```
|
65
|
-
|
66
|
-
### Find commits by committer
|
67
|
-
|
68
|
-
```ruby
|
69
|
-
commit = rom.read(:commits).by_committer('Franck Verrot').to_a.first
|
70
|
-
|
71
|
-
commit.sha1 # => '101868c4ce62b7e96a1f7c3b64fa40285ee00d5e'
|
72
|
-
commit.message # => 'commit (initial): Initial commit'
|
73
|
-
commit.committer # => 'Franck Verrot'
|
74
|
-
```
|
19
|
+
* [API docs](http://rubydoc.info/gems/rom-git)
|
20
|
+
* [ROM user docs](http://rom-rb.org/learn)
|
75
21
|
|
22
|
+
## Installation
|
76
23
|
|
77
|
-
|
24
|
+
Add this line to your application's Gemfile:
|
78
25
|
|
79
26
|
```ruby
|
80
|
-
rom
|
27
|
+
gem 'rom-git'
|
81
28
|
```
|
82
29
|
|
30
|
+
And then execute:
|
83
31
|
|
84
|
-
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
sha1 = 'fe326fd5cb986e6ef3d83f02857fb5bc10333aa4'
|
88
|
-
commit = subject.read(:commits).find_commit(sha1).to_a.first
|
89
|
-
|
90
|
-
commit.sha1 # => sha1
|
91
|
-
commit.message # => 'commit: Add bar'
|
92
|
-
commit.committer # => 'Franck Verrot'
|
93
|
-
```
|
32
|
+
$ bundle
|
94
33
|
|
95
|
-
|
34
|
+
Or install it yourself as:
|
96
35
|
|
97
|
-
|
98
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
99
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
100
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
101
|
-
5. Create new Pull Request
|
36
|
+
$ gem install rom-git
|
102
37
|
|
103
38
|
## License
|
104
39
|
|
105
|
-
|
106
|
-
See LICENSE.txt for details.
|
40
|
+
See `LICENSE` file.
|
data/Rakefile
CHANGED
@@ -1,104 +1,4 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2015 Franck Verrot <franck@verrot.fr>
|
1
|
+
require 'rspec/core/rake_task'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
|
17
|
-
require 'rubygems'
|
18
|
-
require 'rubygems/specification'
|
19
|
-
|
20
|
-
require 'bundler'
|
21
|
-
Bundler::GemHelper.install_tasks
|
22
|
-
|
23
|
-
$:<< 'lib'
|
24
|
-
require 'rom-git'
|
25
|
-
|
26
|
-
$stdout.puts """
|
27
|
-
rom-git - Copyright (C) 2015 Franck Verrot <franck@verrot.fr>
|
28
|
-
This program comes with ABSOLUTELY NO WARRANTY; for details type `rake license'.
|
29
|
-
This is free software, and you are welcome to redistribute it
|
30
|
-
under certain conditions; type `rake license' for details.
|
31
|
-
|
32
|
-
"""
|
33
|
-
|
34
|
-
require 'rake/testtask'
|
35
|
-
Rake::TestTask.new do |t|
|
36
|
-
t.libs << "test"
|
37
|
-
t.pattern = "test/**/*_test.rb"
|
38
|
-
#t.verbose = true
|
39
|
-
#t.warning = true
|
40
|
-
end
|
41
|
-
|
42
|
-
Rake::TestTask.new(:unit_tests) do |t|
|
43
|
-
t.libs << "test"
|
44
|
-
t.pattern = "test/unit/**/*_test.rb"
|
45
|
-
#t.verbose = true
|
46
|
-
#t.warning = true
|
47
|
-
end
|
48
|
-
|
49
|
-
Rake::TestTask.new(:integration_tests) do |t|
|
50
|
-
t.libs << "test"
|
51
|
-
t.pattern = "test/integration/**/*_test.rb"
|
52
|
-
#t.verbose = true
|
53
|
-
#t.warning = true
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def gemspec
|
58
|
-
@gemspec ||= begin
|
59
|
-
file = File.expand_path('../rom-git.gemspec', __FILE__)
|
60
|
-
eval(File.read(file), binding, file)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
desc "Clean the current directory"
|
65
|
-
task :clean do
|
66
|
-
rm_rf 'tmp'
|
67
|
-
rm_rf 'pkg'
|
68
|
-
end
|
69
|
-
|
70
|
-
desc "Run the full spec suite"
|
71
|
-
task :full => ["clean", "test"]
|
72
|
-
|
73
|
-
desc "install the gem locally"
|
74
|
-
task :install => :package do
|
75
|
-
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
76
|
-
end
|
77
|
-
|
78
|
-
desc "validate the gemspec"
|
79
|
-
task :gemspec do
|
80
|
-
gemspec.validate
|
81
|
-
end
|
82
|
-
|
83
|
-
desc "Build the gem"
|
84
|
-
task :gem => [:gemspec, :build] do
|
85
|
-
mkdir_p "pkg"
|
86
|
-
sh "gem build rom-git.gemspec"
|
87
|
-
mv "#{gemspec.full_name}.gem", "pkg"
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "Install rom-git"
|
91
|
-
task :install => :gem do
|
92
|
-
sh "gem install pkg/#{gemspec.full_name}.gem"
|
93
|
-
end
|
94
|
-
|
95
|
-
task :default => :full
|
96
|
-
|
97
|
-
task :license do
|
98
|
-
`open http://www.gnu.org/licenses/gpl.txt`
|
99
|
-
end
|
100
|
-
|
101
|
-
task :console do
|
102
|
-
require 'pry'
|
103
|
-
Pry.start
|
104
|
-
end
|
3
|
+
RSpec::Core::RakeTask.new(:spec)
|
4
|
+
task default: :spec
|
data/lib/rom-git.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'rom/git'
|
data/lib/rom/git.rb
CHANGED
data/lib/rom/git/dataset.rb
CHANGED
@@ -3,27 +3,19 @@ require 'rom/memory/dataset'
|
|
3
3
|
module ROM
|
4
4
|
module Git
|
5
5
|
class Dataset < ROM::Memory::Dataset
|
6
|
-
option :path, reader: true
|
7
|
-
option :options, reader: true
|
8
|
-
option :gateway, reader: true
|
9
|
-
|
10
6
|
def self.row_proc
|
11
7
|
lambda do |row|
|
12
8
|
{
|
13
9
|
sha1: row[:id_new] || row[:sha1],
|
14
10
|
message: row[:message],
|
15
|
-
committer: (
|
11
|
+
committer: (begin
|
12
|
+
row[:committer].fetch(:name, 'unknown committer name')
|
13
|
+
rescue
|
14
|
+
row[:committer].to_s
|
15
|
+
end)
|
16
16
|
}
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
20
|
-
def reload!
|
21
|
-
@data = gateway.reset_data
|
22
|
-
end
|
23
|
-
|
24
|
-
def count
|
25
|
-
@data.count
|
26
|
-
end
|
27
19
|
end
|
28
20
|
end
|
29
21
|
end
|
data/lib/rom/git/gateway.rb
CHANGED
@@ -1,36 +1,39 @@
|
|
1
|
+
require 'rom/support/options'
|
2
|
+
require 'rom/support/constants'
|
3
|
+
|
1
4
|
require 'rom/gateway'
|
2
5
|
require 'rom/git/dataset'
|
3
6
|
|
4
7
|
module ROM
|
5
8
|
module Git
|
6
9
|
class Gateway < ROM::Gateway
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
DEFAULT_BRANCH = 'refs/heads/master'.freeze
|
11
|
+
include Options
|
12
|
+
|
13
|
+
option :path, accept: String, reader: true
|
14
|
+
|
15
|
+
option :branch, accept: String, reader: true, default: DEFAULT_BRANCH
|
16
|
+
|
17
|
+
attr_reader :datasets
|
18
|
+
|
19
|
+
attr_reader :repo
|
20
|
+
|
21
|
+
def initialize(path, options = EMPTY_HASH)
|
22
|
+
super
|
11
23
|
@datasets = {}
|
12
|
-
|
24
|
+
@repo = Rugged::Repository.new(path)
|
13
25
|
end
|
14
26
|
|
15
27
|
def [](name)
|
16
|
-
|
28
|
+
datasets[name]
|
17
29
|
end
|
18
30
|
|
19
31
|
def dataset(name)
|
20
|
-
|
32
|
+
datasets[name] = Dataset.new(repo.references[branch].log)
|
21
33
|
end
|
22
34
|
|
23
35
|
def dataset?(name)
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def reset_data
|
28
|
-
repo = Rugged::Repository.new(@path)
|
29
|
-
walker = Rugged::Walker.new(repo)
|
30
|
-
branch = (@options || {}).fetch(:branch, 'refs/head/master')
|
31
|
-
ref = repo.references[branch]
|
32
|
-
|
33
|
-
@connection = ref.log rescue []
|
36
|
+
datasets.key?(name)
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
data/lib/rom/git/relation.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'rom/relation'
|
2
|
+
require 'rom/plugins/relation/key_inference'
|
3
|
+
require 'rom/plugins/relation/view'
|
2
4
|
|
3
5
|
module ROM
|
4
6
|
module Git
|
@@ -7,6 +9,9 @@ module ROM
|
|
7
9
|
|
8
10
|
forward :join, :project, :restrict, :order
|
9
11
|
|
12
|
+
use :view
|
13
|
+
use :key_inference
|
14
|
+
|
10
15
|
def count
|
11
16
|
dataset.count
|
12
17
|
end
|
data/rom-git.gemspec
CHANGED
@@ -1,27 +1,25 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
require File.expand_path('../lib/rom/git/version', __FILE__)
|
4
|
+
|
3
5
|
Gem::Specification.new do |spec|
|
4
6
|
spec.name = "rom-git"
|
5
|
-
spec.version =
|
6
|
-
spec.authors = ["Franck Verrot"]
|
7
|
-
spec.email = ["franck@verrot.fr"]
|
8
|
-
spec.summary = "Git
|
7
|
+
spec.version = ROM::Git::VERSION
|
8
|
+
spec.authors = ["Franck Verrot", "Piotr Solnica"]
|
9
|
+
spec.email = ["franck@verrot.fr", "piotr.solnica+oss@gmail.com"]
|
10
|
+
spec.summary = "Git adapter for the rom-rb"
|
9
11
|
spec.description = spec.summary
|
10
|
-
spec.homepage = "
|
12
|
+
spec.homepage = "http://rom-rb.org"
|
11
13
|
spec.license = "MIT"
|
12
14
|
|
13
15
|
spec.files = `git ls-files -z`.split("\x0")
|
14
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
17
|
spec.test_files = spec.files.grep(%r{^test/})
|
16
18
|
|
17
|
-
spec.add_runtime_dependency "rom", "~>
|
18
|
-
|
19
|
-
spec.add_dependency "rugged"
|
19
|
+
spec.add_runtime_dependency "rom", "~> 2.0"
|
20
|
+
spec.add_runtime_dependency "rugged", "~> 0.24"
|
20
21
|
|
21
22
|
spec.add_development_dependency "bundler"
|
22
23
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "
|
24
|
-
spec.add_development_dependency "pry"
|
25
|
-
spec.add_development_dependency "inflecto"
|
26
|
-
spec.add_development_dependency "virtus"
|
24
|
+
spec.add_development_dependency "rspec"
|
27
25
|
end
|
data/{test → spec}/fixtures/HEAD
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
49b6dbdb939f0d9494d40f210bbaeb54d6a15c35
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
RSpec.describe 'Git gateway' do
|
4
|
+
describe 'using the default (master) branch' do
|
5
|
+
let(:path) { File.expand_path('./spec/fixtures') }
|
6
|
+
|
7
|
+
let(:rom) do
|
8
|
+
ROM.container(:git, path) do |conf|
|
9
|
+
conf.relation(:commits) do
|
10
|
+
|
11
|
+
def by_sha1(sha1)
|
12
|
+
restrict(sha1: sha1)
|
13
|
+
end
|
14
|
+
|
15
|
+
def by_committer(committer_name)
|
16
|
+
restrict(committer: committer_name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
conf.mappers do
|
21
|
+
define(:commits) do
|
22
|
+
model OpenStruct
|
23
|
+
register_as :entity
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
shared_context 'a mapped relation tuple' do
|
30
|
+
it 'returns restricted and mapped object' do
|
31
|
+
commit = rom.relation(:commits)
|
32
|
+
.as(:entity).by_sha1('101868c4ce62b7e96a1f7c3b64fa40285ee00d5e').one
|
33
|
+
|
34
|
+
expect(commit.sha1).to eql('101868c4ce62b7e96a1f7c3b64fa40285ee00d5e')
|
35
|
+
expect(commit.message).to eql('commit (initial): Initial commit')
|
36
|
+
expect(commit.committer).to eql('Franck Verrot')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'using a relation with a custom mapper' do
|
41
|
+
let(:commit) do
|
42
|
+
rom.relation(:commits)
|
43
|
+
.as(:entity).by_sha1('101868c4ce62b7e96a1f7c3b64fa40285ee00d5e').one
|
44
|
+
end
|
45
|
+
|
46
|
+
include_context 'a mapped relation tuple'
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'using a repository' do
|
50
|
+
let(:repo) do
|
51
|
+
Class.new(ROM::Repository[:commits]).new(rom)
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:commits) { repo.commits.one }
|
55
|
+
|
56
|
+
include_context 'a mapped relation tuple'
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'setup' do
|
60
|
+
it 'raises when branch name is invalid' do
|
61
|
+
expect { ROM.container(:git, path, branch: 'not-here') { |conf| conf.relation(:commits) } }
|
62
|
+
.to raise_error(Rugged::ReferenceError, /not-here/)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'configures with a custom branch' do
|
66
|
+
rom = ROM.container(:git, path, branch: 'refs/heads/feature') { |conf| conf.relation(:commits) }
|
67
|
+
expect(rom.relations[:commits].count).to be(0)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '2.3.1'
|
4
|
+
require "codeclimate-test-reporter"
|
5
|
+
CodeClimate::TestReporter.start
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rom-git'
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'byebug'
|
12
|
+
rescue LoadError
|
13
|
+
end
|
14
|
+
|
15
|
+
root = Pathname(__FILE__).dirname
|
16
|
+
|
17
|
+
Dir[root.join('shared/*.rb').to_s].each { |f| require f }
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franck Verrot
|
8
|
+
- Piotr Solnica
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-07-31 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rom
|
@@ -16,28 +17,28 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
+
version: '2.0'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
+
version: '2.0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rugged
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - "
|
32
|
+
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
+
version: '0.24'
|
34
35
|
type: :runtime
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - "
|
39
|
+
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
+
version: '0.24'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: bundler
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,49 +68,7 @@ dependencies:
|
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: inflecto
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: virtus
|
71
|
+
name: rspec
|
113
72
|
requirement: !ruby/object:Gem::Requirement
|
114
73
|
requirements:
|
115
74
|
- - ">="
|
@@ -122,14 +81,16 @@ dependencies:
|
|
122
81
|
- - ">="
|
123
82
|
- !ruby/object:Gem::Version
|
124
83
|
version: '0'
|
125
|
-
description: Git
|
84
|
+
description: Git adapter for the rom-rb
|
126
85
|
email:
|
127
86
|
- franck@verrot.fr
|
87
|
+
- piotr.solnica+oss@gmail.com
|
128
88
|
executables: []
|
129
89
|
extensions: []
|
130
90
|
extra_rdoc_files: []
|
131
91
|
files:
|
132
92
|
- ".gitignore"
|
93
|
+
- ".rspec"
|
133
94
|
- ".travis.yml"
|
134
95
|
- CHANGELOG.md
|
135
96
|
- Gemfile
|
@@ -141,26 +102,28 @@ files:
|
|
141
102
|
- lib/rom/git/dataset.rb
|
142
103
|
- lib/rom/git/gateway.rb
|
143
104
|
- lib/rom/git/relation.rb
|
105
|
+
- lib/rom/git/version.rb
|
144
106
|
- rom-git.gemspec
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
-
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
155
|
-
-
|
156
|
-
-
|
157
|
-
-
|
158
|
-
-
|
159
|
-
-
|
160
|
-
-
|
161
|
-
-
|
162
|
-
-
|
163
|
-
|
107
|
+
- spec/fixtures/HEAD
|
108
|
+
- spec/fixtures/logs/HEAD
|
109
|
+
- spec/fixtures/logs/refs/heads/feature
|
110
|
+
- spec/fixtures/logs/refs/heads/master
|
111
|
+
- spec/fixtures/objects/0a/0d213d2bcc5d5fb3a39c134d253d160b7c14c4
|
112
|
+
- spec/fixtures/objects/10/1868c4ce62b7e96a1f7c3b64fa40285ee00d5e
|
113
|
+
- spec/fixtures/objects/20/5f6b799e7d5c2524468ca006a0131aa57ecce7
|
114
|
+
- spec/fixtures/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99
|
115
|
+
- spec/fixtures/objects/49/b6dbdb939f0d9494d40f210bbaeb54d6a15c35
|
116
|
+
- spec/fixtures/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
|
117
|
+
- spec/fixtures/objects/6f/331f786e8c5ca8ffb67d1dfd3b1e1942167e3e
|
118
|
+
- spec/fixtures/objects/89/ff1a2aefcbff0f09197f0fd8beeb19a7b6e51c
|
119
|
+
- spec/fixtures/objects/e7/d5223c10643012af885505e2fc7950f81214b6
|
120
|
+
- spec/fixtures/objects/f0/184ad83045ea3a7e32fb547d5275f21686558d
|
121
|
+
- spec/fixtures/objects/fe/326fd5cb986e6ef3d83f02857fb5bc10333aa4
|
122
|
+
- spec/fixtures/refs/heads/feature
|
123
|
+
- spec/fixtures/refs/heads/master
|
124
|
+
- spec/integration/gateway_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
homepage: http://rom-rb.org
|
164
127
|
licenses:
|
165
128
|
- MIT
|
166
129
|
metadata: {}
|
@@ -180,27 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
143
|
version: '0'
|
181
144
|
requirements: []
|
182
145
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.5.1
|
184
147
|
signing_key:
|
185
148
|
specification_version: 4
|
186
|
-
summary: Git
|
187
|
-
test_files:
|
188
|
-
- test/fixtures/HEAD
|
189
|
-
- test/fixtures/logs/HEAD
|
190
|
-
- test/fixtures/logs/refs/heads/master
|
191
|
-
- test/fixtures/objects/0a/0d213d2bcc5d5fb3a39c134d253d160b7c14c4
|
192
|
-
- test/fixtures/objects/10/1868c4ce62b7e96a1f7c3b64fa40285ee00d5e
|
193
|
-
- test/fixtures/objects/20/5f6b799e7d5c2524468ca006a0131aa57ecce7
|
194
|
-
- test/fixtures/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99
|
195
|
-
- test/fixtures/objects/49/b6dbdb939f0d9494d40f210bbaeb54d6a15c35
|
196
|
-
- test/fixtures/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
|
197
|
-
- test/fixtures/objects/6f/331f786e8c5ca8ffb67d1dfd3b1e1942167e3e
|
198
|
-
- test/fixtures/objects/89/ff1a2aefcbff0f09197f0fd8beeb19a7b6e51c
|
199
|
-
- test/fixtures/objects/e7/d5223c10643012af885505e2fc7950f81214b6
|
200
|
-
- test/fixtures/objects/f0/184ad83045ea3a7e32fb547d5275f21686558d
|
201
|
-
- test/fixtures/objects/fe/326fd5cb986e6ef3d83f02857fb5bc10333aa4
|
202
|
-
- test/fixtures/refs/heads/master
|
203
|
-
- test/integration/gateway_test.rb
|
204
|
-
- test/integration/relation_test.rb
|
205
|
-
- test/test_helper.rb
|
206
|
-
has_rdoc:
|
149
|
+
summary: Git adapter for the rom-rb
|
150
|
+
test_files: []
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'virtus'
|
3
|
-
|
4
|
-
describe 'Git gateway' do
|
5
|
-
describe 'using the default (master) branch' do
|
6
|
-
let(:path) { File.expand_path('./test/fixtures') }
|
7
|
-
let(:rom_setup) do
|
8
|
-
ROM.setup(
|
9
|
-
commits: [
|
10
|
-
:git,
|
11
|
-
path,
|
12
|
-
branch: 'refs/heads/master'
|
13
|
-
]
|
14
|
-
)
|
15
|
-
end
|
16
|
-
let(:rom) { rom_setup.finalize }
|
17
|
-
|
18
|
-
before do
|
19
|
-
rom_setup.relation(:commits) do
|
20
|
-
gateway :commits
|
21
|
-
|
22
|
-
def by_sha1(sha1)
|
23
|
-
restrict(sha1: sha1)
|
24
|
-
end
|
25
|
-
|
26
|
-
def by_committer(committer_name)
|
27
|
-
restrict(committer: committer_name)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
rom_setup.mappers do
|
32
|
-
define(:commits) do
|
33
|
-
model(Class.new do
|
34
|
-
include Virtus.model
|
35
|
-
|
36
|
-
attribute :sha1, String
|
37
|
-
attribute :message, String
|
38
|
-
attribute :committer, String
|
39
|
-
end)
|
40
|
-
|
41
|
-
register_as :entity
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'env#relation' do
|
47
|
-
it 'returns restricted and mapped object' do
|
48
|
-
commit = rom.relation(:commits).as(:entity).by_sha1('101868c4ce62b7e96a1f7c3b64fa40285ee00d5e').to_a.first
|
49
|
-
|
50
|
-
assert_equal '101868c4ce62b7e96a1f7c3b64fa40285ee00d5e', commit.sha1
|
51
|
-
assert_equal 'commit (initial): Initial commit', commit.message
|
52
|
-
assert_equal 'Franck Verrot', commit.committer
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# describe 'with a custom branch'
|
57
|
-
end
|
58
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe "Git Gateway" do
|
4
|
-
let(:path) { File.expand_path("./test/fixtures") }
|
5
|
-
let(:rom_setup) do
|
6
|
-
ROM.setup(
|
7
|
-
commits: [
|
8
|
-
:git,
|
9
|
-
path,
|
10
|
-
branch: 'refs/heads/master'
|
11
|
-
]
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
before do
|
16
|
-
ROM.plugins do
|
17
|
-
adapter :git do
|
18
|
-
register :test_plugin, Module.new, type: :relation
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "relation with plugin" do
|
24
|
-
it "shouldn't raise error" do
|
25
|
-
rom_setup.relation(:commits) do
|
26
|
-
gateway :commits
|
27
|
-
use :test_plugin
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|