relaxo 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9be2c95aada8b0d15d79f7376b32e57a07724cbe1fd93afa578091c0c522906c
4
- data.tar.gz: b17fa3492dd504ba16a018fee637e8c1d3d293bdacc4fb84f65e5deefca3e792
3
+ metadata.gz: b71fd8263f890a77bf20e18e6e3258edeee8954076452914cb35698a7827723b
4
+ data.tar.gz: e502abf00e610646d5866868b23c931330b919ab5e3ab280128f82d070765c11
5
5
  SHA512:
6
- metadata.gz: d0b4a7b024ad81169340891f1c7541bc2b5a1ecff678c4f4685b1aa8c7567546f6d0f7a69c078b132f6e9a88b90ea1d63ea14308c7984836850ac0ae1fe979d2
7
- data.tar.gz: ded7e4a80713178e513f7b8d585e974fef763fb025d1d083f2574ecf553015cb519c059054ac4e61cae4ba33a30d0924b1f971ca2632cab08efa8e41a68562d7
6
+ metadata.gz: 41ec8840e1a72cfa879045f2f22b7cf10e165d9e47e7f4cad72005785f0be3b3b6c6229f2c210888637903497ad74289f1fea8f72646f2ece2119537837da16f
7
+ data.tar.gz: 69b6c7b790da0585527339c3b4ea593cd8da13c08ef751af82e83b0fa2af911015a4013a362479a4c2bc60f09d0ad4e992bcafa776463e783f423a56534943ac
data/.travis.yml CHANGED
@@ -1,15 +1,20 @@
1
1
  language: ruby
2
- sudo: false
3
- dist: trusty
2
+ dist: xenial
4
3
  cache: bundler
5
- rvm:
6
- - 2.1
7
- - 2.2
8
- - 2.3
9
- - 2.4
10
- - ruby-head
11
- - jruby-head
4
+
12
5
  matrix:
6
+ include:
7
+ - rvm: 2.4
8
+ - rvm: 2.5
9
+ - rvm: 2.6
10
+ - rvm: 2.6
11
+ env: COVERAGE=Summary,Coveralls
12
+ - rvm: truffleruby
13
+ - rvm: ruby-head
14
+ - rvm: 2.6
15
+ os: osx
13
16
  allow_failures:
14
- - rvm: "ruby-head"
15
- - rvm: "jruby-head"
17
+ - rvm: truffleruby
18
+ - rvm: ruby-head
19
+ - rvm: jruby-head
20
+ - rvm: truffleruby
data/README.md CHANGED
@@ -31,18 +31,18 @@ Connect to a local database and manipulate some documents.
31
31
 
32
32
  DB.commit(message: "Create test data") do |dataset|
33
33
  object = dataset.append(MessagePack.dump({bob: 'dole'}))
34
- dataset.write("doc1.json", object)
34
+ dataset.write("doc1.msgpack", object)
35
35
  end
36
36
 
37
37
  DB.commit(message: "Update test data") do |dataset|
38
- doc = MessagePack.load dataset.read('doc1.json').data
38
+ doc = MessagePack.load dataset.read('doc1.msgpack').data
39
39
  doc[:foo] = 'bar'
40
40
 
41
41
  object = dataset.append(MessagePack.dump(doc))
42
- dataset.write("doc2.json", object)
42
+ dataset.write("doc2.msgpack", object)
43
43
  end
44
44
 
45
- doc = MessagePack.load DB.current['doc2.json'].data
45
+ doc = MessagePack.load DB.current['doc2.msgpack'].data
46
46
  puts doc
47
47
  # => {"bob"=>"dole", "foo"=>"bar"}
48
48
 
data/lib/relaxo.rb CHANGED
@@ -20,7 +20,8 @@
20
20
 
21
21
  require 'relaxo/database'
22
22
 
23
- require 'pry'
23
+ require 'etc'
24
+ require 'socket'
24
25
 
25
26
  module Relaxo
