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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb87904642066e6bd25f1c9b3d295585c3d86b1e
4
- data.tar.gz: 29f8a8ed4a2ec60aecbaf6016fad82886d218e6a
3
+ metadata.gz: 30f6ff4ae48fa386a7c210a840f7bc2e5504e812
4
+ data.tar.gz: e3cc6d272dab7679b7766bb96a0b9cdf557ad2b3
5
5
  SHA512:
6
- metadata.gz: 51598af7041ac68900fcf6b6c831e2e56d6768e1118ee13b6ff967366754211495e7b62876d7d7ff855b9be9ec511ef1413df75b0409159ea793091228b2423f
7
- data.tar.gz: 7abe60420501451dbcb9b461168eb5f7f4ff86c7064243d28f4c31a510e37c783695e4304fb6ce6ba731bb1f911cecc4bdbc2acc68e7cd4c86ff56682bce3c09
6
+ metadata.gz: d8ec9aba049750bc2d18053ba05633d4a593d6fd7e44f002746dd629d2fd8c4ad6297228f549b9653d60ad9a54e410ad6334aa6356c1d3a2d6825b102241cb43
7
+ data.tar.gz: 1b9106d793d8874f32345492ad25aac13a1a3817df7af885d3f084117c7c9a8a34f7fbcd3eca834ee0b62cb4f2d20c9b86fbcdb015979e20712475dd0b9f383e
data/.travis.yml CHANGED
@@ -2,6 +2,7 @@ rvm:
2
2
  - 2.0.0
3
3
  - 2.1.2
4
4
  - 2.2.2
5
+ - 2.3.0
5
6
  - jruby-9.0.1.0
6
7
  - rbx-2.5.8
7
8
  services:
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.
@@ -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.0'
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, CouchPotato::View::Lists
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, ForbiddenAttributesProtection
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
@@ -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'
@@ -1,4 +1,4 @@
1
1
  module CouchPotato
2
- VERSION = '1.6.5'
3
- RSPEC_VERSION = '3.0.0'
2
+ VERSION = '1.7.0'.freeze
3
+ RSPEC_VERSION = '3.4.0'.freeze
4
4
  end
data/spec/railtie_spec.rb CHANGED
@@ -2,8 +2,14 @@ require 'spec_helper'
2
2
  require 'yaml'
3
3
 
4
4
  module Rails
5
+ class Env < String
6
+ def development?
7
+ true
8
+ end
9
+ end
10
+
5
11
  def self.env
6
- 'test'
12
+ Env.new 'test'
7
13
  end
8
14
 
9
15
  class Railtie
@@ -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.6.5
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-16 00:00:00.000000000 Z
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