kvom 6.8.0.beta.200.621.4c8e1b0 → 6.8.0.beta.200.650.7c93155

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,13 @@
1
- require "kvom/adapter/base"
2
- require "kvom/document"
3
- require "kvom/base"
1
+ module Kvom
2
+ # :nodoc:
3
+ def self.setup_autoload(mod, mod_source)
4
+ dir = File.expand_path(".", mod_source)[0..-4]
5
+ pattern = "#{dir}/*.rb"
6
+ Dir.glob(pattern).each do |file|
7
+ const = file[dir.length..-4].gsub(%r{[_/](.)}) {$1.upcase}
8
+ mod.autoload const.to_sym, file
9
+ end
10
+ end
11
+
12
+ setup_autoload(self, __FILE__)
13
+ end
@@ -0,0 +1,5 @@
1
+ module Kvom
2
+ module Adapter
3
+ Kvom.setup_autoload(self, __FILE__)
4
+ end
5
+ end
@@ -39,5 +39,4 @@ class Base
39
39
 
40
40
  end
41
41
 
42
- end ; end # module Kvom
43
-
42
+ end; end # module Kvom::Adapter
@@ -1,9 +1,8 @@
1
1
  require 'couchrest'
2
- require 'kvom/adapter/couchdb_document'
3
2
 
4
3
  module Kvom; module Adapter
5
4
 
6
- class CouchdbAdapter < Kvom::Adapter::Base
5
+ class CouchdbAdapter < Base
7
6
  def new_document(key, attributes)
8
7
  new_document_from_attributes(attributes.merge("_id" => key))
9
8
  end
@@ -79,4 +78,4 @@ class CouchdbAdapter < Kvom::Adapter::Base
79
78
 
80
79
  end
81
80
 
82
- end ; end # module Kvom
81
+ end; end # module Kvom::Adapter
@@ -1,6 +1,6 @@
1
1
  module Kvom; module Adapter
2
2
 
3
- class CouchdbDocument < Document
3
+ class ::CouchdbDocument < Kvom::Document
4
4
  attr_accessor :couchrest_document
5
5
 
6
6
  def initialize(couchrest_document)
@@ -20,4 +20,4 @@ class CouchdbDocument < Document
20
20
  end
21
21
  end
22
22
 
23
- end ; end # module Kvom
23
+ end; end # module Kvom
@@ -1,9 +1,8 @@
1
1
  require 'aws-sdk'
2
- require 'kvom/adapter/dynamodb_document'
3
2
 
4
3
  module Kvom; module Adapter
5
4
 
6
- class DynamodbAdapter < Kvom::Adapter::Base
5
+ class DynamodbAdapter < Base
7
6
  def new_document(key, attributes = nil)
8
7
  DynamodbDocument.new_document(attributes, key, item_for_key(key))
9
8
  end
@@ -113,4 +112,4 @@ class DynamodbAdapter < Kvom::Adapter::Base
113
112
 
114
113
  end
115
114
 
116
- end ; end # module Kvom
115
+ end; end # module Kvom::Adapter
@@ -153,4 +153,4 @@ class DynamodbDocument < Document
153
153
  end
154
154
  end
155
155
 
156
- end ; end # module Kvom
156
+ end; end # module Kvom::Adapter
@@ -4,16 +4,8 @@ require 'active_support/core_ext/class/attribute'
4
4
  require 'active_model/naming'
5
5
  require 'securerandom'
6
6
 
7
- require 'kvom/model_identity'
8
-
9
7
  module Kvom
10
8
 
11
- class NotFound < ::StandardError
12
- def self.for_key(key)
13
- new(%(document with key "#{key}" not found))
14
- end
15
- end
16
-
17
9
  class Base
18
10
  include ModelIdentity
19
11
  extend ActiveModel::Naming
@@ -113,4 +105,3 @@ class Base
113
105
  end
114
106
 
115
107
  end # module Kvom
116
-
@@ -1,6 +1,4 @@
1
- module Kvom
2
-
3
- class Document
1
+ class Kvom::Document
4
2
  def key
5
3
  raise "implement me in subclass!"
6
4
  end
@@ -13,5 +11,3 @@ class Document
13
11
  raise "implement me in subclass!"
14
12
  end
15
13
  end
16
-
17
- end # module Kvom
@@ -0,0 +1,5 @@
1
+ class Kvom::NotFound < ::StandardError
2
+ def self.for_key(key)
3
+ new(%(document with key "#{key}" not found))
4
+ end
5
+ end
@@ -1,7 +1,5 @@
1
1
  require "spec_helper"
2
2
 
3
- require "kvom/model_identity"
4
-
5
3
  describe Kvom::ModelIdentity do
6
4
  class IdTest
7
5
  include Kvom::ModelIdentity
@@ -9,16 +9,15 @@ class TestModel < Kvom::Base
9
9
  @adapter ||=
