mince_data_model 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,50 @@
1
-
2
1
  # What Iz Mince Data Model?
3
2
 
4
- Some niceties and defines an implementation to swap out different data persistance strategies. Currently there are 2 supported data persistance strategies: Mince (MongoDB), and HashyDB (in memory hash). If using this gem, all you need to do in order to change the data persistence strategy is to implement the methods outlined by this gem. Check out the [Mince Data Store](https://github.com/asynchrony/mince/blob/master/lib/mince/data_store.rb) and the [HashyDB Data Store](https://github.com/asynchrony/HashyDB/blob/master/lib/hashy_db/data_store.rb) for a list of methods to implement.
3
+ Mince Data Model provides the ability to switch between different databases for different environments.
4
+
5
+ It supports the following data stores:
6
+
7
+ - [mince_dynamo_db](https://github.com/coffeencoke/mince_dynamo_db) - Stores and retrieves data from Amazon's DynamoDB
8
+ - [mince](https://github.com/asynchrony/mince) - Stores and retrieves data from MongoDB
9
+ - [hashy_db](https://github.com/asynchrony/hashy_db) - Stores and retrieves data from a hash in-memory.
10
+
11
+ By creating some niceties and an implementation to swap out different data persistance strategies.
12
+
13
+ # How To Use
14
+
15
+ ## Create a data model class
16
+
17
+ ```ruby
18
+ class TronLightCycleDataModel
19
+ include MinceDataModel
20
+
21
+ # Name of the collection or table to store the data
22
+ data_collection :light_cycles
23
+
24
+ # The fields or columns this data model can have
25
+ data_fields :luminating_color, :rezzed, :jetwall, :grid_locked
26
+ end
27
+ ```
28
+
29
+ ## Set the data store to use
30
+
31
+ ```ruby
32
+ Rails.application.config.data_store = 'mince_dynamo_db/data_store'
33
+ ```
34
+ You must have the data store gem installed.
35
+
36
+ ## Start storing and retrieving data
37
+
38
+ ```ruby
39
+ TronLightCycleDataModel.store(model)
40
+ TronLightCycleDataModel.find(1)
41
+ TronLightCycleDataModel.all
42
+ TronLightCycleDataModel.all_by_field(:grid_locked, true)
43
+ TronLightCycleDataModel.update_field_with_value('some_cycle_id_123', :grid_locked, false)
44
+ TronLightCycleDataModel.all_by_fields(grid_locked: true, luminating_color: 'red')
45
+ ```
46
+
47
+ There are also other [ways to set the data store](https://github.com/asynchrony/mince_data_model/wiki/ways-to-set-the-data-store)
5
48
 
6
49
  # Why?
7
50
 
@@ -42,3 +85,12 @@ The motivation behind this is so you can clone the repository down, have ruby in
42
85
 
43
86
  [@github](https://github.com/asynchrony/hashy_db)
44
87
  [@rubygems](https://rubygems.org/gems/hashy_db)
88
+
89
+ # Mince DynamoDb
90
+
91
+ Provides an interface for storing and retreiving information in Amazon's DynamoDB.
92
+
93
+ It's almost impossible to develop an application using DynamoDB in development and even harder to use DynamoDb in a test environment. This allows you to switch your application to DynamoDB only in production mode.
94
+
95
+ [@github](https://github.com/coffeencoke/mince_dynamo_db)
96
+ [@rubygems](https://rubygems.org/gems/mince_dynamo_db)
@@ -1,3 +1,3 @@
1
1
  module MinceDataModel
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -41,6 +41,10 @@ module MinceDataModel
41
41
  end
42
42
  end
43
43
 
44
+ def update_field_with_value(id, field, value)
45
+ data_store.instance.update_field_with_value(data_collection, id, field, value)
46
+ end
47
+
44
48
  def remove_from_array(id, field, value)
45
49
  data_store.instance.remove_from_array(data_collection, data_store.primary_key_identifier, id, field, value)
46
50
  end
@@ -167,4 +171,4 @@ module MinceDataModel
167
171
  def field_exists?(field)
168
172
  model.respond_to?(field) && !model.send(field).nil?
169
173
  end
170
- end
174
+ end
@@ -45,6 +45,16 @@ shared_examples_for 'a data model' do
45
45
  end
46
46
  end
47
47
 
48
+ describe 'updating a specific field for a data model' do
49
+ let(:data_model_id) { '1234567' }
50
+
51
+ it 'has the data store update the field' do
52
+ mock_data_store.should_receive(:update_field_with_value).with(collection_name, data_model_id, :some_field, 'some value')
53
+
54
+ described_class.update_field_with_value(data_model_id, :some_field, 'some value')
55
+ end
56
+ end
57
+
48
58
  describe "pushing a value to an array for a data model" do
49
59
  let(:data_model_id) { '1234567' }
50
60
 
@@ -162,4 +172,4 @@ shared_examples_for 'a data model' do
162
172
  described_class.find(mock_data_model[:id]).should == HashWithIndifferentAccess.new(mock_data_model)
163
173
  end
164
174
  end
165
- end
175
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mince_data_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-03-03 00:00:00.000000000 Z
14
+ date: 2012-04-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &70291511198100 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: '0'
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *70291511198100
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: rake
29
- requirement: &70291511197560 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ! '>='
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '0'
35
40
  type: :development
36
41
  prerelease: false
37
- version_requirements: *70291511197560
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: rails
40
- requirement: &70291511196880 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ~>
@@ -45,7 +55,12 @@ dependencies:
45
55
  version: '3.0'
46
56
  type: :runtime
47
57
  prerelease: false
48
- version_requirements: *70291511196880
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '3.0'
49
64
  description: Interface for interchanging which type of data store to persist data
50
65
  to
51
66
  email:
@@ -57,7 +72,6 @@ extra_rdoc_files: []
57
72
  files:
58
73
  - .gitignore
59
74
  - .rspec
60
- - .rvmrc
61
75
  - Gemfile
62
76
  - README.md
63
77
  - Rakefile
@@ -90,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
104
  version: '0'
91
105
  requirements: []
92
106
  rubyforge_project: mince_data_model
93
- rubygems_version: 1.8.10
107
+ rubygems_version: 1.8.21
94
108
  signing_key:
95
109
  specification_version: 3
96
110
  summary: Interface for interchanging which type of data store to persist data to
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3@mince_data_model --create