restful_query 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Appraisals +12 -0
- data/Gemfile +11 -0
- data/Rakefile +7 -7
- data/lib/restful_query.rb +8 -10
- data/restful_query.gemspec +28 -15
- data/test/{test_restful_query_can_query.rb → can_query_test.rb} +4 -4
- data/test/{test_restful_query_condition.rb → condition_test.rb} +2 -2
- data/test/{test_helper.rb → helper.rb} +6 -5
- data/test/{test_restful_query_parser.rb → parser_test.rb} +20 -5
- data/test/{test_restful_query_sort.rb → sort_test.rb} +3 -3
- metadata +76 -34
- data/tasks/restful_query_tasks.rake +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f782db244df437f5e1653556e54f629a2e7b1b6
|
4
|
+
data.tar.gz: eb3fd20c0dde5cee15037b3b8ef220257d6e6329
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62fde767dcb820a0539c1e163fcf59b628e8c94a63b4f0c177d5f2165d85411b82bfe5d4a4730c53fcc1e85146663e087c8aea349e6d581ea8bae13efdd56e58
|
7
|
+
data.tar.gz: fcca5416bbba463353a99f87fe7af42b567f933da4ea2d61a0b1458e92e6124052fde6b8ae93367c245858454c96e6d21a7062070790c7e464175be702b0ba61
|
data/Appraisals
ADDED
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -7,24 +7,24 @@ begin
|
|
7
7
|
s.name = %q{restful_query}
|
8
8
|
s.version = RestfulQuery::VERSION
|
9
9
|
s.authors = ["Aaron Quint"]
|
10
|
+
s.email = "aaron@quirkey.com"
|
11
|
+
s.homepage = "https://github.com/quirkey/restful_query"
|
12
|
+
s.license = "MIT"
|
10
13
|
s.summary = 'Simple ActiveRecord and Sequel queries from a RESTful and safe interface'
|
11
14
|
s.description = %q{RestfulQuery provides a simple interface in front of a complex parser to parse specially formatted query hashes into complex SQL queries. It includes ActiveRecord and Sequel extensions.}
|
12
|
-
s.rubyforge_project = %q{quirkey}
|
13
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.0"])
|
14
|
-
s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
|
15
|
-
s.add_development_dependency(%q<Shoulda>, [">= 1.2.0"])
|
16
15
|
end
|
17
|
-
Jeweler::
|
16
|
+
Jeweler::RubygemsDotOrgTasks.new
|
17
|
+
|
18
18
|
rescue LoadError
|
19
19
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
20
|
end
|
21
21
|
|
22
22
|
Rake::TestTask.new do |t|
|
23
23
|
t.libs << "test"
|
24
|
-
t.test_files = FileList[
|
24
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
25
25
|
t.verbose = true
|
26
26
|
end
|
27
27
|
|
28
28
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
29
29
|
|
30
|
-
task :default => :test
|
30
|
+
task :default => :test
|
data/lib/restful_query.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
-
require
|
5
|
-
|
6
|
-
require 'chronic'
|
7
|
-
rescue LoadError
|
8
|
-
warn 'In order to use the time parsing functionalities you must install the Chronic gem: sudo gem install chronic'
|
9
|
-
end
|
4
|
+
require "active_support"
|
5
|
+
require "chronic"
|
10
6
|
|
11
7
|
module RestfulQuery
|
12
|
-
VERSION =
|
8
|
+
VERSION = "0.4.0"
|
13
9
|
|
14
10
|
class Error < RuntimeError; end
|
15
11
|
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
require "restful_query/can_query"
|
14
|
+
|
15
|
+
require "restful_query/condition"
|
16
|
+
require "restful_query/sort"
|
17
|
+
require "restful_query/parser"
|
data/restful_query.gemspec
CHANGED
@@ -2,20 +2,25 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: restful_query 0.4.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "restful_query"
|
8
|
-
s.version = "0.
|
9
|
+
s.version = "0.4.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Aaron Quint"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2015-02-27"
|
13
15
|
s.description = "RestfulQuery provides a simple interface in front of a complex parser to parse specially formatted query hashes into complex SQL queries. It includes ActiveRecord and Sequel extensions."
|
16
|
+
s.email = "aaron@quirkey.com"
|
14
17
|
s.extra_rdoc_files = [
|
15
18
|
"LICENSE",
|
16
19
|
"README.rdoc"
|
17
20
|
]
|
18
21
|
s.files = [
|
22
|
+
"Appraisals",
|
23
|
+
"Gemfile",
|
19
24
|
"History.txt",
|
20
25
|
"LICENSE",
|
21
26
|
"README.rdoc",
|
@@ -30,34 +35,42 @@ Gem::Specification.new do |s|
|
|
30
35
|
"lib/sequel/extensions/restful_query.rb",
|
31
36
|
"rails/init.rb",
|
32
37
|
"restful_query.gemspec",
|
33
|
-
"
|
34
|
-
"test/
|
35
|
-
"test/
|
36
|
-
"test/
|
37
|
-
"test/
|
38
|
-
"test/test_restful_query_sort.rb"
|
38
|
+
"test/can_query_test.rb",
|
39
|
+
"test/condition_test.rb",
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/parser_test.rb",
|
42
|
+
"test/sort_test.rb"
|
39
43
|
]
|
40
|
-
s.
|
41
|
-
s.
|
42
|
-
s.rubygems_version = "
|
44
|
+
s.homepage = "https://github.com/quirkey/restful_query"
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.rubygems_version = "2.2.2"
|
43
47
|
s.summary = "Simple ActiveRecord and Sequel queries from a RESTful and safe interface"
|
44
48
|
|
45
49
|
if s.respond_to? :specification_version then
|
46
|
-
s.specification_version =
|
50
|
+
s.specification_version = 4
|
47
51
|
|
48
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
53
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.0"])
|
50
54
|
s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
|
51
|
-
s.add_development_dependency(%q<
|
55
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<appraisal>, [">= 1.0.2", "~> 1.0"])
|
57
|
+
s.add_development_dependency(%q<minitest>, ["~> 5.5"])
|
58
|
+
s.add_development_dependency(%q<shoulda-context>, ["~> 1.2"])
|
52
59
|
else
|
53
60
|
s.add_dependency(%q<activesupport>, [">= 2.2.0"])
|
54
61
|
s.add_dependency(%q<chronic>, [">= 0.2.3"])
|
55
|
-
s.add_dependency(%q<
|
62
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
63
|
+
s.add_dependency(%q<appraisal>, [">= 1.0.2", "~> 1.0"])
|
64
|
+
s.add_dependency(%q<minitest>, ["~> 5.5"])
|
65
|
+
s.add_dependency(%q<shoulda-context>, ["~> 1.2"])
|
56
66
|
end
|
57
67
|
else
|
58
68
|
s.add_dependency(%q<activesupport>, [">= 2.2.0"])
|
59
69
|
s.add_dependency(%q<chronic>, [">= 0.2.3"])
|
60
|
-
s.add_dependency(%q<
|
70
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
71
|
+
s.add_dependency(%q<appraisal>, [">= 1.0.2", "~> 1.0"])
|
72
|
+
s.add_dependency(%q<minitest>, ["~> 5.5"])
|
73
|
+
s.add_dependency(%q<shoulda-context>, ["~> 1.2"])
|
61
74
|
end
|
62
75
|
end
|
63
76
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
|
-
class
|
3
|
+
class RestfulQuery::CanQueryTest < Minitest::Test
|
4
4
|
|
5
5
|
context "CanQuery" do
|
6
6
|
context "A class with the can_query macro" do
|
@@ -8,13 +8,13 @@ class TestRestfulQueryCanQuery < Test::Unit::TestCase
|
|
8
8
|
assert ClassWithQuery.can_query?
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
context "A class without the can_query macro" do
|
13
13
|
should "not can_query?" do
|
14
14
|
assert !ClassWithoutQuery.can_query?
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'shoulda'
|
1
|
+
$LOAD_PATH.unshift(File.join(File.expand_path(File.dirname(__FILE__)), "../lib"))
|
4
2
|
|
5
|
-
|
6
|
-
require
|
3
|
+
require "rubygems"
|
4
|
+
require "minitest/autorun"
|
5
|
+
require "shoulda-context"
|
6
|
+
|
7
|
+
require "restful_query"
|
7
8
|
|
8
9
|
|
9
10
|
unless defined?(ActiveRecord)
|
@@ -1,10 +1,25 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
|
-
class
|
3
|
+
class RestfulQuery::ParserTest < Minitest::Test
|
4
4
|
|
5
5
|
context "Parser" do
|
6
6
|
setup do
|
7
|
-
@base_query_hash = {
|
7
|
+
@base_query_hash = {
|
8
|
+
'created_at' => {
|
9
|
+
'gt' => '1 week ago',
|
10
|
+
'lt' => '1 hour ago'
|
11
|
+
},
|
12
|
+
'updated_at' => {
|
13
|
+
'lt' => '1 day ago'
|
14
|
+
},
|
15
|
+
'title' => {
|
16
|
+
'eq' => 'Test'
|
17
|
+
},
|
18
|
+
'other_time' => {
|
19
|
+
'gt' => 'oct 1'
|
20
|
+
},
|
21
|
+
'name' => 'Aaron'
|
22
|
+
}
|
8
23
|
end
|
9
24
|
|
10
25
|
context "from_hash" do
|
@@ -110,8 +125,8 @@ class RestfulQueryParserTest < Test::Unit::TestCase
|
|
110
125
|
end
|
111
126
|
|
112
127
|
should "not parse created at/updated at if not specified" do
|
113
|
-
|
114
|
-
|
128
|
+
refute_equal Chronic.parse('1 week ago').to_s, @parser.conditions_for(:created_at).first.value.to_s
|
129
|
+
refute_equal Chronic.parse('1 day ago').to_s, @parser.conditions_for(:updated_at).first.value.to_s
|
115
130
|
end
|
116
131
|
end
|
117
132
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
|
-
class
|
3
|
+
class RestfulQuery::SortTest < Minitest::Test
|
4
4
|
|
5
5
|
context "Sort" do
|
6
6
|
context "initializing" do
|
@@ -38,7 +38,7 @@ class RestfulQuerySortTest < Test::Unit::TestCase
|
|
38
38
|
|
39
39
|
context "with an invalid direction" do
|
40
40
|
should "raise error" do
|
41
|
-
|
41
|
+
assert_raises(RestfulQuery::InvalidDirection) do
|
42
42
|
RestfulQuery::Sort.new('column', 'blarg')
|
43
43
|
end
|
44
44
|
end
|
metadata
CHANGED
@@ -1,74 +1,117 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Aaron Quint
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.2.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.2.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: chronic
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.2.3
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.2.3
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: jeweler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.2
|
62
|
+
- - "~>"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '1.0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 1.0.2
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: minitest
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '5.5'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '5.5'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: shoulda-context
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.2'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.2'
|
62
103
|
description: RestfulQuery provides a simple interface in front of a complex parser
|
63
104
|
to parse specially formatted query hashes into complex SQL queries. It includes
|
64
105
|
ActiveRecord and Sequel extensions.
|
65
|
-
email:
|
106
|
+
email: aaron@quirkey.com
|
66
107
|
executables: []
|
67
108
|
extensions: []
|
68
109
|
extra_rdoc_files:
|
69
110
|
- LICENSE
|
70
111
|
- README.rdoc
|
71
112
|
files:
|
113
|
+
- Appraisals
|
114
|
+
- Gemfile
|
72
115
|
- History.txt
|
73
116
|
- LICENSE
|
74
117
|
- README.rdoc
|
@@ -83,34 +126,33 @@ files:
|
|
83
126
|
- lib/sequel/extensions/restful_query.rb
|
84
127
|
- rails/init.rb
|
85
128
|
- restful_query.gemspec
|
86
|
-
-
|
87
|
-
- test/
|
88
|
-
- test/
|
89
|
-
- test/
|
90
|
-
- test/
|
91
|
-
|
92
|
-
|
93
|
-
|
129
|
+
- test/can_query_test.rb
|
130
|
+
- test/condition_test.rb
|
131
|
+
- test/helper.rb
|
132
|
+
- test/parser_test.rb
|
133
|
+
- test/sort_test.rb
|
134
|
+
homepage: https://github.com/quirkey/restful_query
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
94
138
|
post_install_message:
|
95
139
|
rdoc_options: []
|
96
140
|
require_paths:
|
97
141
|
- lib
|
98
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
143
|
requirements:
|
101
|
-
- -
|
144
|
+
- - ">="
|
102
145
|
- !ruby/object:Gem::Version
|
103
146
|
version: '0'
|
104
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
148
|
requirements:
|
107
|
-
- -
|
149
|
+
- - ">="
|
108
150
|
- !ruby/object:Gem::Version
|
109
151
|
version: '0'
|
110
152
|
requirements: []
|
111
|
-
rubyforge_project:
|
112
|
-
rubygems_version:
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.2.2
|
113
155
|
signing_key:
|
114
|
-
specification_version:
|
156
|
+
specification_version: 4
|
115
157
|
summary: Simple ActiveRecord and Sequel queries from a RESTful and safe interface
|
116
158
|
test_files: []
|