cooper 0.0.1 → 0.1.0.pre.alpha1
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/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +6 -1
- data/.travis.yml +11 -0
- data/CODE_OF_CONDUCT.md +42 -6
- data/Guardfile +8 -26
- data/README.md +57 -17
- data/Rakefile +17 -0
- data/cooper.gemspec +27 -20
- data/features/mongoid_configuration_spec.rb +11 -0
- data/features/revisioning_spec.rb +65 -0
- data/features/validations_spec.rb +18 -0
- data/lib/cooper/document.rb +68 -0
- data/lib/cooper/revision_source.rb +30 -0
- data/lib/cooper/version.rb +1 -1
- data/lib/cooper.rb +6 -30
- metadata +39 -48
- data/bin/cooper +0 -38
- data/cooper +0 -0
- data/lib/cooper/datastore.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af06dde0588ccd1b4f7cc53d83155c4117040b3
|
4
|
+
data.tar.gz: 06db1ce8eb7612da7683503814907da1afe0721d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f1595866394b6f9a1c75aac38c8fae6c3afa7a2d8cacdd6d70c4dfe1bec022b6c0c5479231e707167c0f062157e50b444cadc55ea711d44b84ea921704ebaab
|
7
|
+
data.tar.gz: f37f4bbef167fa1afcee6fcb7e90b700fdd55867e828927478e6114fce59500ebf3847b0765a3813a50f0bc2d9e689cf27c6ba73f131b16b74db93924b8daabd
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,13 +1,49 @@
|
|
1
1
|
# Contributor Code of Conduct
|
2
2
|
|
3
|
-
As contributors and maintainers of this project,
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
4
7
|
|
5
|
-
We are committed to making participation in this project a harassment-free
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
6
12
|
|
7
|
-
Examples of unacceptable behavior by participants include
|
13
|
+
Examples of unacceptable behavior by participants include:
|
8
14
|
|
9
|
-
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
10
22
|
|
11
|
-
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
12
28
|
|
13
|
-
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at efflamm.castel@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Guardfile
CHANGED
@@ -1,24 +1,12 @@
|
|
1
|
-
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
1
|
+
#!/usr/bin/env ruby
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# Uncomment to clear the screen before every task
|
8
|
-
clearing :on
|
9
|
-
|
10
|
-
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
-
## If you want Guard to automatically start up again, run guard in a
|
12
|
-
## shell loop, e.g.:
|
13
|
-
##
|
14
|
-
## $ while bundle exec guard; do echo 'Restarting Guard...'; done
|
15
|
-
##
|
16
|
-
|
17
|
-
group :red_green_refactor do
|
18
|
-
guard :rspec, cmd: 'bundle exec rspec' do
|
19
|
-
require 'guard/rspec/dsl'
|
3
|
+
group :red_green_refactor, halt_on_fail: true do
|
4
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
5
|
+
require "guard/rspec/dsl"
|
20
6
|
dsl = Guard::RSpec::Dsl.new(self)
|
21
7
|
|
8
|
+
# Feel free to open issues for suggestions and improvements
|
9
|
+
|
22
10
|
# RSpec files
|
23
11
|
rspec = dsl.rspec
|
24
12
|
watch(rspec.spec_helper) { rspec.spec_dir }
|
@@ -28,16 +16,10 @@ group :red_green_refactor do
|
|
28
16
|
# Ruby files
|
29
17
|
ruby = dsl.ruby
|
30
18
|
dsl.watch_spec_files_for(ruby.lib_files)
|
31
|
-
|
32
|
-
## Turnip features and steps
|
33
|
-
# watch(%r{^spec/acceptance/(.+)\.feature$})
|
34
|
-
# watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
35
|
-
# Dir[File.join('**/#{m[1]}.feature')][0] || "spec/acceptance"
|
36
|
-
# end
|
37
19
|
end
|
38
20
|
|
39
|
-
guard :rubocop do
|
40
|
-
watch(
|
21
|
+
guard :rubocop, cli: ['-D'] do
|
22
|
+
watch(%r{.+\.rb$})
|
41
23
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
42
24
|
end
|
43
25
|
end
|
data/README.md
CHANGED
@@ -1,36 +1,76 @@
|
|
1
1
|
# Cooper
|
2
2
|
|
3
|
-
|
3
|
+
[](https://codeclimate.com/github/floum/cooper)
|
4
|
+
[](https://codeclimate.com/github/floum/cooper/coverage)
|
5
|
+
[](https://travis-ci.org/floum/cooper)
|
6
|
+
[](https://gemnasium.com/github.com/floum/cooper)
|
4
7
|
|
5
|
-
|
8
|
+
A schema-less revisioning database project built on [Mongoid](https://github.com/mongodb/mongoid)
|
6
9
|
|
7
10
|
## Getting Started
|
8
|
-
|
9
|
-
Cooper currently tracks the life of a single item.
|
10
|
-
Cooper uses the `ENV['HOME']` environment variable to store data.
|
11
|
-
This will change before v1.0.0
|
12
11
|
|
13
12
|
Install cooper from the command prompt
|
14
13
|
|
15
14
|
`gem install cooper`
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
require 'cooper'
|
20
|
+
|
21
|
+
# Frameworks usually manage this step
|
22
|
+
Mongoid.load!('/path/to/config/mongoid.yml', :environment)
|
23
|
+
|
24
|
+
class Record
|
25
|
+
include Cooper::Document
|
26
|
+
|
27
|
+
revision_field :key
|
28
|
+
end
|
29
|
+
|
30
|
+
record = Record.new(key: 1)
|
31
|
+
|
32
|
+
record.save
|
33
|
+
p record.key
|
34
|
+
#=> 1
|
35
|
+
|
36
|
+
record.update_attributes(key: 2)
|
37
|
+
p record.key
|
38
|
+
#=> 2
|
39
|
+
|
40
|
+
record.checkout(id: 1)
|
41
|
+
p record.key
|
42
|
+
#=> 1
|
43
|
+
|
44
|
+
record.checkout(time: Time.now)
|
45
|
+
p record.key
|
46
|
+
#=> 2
|
47
|
+
```
|
16
48
|
|
17
|
-
|
49
|
+
## Features
|
50
|
+
|
51
|
+
Cooper::Document behaves like a Mongoid::Document
|
52
|
+
|
53
|
+
It adds the capabilities of checking out declared revision fields
|
54
|
+
|
55
|
+
It uses Redis on port 6379 to get the current revision count
|
56
|
+
|
57
|
+
## Road Map
|
58
|
+
|
59
|
+
* Persist revision count from mongodb
|
60
|
+
* Allow Redis configuration
|
61
|
+
* Enable validation skipping on save
|
18
62
|
|
19
|
-
|
20
|
-
`cooper update version:0.0.1 date:2015-05-29'
|
63
|
+
## Tests
|
21
64
|
|
22
|
-
|
65
|
+
`rake` will run all tests
|
23
66
|
|
24
|
-
|
25
|
-
`cooper read --at 1` for status after first update
|
67
|
+
`rake spec:features` will run against mongodb (configuration is located at `spec/support/mongoid.yml`)
|
26
68
|
|
27
|
-
|
69
|
+
`rake spec:unit` runs tests in isolation
|
28
70
|
|
29
|
-
##
|
30
|
-
|
31
|
-
version 0.0.2 will provide the command `cooper start` to bind a cooper server to an IP port
|
71
|
+
## License
|
32
72
|
|
33
|
-
|
73
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
34
74
|
|
35
75
|
## Contributing
|
36
76
|
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
namespace :spec do
|
6
|
+
RSpec::Core::RakeTask.new(:features) do |t|
|
7
|
+
t.pattern = 'features/**/*_spec.rb'
|
8
|
+
end
|
9
|
+
RSpec::Core::RakeTask.new(:unit)
|
10
|
+
|
11
|
+
task all: [:features, :unit]
|
12
|
+
end
|
13
|
+
|
14
|
+
task default: 'spec:all'
|
15
|
+
rescue LoadError
|
16
|
+
p 'RSpec is not available on this machine'
|
17
|
+
end
|
data/cooper.gemspec
CHANGED
@@ -4,30 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'cooper/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.date = '2015-05-21'
|
10
|
-
spec.summary = 'Cooper revisioning database project'
|
11
|
-
spec.description = 'A revisioning database'
|
12
|
-
spec.authors = ['Efflam Castel']
|
13
|
-
spec.email = 'efflamm.castel@gmail.com'
|
7
|
+
spec.date = '2016-05-26'
|
8
|
+
spec.required_ruby_version = '>= 2.3'
|
14
9
|
|
15
|
-
spec.
|
16
|
-
|
10
|
+
spec.name = 'cooper'
|
11
|
+
spec.version = Cooper::VERSION
|
12
|
+
spec.authors = ['Efflam Castel']
|
13
|
+
spec.email = ['efflamm.castel@gmail.com']
|
17
14
|
|
18
|
-
spec.
|
19
|
-
spec.
|
20
|
-
spec.
|
15
|
+
spec.summary = 'a revision database system built upon mongoid'
|
16
|
+
spec.homepage = 'https://github.com/floum/cooper'
|
17
|
+
spec.license = 'MIT'
|
21
18
|
|
22
|
-
spec.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise 'Upgrade RubyGems to protect against public gem pushes.'
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0")
|
26
|
+
.reject { |f| f.match(%r{^(spec)/}) }
|
27
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
28
|
+
spec.require_paths = ['lib']
|
23
29
|
|
24
|
-
spec.add_runtime_dependency '
|
25
|
-
spec.add_runtime_dependency '
|
30
|
+
spec.add_runtime_dependency 'mongoid', '~> 5.1'
|
31
|
+
spec.add_runtime_dependency 'redis', '~> 3.3'
|
26
32
|
|
27
|
-
spec.add_development_dependency '
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency '
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
34
|
+
spec.add_development_dependency 'rake', '~> 11.1'
|
35
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
30
36
|
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
31
|
-
spec.add_development_dependency '
|
32
|
-
|
37
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.5'
|
38
|
+
|
39
|
+
spec.license = 'MIT'
|
33
40
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
describe 'Revisioning feature' do
|
2
|
+
# cooper document with one key example
|
3
|
+
class RevisionedObject
|
4
|
+
include Cooper::Document
|
5
|
+
|
6
|
+
revision_field :key, type: String
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'Saving documents' do
|
10
|
+
let(:object) do
|
11
|
+
RevisionedObject.new
|
12
|
+
end
|
13
|
+
it 'is OK' do
|
14
|
+
expect(object.save).to be_truthy
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'Updating documents' do
|
19
|
+
let(:object) do
|
20
|
+
RevisionedObject.new
|
21
|
+
end
|
22
|
+
it 'works as expected' do
|
23
|
+
object.key = 'value0'
|
24
|
+
object.save
|
25
|
+
object.update_attributes(key: 'value1')
|
26
|
+
expect(object.key).to eq 'value1'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'Checking out documents' do
|
31
|
+
let(:object) do
|
32
|
+
RevisionedObject.new
|
33
|
+
end
|
34
|
+
it 'works as expected' do
|
35
|
+
object.key = 'value1'
|
36
|
+
object.save
|
37
|
+
object.update_attributes(key: 'value2')
|
38
|
+
object.update_attributes(key: 'value3')
|
39
|
+
object.checkout id: 1
|
40
|
+
expect(object.key).to eq 'value1'
|
41
|
+
object.checkout id: 3
|
42
|
+
expect(object.key).to eq 'value3'
|
43
|
+
end
|
44
|
+
it 'manages multiple objects' do
|
45
|
+
object_1 = RevisionedObject.new
|
46
|
+
object_1.key = '1.1'
|
47
|
+
object_1.save
|
48
|
+
object.save
|
49
|
+
object.key = '1.2'
|
50
|
+
object_2 = RevisionedObject.new
|
51
|
+
object_2.key = '2.3'
|
52
|
+
object_2.save
|
53
|
+
object_1.key = '1.4'
|
54
|
+
object_1.save
|
55
|
+
object_2.key = '2.5'
|
56
|
+
object_2.save
|
57
|
+
object_1.key = '1.6'
|
58
|
+
object_1.save
|
59
|
+
object_1.checkout id: 4
|
60
|
+
expect(object_1.key).to eq '1.4'
|
61
|
+
object_2.checkout id: 4
|
62
|
+
expect(object_2.key).to eq '2.3'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe 'Validations' do
|
2
|
+
# basic cooper document validations example
|
3
|
+
class ValidatedObject
|
4
|
+
include Cooper::Document
|
5
|
+
|
6
|
+
revision_field :single_digit, type: Integer
|
7
|
+
|
8
|
+
validates :single_digit, inclusion: { in: (0..9) }
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'works just like Mongoid::Document' do
|
12
|
+
object = ValidatedObject.new(single_digit: 5)
|
13
|
+
expect(object.save).to be_truthy
|
14
|
+
|
15
|
+
object = ValidatedObject.new(single_digit: 10)
|
16
|
+
expect(object.save).not_to be_truthy
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Cooper
|
2
|
+
# Mongoid Document compliant with Revisions
|
3
|
+
module Document
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Mongoid::Document
|
6
|
+
|
7
|
+
attr_accessor :revision_source
|
8
|
+
|
9
|
+
def initialize(*)
|
10
|
+
self.revision_source = REVISION_SOURCE
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def save
|
15
|
+
if valid?
|
16
|
+
revisions.unshift(new_revision)
|
17
|
+
begin
|
18
|
+
super(validate: false)
|
19
|
+
rescue MongoidError => e
|
20
|
+
revisions.shift
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
revision_source.notify_save
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def checkout(options = {})
|
28
|
+
return nil unless find_revision(options)
|
29
|
+
|
30
|
+
find_revision(options)
|
31
|
+
.reject { |key, _| key == :created_at }
|
32
|
+
.each do |field, value|
|
33
|
+
send("#{field}=", value)
|
34
|
+
end
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
included do
|
39
|
+
class_attribute :revision_fields
|
40
|
+
self.revision_fields = []
|
41
|
+
field :revisions, type: Array, default: []
|
42
|
+
end
|
43
|
+
|
44
|
+
class_methods do
|
45
|
+
def revision_field(field, options = {})
|
46
|
+
revision_fields << field
|
47
|
+
self.field field, options
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def new_revision
|
54
|
+
revision_source.new_revision(self)
|
55
|
+
end
|
56
|
+
|
57
|
+
def find_revision(options)
|
58
|
+
raise ArgumentError if ([:time, :id] - options.keys).empty?
|
59
|
+
id = options.fetch(:id) { nil }
|
60
|
+
time = options.fetch(:time) { nil }
|
61
|
+
if id
|
62
|
+
revisions.find { |revision| revision[:id] <= id }
|
63
|
+
else
|
64
|
+
revisions.find { |revision| revision[:created_at] <= time }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Cooper
|
2
|
+
# Default revisions factory for cooper documents
|
3
|
+
class RevisionSource
|
4
|
+
attr_writer :clock
|
5
|
+
|
6
|
+
def initialize(clock = Time)
|
7
|
+
@source = Redis.new
|
8
|
+
@clock = clock
|
9
|
+
end
|
10
|
+
|
11
|
+
def revision_id
|
12
|
+
@source.get('revision_id').to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_revision(object)
|
16
|
+
object.class
|
17
|
+
.revision_fields
|
18
|
+
.each_with_object({}) { |field, revision|
|
19
|
+
revision[field] = object.send(field)
|
20
|
+
}.tap { |revision|
|
21
|
+
revision[:id] = revision_id + 1
|
22
|
+
revision[:created_at] = @clock.now
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def notify_save
|
27
|
+
@source.incr 'revision_id'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/cooper/version.rb
CHANGED
data/lib/cooper.rb
CHANGED
@@ -1,34 +1,10 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
require 'redis'
|
3
|
+
|
1
4
|
require 'cooper/version'
|
2
|
-
require 'cooper/
|
5
|
+
require 'cooper/document'
|
6
|
+
require 'cooper/revision_source'
|
3
7
|
|
4
|
-
# Cooper Database Engine Module
|
5
8
|
module Cooper
|
6
|
-
|
7
|
-
datastore(&:reset)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.read(revision)
|
11
|
-
datastore do |datastore|
|
12
|
-
datastore.read(revision)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.update(changes)
|
17
|
-
datastore do |datastore|
|
18
|
-
datastore << changes
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.delete(attribute)
|
23
|
-
update(attribute => nil)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def self.datastore
|
29
|
-
datastore = DataStore.open
|
30
|
-
yield(datastore)
|
31
|
-
ensure
|
32
|
-
datastore.close
|
33
|
-
end
|
9
|
+
REVISION_SOURCE = RevisionSource.new
|
34
10
|
end
|
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cooper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.1.0.pre.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Efflam Castel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: mongoid
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '5.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '5.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: redis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.3'
|
34
34
|
type: :runtime
|
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: '
|
40
|
+
version: '3.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.12'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.12'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '11.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '11.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: guard-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.7'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '4.7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: guard-rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,58 +95,49 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.2'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.6'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.6'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: aruba-rspec
|
98
|
+
name: codeclimate-test-reporter
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '0.5'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
125
|
-
description:
|
126
|
-
email:
|
127
|
-
|
128
|
-
|
110
|
+
version: '0.5'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- efflamm.castel@gmail.com
|
114
|
+
executables: []
|
129
115
|
extensions: []
|
130
116
|
extra_rdoc_files: []
|
131
117
|
files:
|
132
118
|
- ".gitignore"
|
133
119
|
- ".rspec"
|
134
120
|
- ".rubocop.yml"
|
121
|
+
- ".travis.yml"
|
135
122
|
- CODE_OF_CONDUCT.md
|
136
123
|
- Gemfile
|
137
124
|
- Guardfile
|
138
125
|
- LICENSE.md
|
139
126
|
- README.md
|
140
|
-
-
|
141
|
-
- cooper
|
127
|
+
- Rakefile
|
142
128
|
- cooper.gemspec
|
129
|
+
- features/mongoid_configuration_spec.rb
|
130
|
+
- features/revisioning_spec.rb
|
131
|
+
- features/validations_spec.rb
|
143
132
|
- lib/cooper.rb
|
144
|
-
- lib/cooper/
|
133
|
+
- lib/cooper/document.rb
|
134
|
+
- lib/cooper/revision_source.rb
|
145
135
|
- lib/cooper/version.rb
|
146
|
-
homepage:
|
136
|
+
homepage: https://github.com/floum/cooper
|
147
137
|
licenses:
|
148
138
|
- MIT
|
149
|
-
metadata:
|
139
|
+
metadata:
|
140
|
+
allowed_push_host: https://rubygems.org
|
150
141
|
post_install_message:
|
151
142
|
rdoc_options: []
|
152
143
|
require_paths:
|
@@ -155,16 +146,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
146
|
requirements:
|
156
147
|
- - ">="
|
157
148
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
149
|
+
version: '2.3'
|
159
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
151
|
requirements:
|
161
|
-
- - "
|
152
|
+
- - ">"
|
162
153
|
- !ruby/object:Gem::Version
|
163
|
-
version:
|
154
|
+
version: 1.3.1
|
164
155
|
requirements: []
|
165
156
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.5.1
|
167
158
|
signing_key:
|
168
159
|
specification_version: 4
|
169
|
-
summary:
|
160
|
+
summary: a revision database system built upon mongoid
|
170
161
|
test_files: []
|
data/bin/cooper
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'thor'
|
3
|
-
require 'json'
|
4
|
-
require 'cooper'
|
5
|
-
|
6
|
-
# the Thor class for the cooper command-line interface
|
7
|
-
class CooperCLI < Thor
|
8
|
-
map '-v' => 'version'
|
9
|
-
|
10
|
-
desc 'version', 'prints the version'
|
11
|
-
def version
|
12
|
-
puts "Cooper v#{Cooper::VERSION}"
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'reset', 'resets the cooper item'
|
16
|
-
def reset
|
17
|
-
Cooper.reset
|
18
|
-
end
|
19
|
-
|
20
|
-
desc 'update ATTRIBUTES', 'update the cooper item'
|
21
|
-
def update(*attributes)
|
22
|
-
changes = Hash[attributes.map { |attribute| attribute.split(':') }]
|
23
|
-
Cooper.update(changes)
|
24
|
-
end
|
25
|
-
|
26
|
-
desc 'read', 'read the cooper item'
|
27
|
-
method_option :at, type: :numeric, default: -1
|
28
|
-
def read
|
29
|
-
puts Cooper.read(options[:at]).to_json
|
30
|
-
end
|
31
|
-
|
32
|
-
desc 'rm ATTRIBUTE', 'removes the attribute from the cooper item'
|
33
|
-
def rm(attribute)
|
34
|
-
Cooper.delete(attribute)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
CooperCLI.start(ARGV)
|
data/cooper
DELETED
File without changes
|
data/lib/cooper/datastore.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Cooper
|
2
|
-
# Interface class for the cooper data store
|
3
|
-
class DataStore < File
|
4
|
-
LOCATION = "#{ENV['HOME']}/.cooper_item"
|
5
|
-
|
6
|
-
def self.open
|
7
|
-
super(LOCATION, 'a+')
|
8
|
-
end
|
9
|
-
|
10
|
-
def reset
|
11
|
-
truncate(0)
|
12
|
-
end
|
13
|
-
|
14
|
-
def <<(attributes)
|
15
|
-
puts attributes.to_json
|
16
|
-
end
|
17
|
-
|
18
|
-
def read(revision)
|
19
|
-
readlines[0..revision]
|
20
|
-
.each_with_object({}) { |line, item| item.merge!(JSON.parse(line)) }
|
21
|
-
.reject { |_, v| v.nil? }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|