couch_potato 1.6.5 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGES.md +29 -0
- data/couch_potato-rspec.gemspec +1 -1
- data/lib/couch_potato/persistence.rb +5 -2
- data/lib/couch_potato/persistence/revisions.rb +14 -0
- data/lib/couch_potato/railtie.rb +1 -1
- data/lib/couch_potato/version.rb +2 -2
- data/spec/railtie_spec.rb +7 -1
- data/spec/revisions_spec.rb +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f6ff4ae48fa386a7c210a840f7bc2e5504e812
|
4
|
+
data.tar.gz: e3cc6d272dab7679b7766bb96a0b9cdf557ad2b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8ec9aba049750bc2d18053ba05633d4a593d6fd7e44f002746dd629d2fd8c4ad6297228f549b9653d60ad9a54e410ad6334aa6356c1d3a2d6825b102241cb43
|
7
|
+
data.tar.gz: 1b9106d793d8874f32345492ad25aac13a1a3817df7af885d3f084117c7c9a8a34f7fbcd3eca834ee0b62cb4f2d20c9b86fbcdb015979e20712475dd0b9f383e
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
## Changes
|
2
2
|
|
3
|
+
### 1.7.0
|
4
|
+
|
5
|
+
* added `_revisions` method that returns all available revisions of a document.
|
6
|
+
|
7
|
+
### 1.6.4
|
8
|
+
|
9
|
+
* bug fix for accessing inherited properties (Alexander Lang)
|
10
|
+
|
11
|
+
### 1.6.3
|
12
|
+
|
13
|
+
* added ActiveSupport instrumentation (Alexander Lang)
|
14
|
+
|
15
|
+
### 1.6.2
|
16
|
+
|
17
|
+
* view digest bugfix (Alexander Lang)
|
18
|
+
|
19
|
+
### 1.6.1
|
20
|
+
|
21
|
+
* added option to add digests to a single view (Alexander Lang)
|
22
|
+
|
23
|
+
### 1.6.0
|
24
|
+
|
25
|
+
* added global option to add digests to view names (Alexander Lang)
|
26
|
+
|
27
|
+
### 1.5.1
|
28
|
+
|
29
|
+
* updated CouchRest to 2.0.0.rc3 in order to re-use http connections. Performance improvements. (Thilo Utke)
|
30
|
+
* added passing params to lists (Alexander Lang)
|
31
|
+
|
3
32
|
### 1.5.0
|
4
33
|
|
5
34
|
* Moved RSpec matchers into couch_potato-rspec gem. This way, people not using RSpec don't need to install the helpers, plus we can release separate matchers for RSpec 2 and 3.
|
data/couch_potato-rspec.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.version = CouchPotato::RSPEC_VERSION
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
13
|
|
14
|
-
s.add_dependency 'rspec', '~>3.
|
14
|
+
s.add_dependency 'rspec', '~>3.4'
|
15
15
|
s.add_development_dependency 'rake'
|
16
16
|
|
17
17
|
s.files = `git ls-files | grep "lib/couch_potato/rspec"`.split("\n")
|
@@ -10,6 +10,7 @@ require File.dirname(__FILE__) + '/persistence/deep_dirty_attributes'
|
|
10
10
|
require File.dirname(__FILE__) + '/persistence/ghost_attributes'
|
11
11
|
require File.dirname(__FILE__) + '/persistence/attachments'
|
12
12
|
require File.dirname(__FILE__) + '/persistence/type_caster'
|
13
|
+
require File.dirname(__FILE__) + '/persistence/revisions'
|
13
14
|
require File.dirname(__FILE__) + '/forbidden_attributes_protection'
|
14
15
|
require File.dirname(__FILE__) + '/view/custom_views'
|
15
16
|
require File.dirname(__FILE__) + '/view/lists'
|
@@ -20,9 +21,11 @@ module CouchPotato
|
|
20
21
|
module Persistence
|
21
22
|
|
22
23
|
def self.included(base) #:nodoc:
|
23
|
-
base.send :include, Properties, Callbacks, Json, CouchPotato::View::CustomViews,
|
24
|
+
base.send :include, Properties, Callbacks, Json, CouchPotato::View::CustomViews,
|
25
|
+
CouchPotato::View::Lists
|
24
26
|
base.send :include, DirtyAttributes, GhostAttributes, Attachments
|
25
|
-
base.send :include, MagicTimestamps, ActiveModelCompliance,
|
27
|
+
base.send :include, MagicTimestamps, ActiveModelCompliance,
|
28
|
+
ForbiddenAttributesProtection, Revisions
|
26
29
|
base.send :include, Validation
|
27
30
|
base.class_eval do
|
28
31
|
attr_accessor :_id, :_rev, :_deleted, :database
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CouchPotato
|
2
|
+
module Persistence
|
3
|
+
module Revisions
|
4
|
+
# returns all available revisions of a document, first to last.
|
5
|
+
# causes n+1 requests. do not use in production code.
|
6
|
+
def _revisions
|
7
|
+
with_revs = database.couchrest_database.get(id, revs: true, revs_info: true)._document
|
8
|
+
revs_info = with_revs[:_revs_info]
|
9
|
+
revs = revs_info.select {|info| info[:status] == 'available' }.map {|info| info[:rev] }
|
10
|
+
revs.reverse.map {|rev| database.couchrest_database.get(id, rev: rev) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/couch_potato/railtie.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../rails/reload_classes')
|
2
1
|
require 'erb'
|
3
2
|
|
4
3
|
module CouchPotato
|
5
4
|
def self.rails_init
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rails/reload_classes') if Rails.env.development?
|
6
6
|
path = Rails.root.join('config/couchdb.yml')
|
7
7
|
if File.exist?(path)
|
8
8
|
require 'yaml'
|
data/lib/couch_potato/version.rb
CHANGED
data/spec/railtie_spec.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CouchPotato::Persistence::Revisions, '#_revisions' do
|
4
|
+
let(:db) { CouchPotato.database }
|
5
|
+
|
6
|
+
class Thing
|
7
|
+
include CouchPotato::Persistence
|
8
|
+
|
9
|
+
property :title
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
recreate_db
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns all available revisions of a document' do
|
17
|
+
thing = Thing.new title: 't1'
|
18
|
+
db.save! thing
|
19
|
+
thing.title = 't2'
|
20
|
+
db.save! thing
|
21
|
+
|
22
|
+
expect(thing._revisions.map(&:title)).to eq(%w(t1 t2))
|
23
|
+
expect(thing._revisions.map {|t| t._rev[0, 1].to_i }).to eq([1, 2])
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_potato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/couch_potato/persistence/json.rb
|
147
147
|
- lib/couch_potato/persistence/magic_timestamps.rb
|
148
148
|
- lib/couch_potato/persistence/properties.rb
|
149
|
+
- lib/couch_potato/persistence/revisions.rb
|
149
150
|
- lib/couch_potato/persistence/simple_property.rb
|
150
151
|
- lib/couch_potato/persistence/type_caster.rb
|
151
152
|
- lib/couch_potato/railtie.rb
|
@@ -172,6 +173,7 @@ files:
|
|
172
173
|
- spec/rails_spec.rb
|
173
174
|
- spec/railtie_spec.rb
|
174
175
|
- spec/reload_spec.rb
|
176
|
+
- spec/revisions_spec.rb
|
175
177
|
- spec/spec.opts
|
176
178
|
- spec/spec_helper.rb
|
177
179
|
- spec/unit/active_model_compliance_spec.rb
|
@@ -238,6 +240,7 @@ test_files:
|
|
238
240
|
- spec/rails_spec.rb
|
239
241
|
- spec/railtie_spec.rb
|
240
242
|
- spec/reload_spec.rb
|
243
|
+
- spec/revisions_spec.rb
|
241
244
|
- spec/spec.opts
|
242
245
|
- spec/spec_helper.rb
|
243
246
|
- spec/unit/active_model_compliance_spec.rb
|