26
27
  MASTER = 'master'.freeze
@@ -36,6 +37,18 @@ module Relaxo
36
37
 
37
38
  branch ||= MASTER
38
39
 
39
- return Database.new(path, branch, metadata)
40
+ database = Database.new(path, branch, metadata)
41
+
42
+ if config = database.config
43
+ unless config['user.name']
44
+ login = Etc.getlogin
45
+ hostname = Socket.gethostname
46
+
47
+ config['user.name'] = login
48
+ config['user.email'] = "#{login}@#{hostname}"
49
+ end
50
+ end
51
+
52
+ return database
40
53
  end
41
54
  end
@@ -19,8 +19,8 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require 'rugged'
22
- require 'logger'
23
22
 
23
+ require_relative 'logger'
24
24
  require_relative 'dataset'
25
25
  require_relative 'changeset'
26
26
 
@@ -32,13 +32,15 @@ module Relaxo
32
32
  @path = path
33
33
  @metadata = metadata
34
34
 
35
- @logger = metadata[:logger] || Logger.new($stderr).tap{|logger| logger.level = Logger::INFO}
36
-
37
35
  @repository = Rugged::Repository.new(path)
38
36
 
39
37
  @branch = branch
40
38
  end
41
39
 
40
+ def config
41
+ @repository.config
42
+ end
43
+
42
44
  attr :path
43
45
  attr :metadata
44
46
  attr :repository
@@ -127,7 +129,7 @@ module Relaxo
127
129
  end_time = Time.now
128
130
  elapsed_time = end_time - start_time
129
131
 
130
- @logger.debug("time") {"#{message.inspect}: %0.3fs" % elapsed_time}
132
+ Relaxo.logger.debug("time") {"#{message.inspect}: %0.3fs" % elapsed_time}
131
133
  end
132
134
 
133
135
  def apply(parent, changeset, **options)
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2012 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'console'
22
+
23
+ module Relaxo
24
+ extend Console
25
+ end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Relaxo
22
- VERSION = "1.4.0"
22
+ VERSION = "1.5.0"
23
23
  end
data/relaxo.gemspec CHANGED
@@ -23,7 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "rugged"
26
+ spec.add_dependency "console"
26
27
 
28
+ spec.add_development_dependency "covered"
27
29
  spec.add_development_dependency "rspec", "~> 3.6"
28
30
  spec.add_development_dependency "bundler", "~> 1.3"
29
31
  spec.add_development_dependency "rake"
@@ -15,6 +15,13 @@ RSpec.describe Relaxo::Database do
15
15
  expect(database).to be_empty
16
16
  end
17
17
 
18
+ it "prepares user details in config" do
19
+ expect(database.config).to include('user.name', 'user.email')
20
+
21
+ puts database.config['user.name']
22
+ puts database.config['user.email']
23
+ end
24
+
18
25
  it "can clear database" do
19
26
  expect do
20
27
  database.clear!
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,5 @@
1
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"
2
+ require 'covered/rspec'
21
3
 
22
4
  RSpec.configure do |config|
23
5
  # Enable flags like --only-failures and --next-failure
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.4.0
4
+ version: 1.5.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: 2018-06-30 00:00:00.000000000 Z
11
+ date: 2019-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: console
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: covered
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rspec
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +118,7 @@ files:
90
118
  - lib/relaxo/database.rb
91
119
  - lib/relaxo/dataset.rb
92
120
  - lib/relaxo/directory.rb
121
+ - lib/relaxo/logger.rb
93
122
  - lib/relaxo/version.rb
94
123
  - relaxo.gemspec
95
124
  - spec/relaxo/changeset_spec.rb
@@ -118,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
147
  - !ruby/object:Gem::Version
119
148
  version: '0'
120
149
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.7.6
150
+ rubygems_version: 3.0.3
123
151
  signing_key:
124
152
  specification_version: 4
125
153
  summary: Relaxo is a helper for loading and working with CouchDB.