10
10
  case (type = ENV['KVOM_ADAPTER_TYPE'] || "couch")
11
11
  when "couch"
12
- require "kvom/adapter/couchdb_adapter"
13
12
  require 'multi_json'
14
13
  MultiJson.engine = :yajl
15
14
  database_name = "kvom-unit_tests"
16
- CouchRest.database!(database_name)
17
- Kvom::Adapter::CouchdbAdapter.new({
15
+ adapter = Kvom::Adapter::CouchdbAdapter.new({
18
16
  :url => database_name,
19
17
  })
18
+ CouchRest.database!(database_name)
19
+ adapter
20
20
  when /dynamo/
21
- require "kvom/adapter/dynamodb_adapter"
22
21
  require File.expand_path("../../../tasks/support/local_config", __FILE__)
23
22
  options = {
24
23
  :table => "test-kvom",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kvom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15922107031
4
+ hash: 6553831203
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 6
@@ -9,15 +9,11 @@ version: !ruby/object:Gem::Version
9
9
  - 0
10
10
  - beta
11
11
  - 200
12
- - 621
13
- - 4
12
+ - 650
13
+ - 7
14
14
  - c
15
- - 8
16
- - e
17
- - 1
18
- - b
19
- - 0
20
- version: 6.8.0.beta.200.621.4c8e1b0
15
+ - 93155
16
+ version: 6.8.0.beta.200.650.7c93155
21
17
  platform: ruby
22
18
  authors:
23
19
  - Kristian Hanekamp, Infopark AG
@@ -25,7 +21,7 @@ autorequire:
25
21
  bindir: bin
26
22
  cert_chain: []
27
23
 
28
- date: 2012-04-18 00:00:00 +02:00
24
+ date: 2012-06-01 00:00:00 +02:00
29
25
  default_executable:
30
26
  dependencies:
31
27
  - !ruby/object:Gem::Dependency
@@ -38,10 +34,10 @@ dependencies:
38
34
  segments:
39
35
  - 0
40
36
  version: "0"
37
+ version_requirements: *id001
38
+ name: rspec
41
39
  prerelease: false
42
40
  type: :development
43
- name: rspec
44
- version_requirements: *id001
45
41
  - !ruby/object:Gem::Dependency
46
42
  requirement: &id002 !ruby/object:Gem::Requirement
47
43
  none: false
@@ -52,10 +48,10 @@ dependencies:
52
48
  segments:
53
49
  - 0
54
50
  version: "0"
51
+ version_requirements: *id002
52
+ name: helpful_configuration
55
53
  prerelease: false
56
54
  type: :development
57
- name: helpful_configuration
58
- version_requirements: *id002
59
55
  - !ruby/object:Gem::Dependency
60
56
  requirement: &id003 !ruby/object:Gem::Requirement
61
57
  none: false
@@ -66,10 +62,10 @@ dependencies:
66
62
  segments:
67
63
  - 0
68
64
  version: "0"
65
+ version_requirements: *id003
66
+ name: couchrest
69
67
  prerelease: false
70
68
  type: :runtime
71
- name: couchrest
72
- version_requirements: *id003
73
69
  - !ruby/object:Gem::Dependency
74
70
  requirement: &id004 !ruby/object:Gem::Requirement
75
71
  none: false
@@ -80,10 +76,10 @@ dependencies:
80
76
  segments:
81
77
  - 0
82
78
  version: "0"
79
+ version_requirements: *id004
80
+ name: activemodel
83
81
  prerelease: false
84
82
  type: :runtime
85
- name: activemodel
86
- version_requirements: *id004
87
83
  - !ruby/object:Gem::Dependency
88
84
  requirement: &id005 !ruby/object:Gem::Requirement
89
85
  none: false
@@ -94,10 +90,10 @@ dependencies:
94
90
  segments:
95
91
  - 0
96
92
  version: "0"
93
+ version_requirements: *id005
94
+ name: aws-sdk
97
95
  prerelease: false
98
96
  type: :runtime
99
- name: aws-sdk
100
- version_requirements: *id005
101
97
  description: Use it to build object models in ruby on top of a key value store.
102
98
  email:
103
99
  - kristian.hanekamp@infopark.de
@@ -113,6 +109,7 @@ files:
113
109
  - Rakefile
114
110
  - kvom.gemspec
115
111
  - lib/kvom.rb
112
+ - lib/kvom/adapter.rb
116
113
  - lib/kvom/adapter/base.rb
117
114
  - lib/kvom/adapter/couchdb_adapter.rb
118
115
  - lib/kvom/adapter/couchdb_document.rb
@@ -121,6 +118,7 @@ files:
121
118
  - lib/kvom/base.rb
122
119
  - lib/kvom/document.rb
123
120
  - lib/kvom/model_identity.rb
121
+ - lib/kvom/not_found.rb
124
122
  - spec/base_spec.rb
125
123
  - spec/counter_spec.rb
126
124
  - spec/model_identity_spec.rb