query_string_interface 0.1.0 → 0.2.0
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.
- data/README.md +48 -0
- data/lib/query_string_interface/filter.rb +11 -1
- data/lib/query_string_interface/version.rb +1 -1
- metadata +4 -6
- data/README.rdoc +0 -44
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Overview [![build status][1]][2]
|
2
|
+
|
3
|
+
[1]: https://secure.travis-ci.org/vicentemundim/query_string_interface.png
|
4
|
+
[2]: http://travis-ci.org/#!/vicentemundim/query_string_interface
|
5
|
+
|
6
|
+
### About QueryStringInterace
|
7
|
+
|
8
|
+
This gem extracts params given as a hash to structured data, that can be used when creating queries
|
9
|
+
|
10
|
+
### Repository
|
11
|
+
|
12
|
+
http://github.com/vicentemundim/query_string_interface
|
13
|
+
|
14
|
+
## Installing
|
15
|
+
|
16
|
+
This is a gem, so you can install it by:
|
17
|
+
|
18
|
+
sudo gem install query_string_interface
|
19
|
+
|
20
|
+
Or, if you are using rails, put this in your Gemfile:
|
21
|
+
|
22
|
+
gem 'query_string_interface'
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
To use it, just extend QueryStringInterface in your document model:
|
27
|
+
|
28
|
+
class Document
|
29
|
+
include Mongoid::Document
|
30
|
+
extend QueryInterfaceString
|
31
|
+
|
32
|
+
# ... add fields here
|
33
|
+
end
|
34
|
+
|
35
|
+
Then, you can use some class methods with your ORM syntax:
|
36
|
+
|
37
|
+
def self.filter_by(params)
|
38
|
+
where(filtering_options(params)).order_by(*sorting_options(params))
|
39
|
+
end
|
40
|
+
|
41
|
+
# ORM Adapters
|
42
|
+
|
43
|
+
http://github.com/vicentemundim/mongoid_query_string_interface
|
44
|
+
|
45
|
+
# Credits
|
46
|
+
|
47
|
+
- Vicente Mundim: vicente.mundim at gmail dot com
|
48
|
+
- Wandenberg Peixoto: wandenberg at gmail dot com
|
@@ -114,7 +114,9 @@ module QueryStringInterface
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def json_value
|
117
|
-
raw_or_data =
|
117
|
+
raw_or_data = disable_active_support_datetime_parsing do
|
118
|
+
ActiveSupport::JSON.decode(unescaped_raw_value)
|
119
|
+
end
|
118
120
|
|
119
121
|
raise "$or query filters must be given as an array of hashes" unless valid_or_filters?(raw_or_data)
|
120
122
|
|
@@ -123,6 +125,14 @@ module QueryStringInterface
|
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
128
|
+
def disable_active_support_datetime_parsing
|
129
|
+
old_value = ActiveSupport.parse_json_times
|
130
|
+
ActiveSupport.parse_json_times = false
|
131
|
+
result = yield
|
132
|
+
ActiveSupport.parse_json_times = old_value
|
133
|
+
result
|
134
|
+
end
|
135
|
+
|
126
136
|
def valid_or_filters?(raw_or_data)
|
127
137
|
raw_or_data.is_a?(Array) and raw_or_data.all? { |item| item.is_a?(Hash) }
|
128
138
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: query_string_interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Vicente Mundim
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-12-07 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: activesupport
|
@@ -58,10 +57,9 @@ files:
|
|
58
57
|
- lib/query_string_interface/version.rb
|
59
58
|
- lib/query_string_interface.rb
|
60
59
|
- MIT_LICENSE
|
61
|
-
- README.
|
60
|
+
- README.md
|
62
61
|
- Gemfile
|
63
62
|
- Gemfile.lock
|
64
|
-
has_rdoc: true
|
65
63
|
homepage: ""
|
66
64
|
licenses: []
|
67
65
|
|
@@ -85,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
83
|
requirements: []
|
86
84
|
|
87
85
|
rubyforge_project: query_string_interface
|
88
|
-
rubygems_version: 1.
|
86
|
+
rubygems_version: 1.8.10
|
89
87
|
signing_key:
|
90
88
|
specification_version: 3
|
91
89
|
summary: Extracts query string params to a structured data, suitable to use for model queries
|
data/README.rdoc
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
= Overview
|
2
|
-
|
3
|
-
== About QueryStringInterace
|
4
|
-
|
5
|
-
This gem extracts params given as a hash to structured data, that can be used when creating queries
|
6
|
-
|
7
|
-
== Repository
|
8
|
-
|
9
|
-
http://github.com/vicentemundim/query_string_interface
|
10
|
-
|
11
|
-
= Installing
|
12
|
-
|
13
|
-
This is a gem, so you can install it by:
|
14
|
-
|
15
|
-
sudo gem install query_string_interface
|
16
|
-
|
17
|
-
Or, if you are using rails, put this in your Gemfile:
|
18
|
-
|
19
|
-
gem 'query_string_interface'
|
20
|
-
|
21
|
-
= Usage
|
22
|
-
|
23
|
-
To use it, just extend QueryStringInterface in your document model:
|
24
|
-
|
25
|
-
class Document
|
26
|
-
include Mongoid::Document
|
27
|
-
extend QueryInterfaceString
|
28
|
-
|
29
|
-
# ... add fields here
|
30
|
-
end
|
31
|
-
|
32
|
-
Then, you can use some class methods with your ORM syntax:
|
33
|
-
|
34
|
-
def self.filter_by(params)
|
35
|
-
where(filtering_options(params)).order_by(*sorting_options(params))
|
36
|
-
end
|
37
|
-
|
38
|
-
= ORM Adapters
|
39
|
-
|
40
|
-
http://github.com/vicentemundim/mongoid_query_string_interface
|
41
|
-
|
42
|
-
= Credits
|
43
|
-
|
44
|
-
Vicente Mundim: vicente.mundim at gmail dot com
|