relaxo 1.0.1 → 1.2.0
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.
- checksums.yaml +4 -4
- data/.rspec +3 -2
- data/.travis.yml +10 -12
- data/Gemfile +1 -1
- data/lib/relaxo.rb +5 -1
- data/lib/relaxo/changeset.rb +2 -2
- data/lib/relaxo/database.rb +1 -1
- data/lib/relaxo/dataset.rb +16 -4
- data/lib/relaxo/directory.rb +23 -6
- data/lib/relaxo/version.rb +1 -1
- data/relaxo.gemspec +1 -1
- data/spec/spec_helper.rb +29 -0
- metadata +7 -6
- data/.simplecov +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0001153bcb2843832dc1f6ad29e49885db98729d
|
4
|
+
data.tar.gz: 0e065a359e1ae3f0ff21ecc1848b2189f3f5345e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768562aeadc873bdd50df1a49ef3a455f64d9a6bc56d2edb4fcf5fe0876e46b6a83f137a677df3faac8cac46aa3da8dc4b6eff91157fc152f0478e621e93922b
|
7
|
+
data.tar.gz: f88b84ef0e018606ef3696688755315d6fd0092fb201de2e76186b5cd1606b8162f72cadf32650dad2513767850e36eadd8af7028722b74aef5ae4d5c9c98ec4
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
|
-
|
4
|
-
|
5
|
-
- git config --global user.name "Samuel Williams"
|
6
|
-
- git config --global user.email "samuel@oriontransfer.net"
|
3
|
+
dist: trusty
|
4
|
+
cache: bundler
|
7
5
|
rvm:
|
8
|
-
- 2.1
|
9
|
-
- 2.2
|
10
|
-
- 2.3
|
11
|
-
- 2.4
|
12
|
-
-
|
13
|
-
|
6
|
+
- 2.1
|
7
|
+
- 2.2
|
8
|
+
- 2.3
|
9
|
+
- 2.4
|
10
|
+
- ruby-head
|
11
|
+
- jruby-head
|
14
12
|
matrix:
|
15
13
|
allow_failures:
|
16
|
-
- rvm: ruby-head
|
17
|
-
- rvm: "
|
14
|
+
- rvm: "ruby-head"
|
15
|
+
- rvm: "jruby-head"
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in relaxo.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'rugged', git: '
|
6
|
+
gem 'rugged', git: 'https://github.com/libgit2/rugged.git', submodules: true
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "pry"
|
data/lib/relaxo.rb
CHANGED
@@ -25,7 +25,11 @@ require 'pry'
|
|
25
25
|
module Relaxo
|
26
26
|
def self.connect(path, metadata = {})
|
27
27
|
unless File.exist?(path)
|
28
|
-
Rugged::Repository.init_at(path, true)
|
28
|
+
repository = Rugged::Repository.init_at(path, true)
|
29
|
+
|
30
|
+
if metadata[:sync] || ENV['RELAXO_SYNC']
|
31
|
+
repository.config['core.fsyncObjectFiles'] = true
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
return Database.new(path, metadata)
|
data/lib/relaxo/changeset.rb
CHANGED
@@ -65,7 +65,7 @@ module Relaxo
|
|
65
65
|
name: name,
|
66
66
|
}
|
67
67
|
|
68
|
-
|
68
|
+
fetch_directory(root).insert(entry)
|
69
69
|
|
70
70
|
return entry
|
71
71
|
end
|
@@ -82,7 +82,7 @@ module Relaxo
|
|
82
82
|
name: name,
|
83
83
|
}
|
84
84
|
|
85
|
-
|
85
|
+
fetch_directory(root).delete(entry)
|
86
86
|
|
87
87
|
return entry
|
88
88
|
end
|
data/lib/relaxo/database.rb
CHANGED
data/lib/relaxo/dataset.rb
CHANGED
@@ -41,19 +41,31 @@ module Relaxo
|
|
41
41
|
|
42
42
|
alias [] read
|
43
43
|
|
44
|
+
def file?
|
45
|
+
read(path)
|
46
|
+
end
|
47
|
+
|
44
48
|
def exist?(path)
|
45
|
-
read(path)
|
49
|
+
read(path) or directory?(path)
|
50
|
+
end
|
51
|
+
|
52
|
+
def directory?(path)
|
53
|
+
@directories.key?(path) or @tree.path(path)[:type] == :tree
|
54
|
+
rescue Rugged::TreeError
|
55
|
+
return false
|
46
56
|
end
|
47
57
|
|
48
|
-
def each(path =
|
58
|
+
def each(path = '', &block)
|
49
59
|
return to_enum(:each, path) unless block_given?
|
50
60
|
|
51
|
-
directory(path)
|
61
|
+
directory = fetch_directory(path)
|
62
|
+
|
63
|
+
directory.each(&block)
|
52
64
|
end
|
53
65
|
|
54
66
|
protected
|
55
67
|
|
56
|
-
def
|
68
|
+
def fetch_directory(path)
|
57
69
|
@directories[path] ||= Directory.new(@repository, @tree, path)
|
58
70
|
end
|
59
71
|
end
|
data/lib/relaxo/directory.rb
CHANGED
@@ -22,9 +22,16 @@ require 'rugged'
|
|
22
22
|
|
23
23
|
module Relaxo
|
24
24
|
class Directory
|
25
|
-
def initialize(repository,
|
25
|
+
def initialize(repository, root_tree, path)
|
26
26
|
@repository = repository
|
27
|
-
|
27
|
+
|
28
|
+
# The root tree, which path is relative to:
|
29
|
+
@root_tree = root_tree
|
30
|
+
|
31
|
+
# The entry and tree for the directory itself:
|
32
|
+
@entry = nil
|
33
|
+
@tree = nil
|
34
|
+
|
28
35
|
@path = path
|
29
36
|
|
30
37
|
@entries = nil
|
@@ -51,6 +58,12 @@ module Relaxo
|
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
61
|
+
def each_entry(&block)
|
62
|
+
return to_enum(:each_entry) unless block_given?
|
63
|
+
|
64
|
+
entries.each(&block)
|
65
|
+
end
|
66
|
+
|
54
67
|
def insert(entry)
|
55
68
|
_, _, name = entry[:name].rpartition('/')
|
56
69
|
|
@@ -71,10 +84,14 @@ module Relaxo
|
|
71
84
|
|
72
85
|
private
|
73
86
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
87
|
+
# Look up the entry for the given directory `@path`:
|
88
|
+
def fetch_entry
|
89
|
+
@entry ||= @root_tree.path(@path)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Load the directory tree for the given `@path`:
|
93
|
+
def fetch_tree
|
94
|
+
@tree ||= Rugged::Tree.new(@repository, fetch_entry[:oid])
|
78
95
|
rescue Rugged::TreeError
|
79
96
|
return nil
|
80
97
|
end
|
data/lib/relaxo/version.rb
CHANGED
data/relaxo.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_dependency "rugged"
|
26
26
|
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
28
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
29
29
|
spec.add_development_dependency "rake"
|
30
30
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
if ENV['COVERAGE'] || ENV['TRAVIS']
|
3
|
+
begin
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter "/spec/"
|
8
|
+
end
|
9
|
+
|
10
|
+
if ENV['TRAVIS']
|
11
|
+
require 'coveralls'
|
12
|
+
Coveralls.wear!
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
warn "Could not load simplecov: #{$!}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require "bundler/setup"
|
20
|
+
require "relaxo"
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
# Enable flags like --only-failures and --next-failure
|
24
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
25
|
+
|
26
|
+
config.expect_with :rspec do |c|
|
27
|
+
c.syntax = :expect
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: '3.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
40
|
+
version: '3.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,7 +79,6 @@ extra_rdoc_files: []
|
|
79
79
|
files:
|
80
80
|
- ".gitignore"
|
81
81
|
- ".rspec"
|
82
|
-
- ".simplecov"
|
83
82
|
- ".travis.yml"
|
84
83
|
- Gemfile
|
85
84
|
- README.md
|
@@ -100,6 +99,7 @@ files:
|
|
100
99
|
- spec/relaxo/enumeration_spec.rb
|
101
100
|
- spec/relaxo/performance_spec.rb
|
102
101
|
- spec/relaxo/test_records.rb
|
102
|
+
- spec/spec_helper.rb
|
103
103
|
homepage: ''
|
104
104
|
licenses:
|
105
105
|
- MIT
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.6.
|
123
|
+
rubygems_version: 2.6.12
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Relaxo is a helper for loading and working with CouchDB.
|
@@ -131,3 +131,4 @@ test_files:
|
|
131
131
|
- spec/relaxo/enumeration_spec.rb
|
132
132
|
- spec/relaxo/performance_spec.rb
|
133
133
|
- spec/relaxo/test_records.rb
|
134
|
+
- spec/spec_helper.rb
|