couch_rest_adapter 0.4.6 → 0.4.7
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/README.rdoc +19 -1
- data/lib/couch_rest_adapter.rb +1 -1
- data/lib/couch_rest_adapter/query_views.rb +3 -5
- data/lib/couch_rest_adapter/version.rb +1 -1
- data/test/dummy/log/test.log +60 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afd6f67968cdc04eeb35048d9b6b2a8b2ba6aaa0
|
4
|
+
data.tar.gz: 32c3d327829c207be8c6078c67cda1fcc6ad5418
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979e357abd7c55fc6bc1d8d1364984cf3f6aa7ff4c55d45ed7c1ba100517be6f0e2d3096c16d84b57fbfcb466ae7d7c27ca90a12d8eb1f81e202ad32c7d91a03
|
7
|
+
data.tar.gz: f4d4fd53b85da4244219acecb87956dda25596f321175bade53036d83c16501a45b43978ad8288b64e69c62fd5d658aaab974e55220d7504e657d91eb1748253
|
data/README.rdoc
CHANGED
@@ -13,12 +13,17 @@ This project rocks and uses MIT-LICENSE.
|
|
13
13
|
|
14
14
|
== Instalation
|
15
15
|
|
16
|
+
Right now there will be a conflict if you use it as it is mixed with ActoveRecord,
|
17
|
+
so you should create your reails project without AR, as in <tt>rails new my_app -O</tt>
|
18
|
+
|
16
19
|
=== In Gemfile
|
17
20
|
|
18
21
|
gem 'couch_rest_adapter'
|
19
22
|
|
20
23
|
=== Sample config/database.yml
|
21
24
|
|
25
|
+
All this are required attributes.
|
26
|
+
|
22
27
|
defaults: &defaults
|
23
28
|
host: localhost
|
24
29
|
port: 5984
|
@@ -58,7 +63,20 @@ with the next structure:
|
|
58
63
|
}
|
59
64
|
|
60
65
|
|
61
|
-
|
66
|
+
You can add more views as needed into ```db/designs/``` folder.
|
67
|
+
|
68
|
+
This is how the designs are delcared:
|
69
|
+
|
70
|
+
db
|
71
|
+
designs
|
72
|
+
my_map_name.map.coffee
|
73
|
+
my_filter_name.filter.coffee
|
74
|
+
my_reduce_name.reduce.coffee
|
75
|
+
|
76
|
+
Then if you run ```rake db:push:design``` the ```_design/my_app`` document will be updated.
|
77
|
+
The views need to be written on coffeescript code.
|
78
|
+
|
79
|
+
One thing: this will allow you to add tests to your couch views ;-)
|
62
80
|
|
63
81
|
=== Model Declaration
|
64
82
|
|
data/lib/couch_rest_adapter.rb
CHANGED
@@ -10,21 +10,19 @@ module CouchRestAdapter
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
|
14
|
-
DEFAULT_DESIGN = Rails.application.class.to_s.split("::").first.downcase
|
15
13
|
|
16
|
-
def find_by_attribute attr_name, value, doc_name
|
14
|
+
def find_by_attribute attr_name, value, doc_name
|
17
15
|
document_name = 'by_attribute'
|
18
16
|
key_value = [object_name, attr_name, value]
|
19
17
|
view_by_key document_name, key_value, doc_name
|
20
18
|
end
|
21
19
|
|
22
|
-
def query_view name, doc_name
|
20
|
+
def query_view name, doc_name
|
23
21
|
view_by_key name, object_name, doc_name
|
24
22
|
end
|
25
23
|
|
26
24
|
def view_by_key name, key = nil, doc_name = nil
|
27
|
-
doc = name.namespace_me(doc_name
|
25
|
+
doc = name.namespace_me(doc_name)
|
28
26
|
view(doc, {key: key})['rows'].map{ |res| new res['doc'] }
|
29
27
|
end
|
30
28
|
|
data/test/dummy/log/test.log
CHANGED
@@ -2746,3 +2746,63 @@ LintTest: test_to_param
|
|
2746
2746
|
------------------------------
|
2747
2747
|
LintTest: test_to_partial_path
|
2748
2748
|
------------------------------
|
2749
|
+
---------------------------------------------------
|
2750
|
+
CouchRestAdapter::AttributeMethodTest: test_base_id
|
2751
|
+
---------------------------------------------------
|
2752
|
+
-----------------------------------------------------------------------------------------------------------------------
|
2753
|
+
CouchRestAdapter::DocumentManagementTest: test__set_id_and_namespace_will_set_the__id_variable_with_an_id_and_namespace
|
2754
|
+
-----------------------------------------------------------------------------------------------------------------------
|
2755
|
+
---------------------------------------------------------------------------------------------------
|
2756
|
+
CouchRestAdapter::DocumentManagementTest: test_class_method_namespace=_allows_override_of_namespace
|
2757
|
+
---------------------------------------------------------------------------------------------------
|
2758
|
+
---------------------------------------------------------------------------------------------
|
2759
|
+
CouchRestAdapter::DocumentManagementTest: test_class_method_namespace_defaults_to_object_name
|
2760
|
+
---------------------------------------------------------------------------------------------
|
2761
|
+
-----------------------------------------------------------------------------------------------------------
|
2762
|
+
CouchRestAdapter::DocumentManagementTest: test_class_method_object_name_returns_model_name_in_singular_form
|
2763
|
+
-----------------------------------------------------------------------------------------------------------
|
2764
|
+
--------------------------------------------------------------
|
2765
|
+
CouchRestAdapterTest: test_attributes_are_available_as_methods
|
2766
|
+
--------------------------------------------------------------
|
2767
|
+
---------------------------------------------------------
|
2768
|
+
CouchRestAdapterTest: test_can_not_instantiate_base_class
|
2769
|
+
---------------------------------------------------------
|
2770
|
+
---------------------------------------------------------------------------------------------
|
2771
|
+
CouchRestAdapterTest: test_find_by_attr_will_return_array_of_docs_with_type_set_to_model_name
|
2772
|
+
---------------------------------------------------------------------------------------------
|
2773
|
+
---------------------------------------------------------
|
2774
|
+
CouchRestAdapterTest: test_find_will_work_with_partial_id
|
2775
|
+
---------------------------------------------------------
|
2776
|
+
-------------------------------------------------------------
|
2777
|
+
CouchRestAdapterTest: test_one_can_update_existing_attributes
|
2778
|
+
-------------------------------------------------------------
|
2779
|
+
--------------------------------------------------------------------------------------------------
|
2780
|
+
CouchRestAdapterTest: test_query_all_by_type_will_return_array_of_docs_with_type_set_to_model_name
|
2781
|
+
--------------------------------------------------------------------------------------------------
|
2782
|
+
----------------------------------------------------------------------
|
2783
|
+
CouchRestAdapterTest: test_query_all_will_bring_array_of_Foo_instances
|
2784
|
+
----------------------------------------------------------------------
|
2785
|
+
-------------------------------------------------------
|
2786
|
+
CouchRestAdapterTest: test_update_to_attr=_will_persist
|
2787
|
+
-------------------------------------------------------
|
2788
|
+
--------------------------------------------------------------
|
2789
|
+
CouchRestAdapterTest: test_will_add_class_underscorename_to_id
|
2790
|
+
--------------------------------------------------------------
|
2791
|
+
--------------------------
|
2792
|
+
LintTest: test_errors_aref
|
2793
|
+
--------------------------
|
2794
|
+
---------------------------
|
2795
|
+
LintTest: test_model_naming
|
2796
|
+
---------------------------
|
2797
|
+
-------------------------
|
2798
|
+
LintTest: test_persisted?
|
2799
|
+
-------------------------
|
2800
|
+
---------------------
|
2801
|
+
LintTest: test_to_key
|
2802
|
+
---------------------
|
2803
|
+
-----------------------
|
2804
|
+
LintTest: test_to_param
|
2805
|
+
-----------------------
|
2806
|
+
------------------------------
|
2807
|
+
LintTest: test_to_partial_path
|
2808
|
+
------------------------------
|