bisque 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTE1NzRhMjI3YjBkYWJlNjg1MWRlYmViNzZjMzk4YmE0YTA2NTEwYw==
5
+ data.tar.gz: !binary |-
6
+ NzkxMDEwZmIwZDQzNzU4ZTQ5MWZjMjlkODY4M2IwYjllN2U4OWMwMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZmYxNjAzYjdkMDQ2ZGM0Y2M4ZjgyZDVhNjE5MTkxMWRmMmVkMzkxZTFhMzVh
10
+ YzUxOGYwYzgyNjA1MzVkZmNmNTAxMWExYmZkMWE0OTg1MzJkOTdlMWI3MDJh
11
+ YzQzMDdiZDRjZTExOTIzNDM5OGZlOGZkOGYyNjNjMWU4MjU3Mjg=
12
+ data.tar.gz: !binary |-
13
+ NjU5Njk2M2VkYWQ3NzgxMTE2N2QzOGU5NDQwNDRlY2E5YWZlZGFlY2Q2M2U3
14
+ ZTg4MTI4NDk1MzEyYjhjMThhY2U4M2JmYzNiOGEzYzI0MzhmMjUxMzMxMjA5
15
+ MjI3MWYyOGEzODk3MzA3ZDAwYmQ5Y2Q5ZDZhZGNjYTM0MzgxN2M=
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ gem 'pg'
10
10
  group :development do
11
11
  gem "rspec", "~> 2.8.0"
12
12
  gem "rdoc", "~> 3.12"
13
- gem "bundler", "~> 1.1.0"
13
+ gem "bundler", "~> 1.3.5"
14
14
  gem "jeweler", "~> 1.8.4"
15
15
  gem "simplecov", ">= 0"
16
16
  gem 'spork'
data/Gemfile.lock CHANGED
@@ -16,23 +16,51 @@ GEM
16
16
  builder (3.0.0)
17
17
  coderay (1.0.7)
18
18
  diff-lcs (1.1.3)
19
- git (1.2.5)
19
+ faraday (0.8.8)
20
+ multipart-post (~> 1.2.0)
21
+ git (1.2.6)
22
+ github_api (0.8.1)
23
+ faraday (~> 0.8.1)
24
+ hashie (~> 1.2.0)
25
+ multi_json (~> 1.3)
26
+ nokogiri (~> 1.5.2)
27
+ oauth2
28
+ hashie (1.2.0)
29
+ highline (1.6.20)
30
+ httpauth (0.2.0)
20
31
  i18n (0.6.0)
21
- jeweler (1.8.4)
32
+ jeweler (1.8.5)
33
+ builder
22
34
  bundler (~> 1.0)
23
35
  git (>= 1.2.5)
36
+ github_api (>= 0.8.1)
37
+ highline (>= 1.6.15)
38
+ nokogiri (= 1.5.10)
24
39
  rake
25
40
  rdoc
26
- json (1.7.5)
41
+ json (1.8.1)
42
+ jwt (0.1.6)
43
+ multi_json (>= 1.0)
27
44
  method_source (0.8)
28
45
  multi_json (1.3.6)
46
+ multi_xml (0.5.5)
47
+ multipart-post (1.2.0)
48
+ nokogiri (1.5.10)
49
+ oauth2 (0.9.2)
50
+ faraday (~> 0.8)
51
+ httpauth (~> 0.2)
52
+ jwt (~> 0.1.4)
53
+ multi_json (~> 1.0)
54
+ multi_xml (~> 0.5)
55
+ rack (~> 1.2)
29
56
  pg (0.14.0)
30
57
  pry (0.9.10)
31
58
  coderay (~> 1.0.5)
32
59
  method_source (~> 0.8)
33
60
  slop (~> 3.3.1)
34
- rake (0.9.2.2)
35
- rdoc (3.12)
61
+ rack (1.5.2)
62
+ rake (10.1.1)
63
+ rdoc (3.12.2)
36
64
  json (~> 1.4)
37
65
  rspec (2.8.0)
38
66
  rspec-core (~> 2.8.0)
@@ -55,7 +83,7 @@ PLATFORMS
55
83
 
56
84
  DEPENDENCIES
57
85
  activerecord (>= 3.0.0)
58
- bundler (~> 1.1.0)
86
+ bundler (~> 1.3.5)
59
87
  jeweler (~> 1.8.4)
60
88
  pg
61
89
  pry
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0
data/bisque.gemspec CHANGED
@@ -2,14 +2,15 @@
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: bisque 0.2.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "bisque"
8
- s.version = "0.1.4"
9
+ s.version = "0.2.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Jeremy Holland"]
12
- s.date = "2013-07-04"
13
+ s.date = "2013-12-30"
13
14
  s.description = "Bisque exists to ease the organizational pain of having to attach reporting and ad-hoc queries to ActiveRecord models in order to get any class-like behavior out of them by providing a new class and DSL for that express purpose."
14
15
  s.email = "jeremy@jeremypholland.com"
15
16
  s.extra_rdoc_files = [
@@ -19,7 +20,6 @@ Gem::Specification.new do |s|
19
20
  s.files = [
20
21
  ".document",
21
22
  ".rspec",
22
- ".rvmrc",
23
23
  "Gemfile",
24
24
  "Gemfile.lock",
25
25
  "LICENSE.txt",
@@ -42,18 +42,18 @@ Gem::Specification.new do |s|
42
42
  s.homepage = "http://github.com/awebneck/bisque"
43
43
  s.licenses = ["MIT"]
44
44
  s.require_paths = ["lib"]
45
- s.rubygems_version = "1.8.23"
45
+ s.rubygems_version = "2.1.11"
46
46
  s.summary = "A simple gem for ease of use in generating reports with ActiveRecord"
47
47
 
48
48
  if s.respond_to? :specification_version then
49
- s.specification_version = 3
49
+ s.specification_version = 4
50
50
 
51
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
52
  s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
53
53
  s.add_runtime_dependency(%q<pg>, [">= 0"])
54
54
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
55
55
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
56
- s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
56
+ s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
57
57
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
58
58
  s.add_development_dependency(%q<simplecov>, [">= 0"])
59
59
  s.add_development_dependency(%q<spork>, [">= 0"])
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
63
63
  s.add_dependency(%q<pg>, [">= 0"])
64
64
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
65
65
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
- s.add_dependency(%q<bundler>, ["~> 1.1.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.3.5"])
67
67
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
68
68
  s.add_dependency(%q<simplecov>, [">= 0"])
69
69
  s.add_dependency(%q<spork>, [">= 0"])
@@ -74,7 +74,7 @@ Gem::Specification.new do |s|
74
74
  s.add_dependency(%q<pg>, [">= 0"])
75
75
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
76
76
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
77
- s.add_dependency(%q<bundler>, ["~> 1.1.0"])
77
+ s.add_dependency(%q<bundler>, ["~> 1.3.5"])
78
78
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
79
79
  s.add_dependency(%q<simplecov>, [">= 0"])
80
80
  s.add_dependency(%q<spork>, [">= 0"])
data/lib/bisque/report.rb CHANGED
@@ -15,6 +15,10 @@ module Bisque
15
15
  raise Bisque::MissingParameterException, "Missing parameter :#{param} for construction of #{self.class} - please provide a value for this parameter to the constructor or define a default." if value.nil? && !self.class.optional.include?(param.intern)
16
16
  @sql.gsub!(/(?<!:):#{param}/, sanitize_and_sqlize(value))
17
17
  end
18
+ self.class.method_params.each do |param|
19
+ raise Bisque::MissingParameterException, "Missing method :#{param} for construction of #{self.class} - please define a method for this parameter." unless respond_to?(param)
20
+ @sql.gsub!(/(?<!:):##{param}/, sanitize_and_sqlize(send(param)))
21
+ end
18
22
  @results = ActiveRecord::Base.connection.execute @sql
19
23
  extract_datatypes
20
24
  construct_converted
@@ -125,6 +129,7 @@ module Bisque
125
129
  if qstr
126
130
  @qstr = qstr.strip
127
131
  @params = qstr.scan(/(?<!:):\w+/).map { |p| p.gsub(/:/,'').intern }
132
+ @method_params = qstr.scan(/(?<!:):#\w+/).map { |p| p.gsub(/:#/,'').intern }
128
133
  else
129
134
  raise Bisque::MissingQueryException, "Bisque Report #{self} missing query definition." if @qstr.nil?
130
135
  @qstr
@@ -153,6 +158,10 @@ module Bisque
153
158
  def params
154
159
  @params || []
155
160
  end
161
+
162
+ def method_params
163
+ @method_params || []
164
+ end
156
165
  end
157
166
  end
158
167
  end
@@ -26,6 +26,19 @@ describe Bisque::Report do
26
26
  end
27
27
  end
28
28
 
29
+ describe "method_params" do
30
+ it "should return an empty array if no method parameters exist" do
31
+ FooReport.method_params.should be_a Array
32
+ FooReport.method_params.should be_empty
33
+ end
34
+
35
+ it "should return a list of the method parameters extracted from the query if present" do
36
+ CorkReport.method_params.should be_a Array
37
+ CorkReport.method_params.length.should == 1
38
+ CorkReport.method_params.should include :slam
39
+ end
40
+ end
41
+
29
42
  describe "defaults" do
30
43
  it "should return an empty hash if no defaults exist" do
31
44
  BarReport.defaults.should be_a Hash
@@ -97,10 +110,18 @@ describe Bisque::Report do
97
110
  lambda { BarReport.new }.should raise_error Bisque::MissingParameterException
98
111
  end
99
112
 
113
+ it "should raise a Bisque::MissingParameterException if the query designates method parameters but no corresponding methods" do
114
+ lambda { CorkReport.new }.should raise_error Bisque::MissingParameterException
115
+ end
116
+
100
117
  it "should not raise a Bisque::MissingParameterException if the query designates parameters but no defaults, it is constructed with no arguments, and the designated parameters are designated as optional" do
101
118
  lambda { CornReport.new }.should_not raise_error
102
119
  end
103
120
 
121
+ it "should not raise a Bisque::MissingParameterException if the query designates method parameters with corresponding methods" do
122
+ lambda { CheeseReport.new }.should_not raise_error Bisque::MissingParameterException
123
+ end
124
+
104
125
  it "should accept a hash of parameters" do
105
126
  lambda { BarReport.new :corn => 'cheese' }.should_not raise_error
106
127
  end
@@ -179,7 +200,7 @@ describe Bisque::Report do
179
200
  :created_on => Date.new(2012,2,1),
180
201
  :boolish => true,
181
202
  :binny => "\x00\x01\x02\x03"
182
- p.sql.should == "SELECT * FROM frobnitzs WHERE name = 'test' AND description = 'testagain' AND score = 12 AND cost = 34.12 AND numberish = 123.35583 AND created_at = '2012-01-01 05:00:00.000000' AND timish = '2012-01-01 06:00:00.000000' AND summed_at = '2012-01-01 07:00:00.000000' AND created_on = '2012-02-01' AND boolish = 't' AND binny = ''"
203
+ p.sql.should == "SELECT * FROM frobnitzs WHERE name = 'test' AND description = 'testagain' AND score = 12 AND cost = 34.12 AND numberish = 123.35583 AND created_at = '2012-01-01 05:00:00.000000' AND timish = '2012-01-01 06:00:00.000000' AND summed_at = '2012-01-01 07:00:00.000000' AND created_on = '2012-02-01' AND boolish = 't' AND binny = '' AND chili = 'hahahah'"
183
204
  end
184
205
  end
185
206
 
@@ -46,11 +46,27 @@ class FunReport < Bisque::Report
46
46
  end
47
47
  end
48
48
 
49
+ class CorkReport < Bisque::Report
50
+ query "SELECT * FROM frobnitzs WHERE name = :#slam"
51
+ end
52
+
53
+ class CheeseReport < Bisque::Report
54
+ query "SELECT * FROM frobnitzs WHERE name = :#slam"
55
+
56
+ def slam
57
+ 'whoopie'
58
+ end
59
+ end
60
+
49
61
  class CornReport < Bisque::Report
50
62
  query "SELECT * FROM frobnitzs WHERE name = :corn"
51
63
  optional :corn
52
64
  end
53
65
 
54
66
  class ParamReport < Bisque::Report
55
- query "SELECT * FROM frobnitzs WHERE name = :name AND description = :description AND score = :score AND cost = :cost AND numberish = :numberish AND created_at = :created_at AND timish = :timish AND summed_at = :summed_at AND created_on = :created_on AND boolish = :boolish AND binny = :binny"
67
+ query "SELECT * FROM frobnitzs WHERE name = :name AND description = :description AND score = :score AND cost = :cost AND numberish = :numberish AND created_at = :created_at AND timish = :timish AND summed_at = :summed_at AND created_on = :created_on AND boolish = :boolish AND binny = :binny AND chili = :#chili"
68
+
69
+ def chili
70
+ 'hahahah'
71
+ end
56
72
  end
@@ -11,5 +11,6 @@ ActiveRecord::Schema.define(:version => 0) do
11
11
  t.column :created_on, :date
12
12
  t.column :boolish, :boolean
13
13
  t.column :binny, :binary
14
+ t.column :chili, :string
14
15
  end
15
16
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeremy Holland
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-04 00:00:00.000000000 Z
11
+ date: 2013-12-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
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
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: pg
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
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
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
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
@@ -62,55 +55,52 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rdoc
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: '3.12'
61
+ version: !binary |-
62
+ My4xMg==
70
63
  type: :development
71
64
  prerelease: false
72
65
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
67
  - - ~>
76
68
  - !ruby/object:Gem::Version
77
- version: '3.12'
69
+ version: !binary |-
70
+ My4xMg==
78
71
  - !ruby/object:Gem::Dependency
79
72
  name: bundler
80
73
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
74
  requirements:
83
75
  - - ~>
84
76
  - !ruby/object:Gem::Version
85
- version: 1.1.0
77
+ version: 1.3.5
86
78
  type: :development
87
79
  prerelease: false
88
80
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
81
  requirements:
91
82
  - - ~>
92
83
  - !ruby/object:Gem::Version
93
- version: 1.1.0
84
+ version: 1.3.5
94
85
  - !ruby/object:Gem::Dependency
95
86
  name: jeweler
96
87
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
88
  requirements:
99
89
  - - ~>
100
90
  - !ruby/object:Gem::Version
101
- version: 1.8.4
91
+ version: !binary |-
92
+ MS44LjQ=
102
93
  type: :development
103
94
  prerelease: false
104
95
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
96
  requirements:
107
97
  - - ~>
108
98
  - !ruby/object:Gem::Version
109
- version: 1.8.4
99
+ version: !binary |-
100
+ MS44LjQ=
110
101
  - !ruby/object:Gem::Dependency
111
102
  name: simplecov
112
103
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
104
  requirements:
115
105
  - - ! '>='
116
106
  - !ruby/object:Gem::Version
@@ -118,7 +108,6 @@ dependencies:
118
108
  type: :development
119
109
  prerelease: false
120
110
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
111
  requirements:
123
112
  - - ! '>='
124
113
  - !ruby/object:Gem::Version
@@ -126,7 +115,6 @@ dependencies:
126
115
  - !ruby/object:Gem::Dependency
127
116
  name: spork
128
117
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
118
  requirements:
131
119
  - - ! '>='
132
120
  - !ruby/object:Gem::Version
@@ -134,7 +122,6 @@ dependencies:
134
122
  type: :development
135
123
  prerelease: false
136
124
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
125
  requirements:
139
126
  - - ! '>='
140
127
  - !ruby/object:Gem::Version
@@ -142,7 +129,6 @@ dependencies:
142
129
  - !ruby/object:Gem::Dependency
143
130
  name: pry
144
131
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
132
  requirements:
147
133
  - - ! '>='
148
134
  - !ruby/object:Gem::Version
@@ -150,7 +136,6 @@ dependencies:
150
136
  type: :development
151
137
  prerelease: false
152
138
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
139
  requirements:
155
140
  - - ! '>='
156
141
  - !ruby/object:Gem::Version
@@ -167,7 +152,6 @@ extra_rdoc_files:
167
152
  files:
168
153
  - .document
169
154
  - .rspec
170
- - .rvmrc
171
155
  - Gemfile
172
156
  - Gemfile.lock
173
157
  - LICENSE.txt
@@ -189,29 +173,25 @@ files:
189
173
  homepage: http://github.com/awebneck/bisque
190
174
  licenses:
191
175
  - MIT
176
+ metadata: {}
192
177
  post_install_message:
193
178
  rdoc_options: []
194
179
  require_paths:
195
180
  - lib
196
181
  required_ruby_version: !ruby/object:Gem::Requirement
197
- none: false
198
182
  requirements:
199
183
  - - ! '>='
200
184
  - !ruby/object:Gem::Version
201
185
  version: '0'
202
- segments:
203
- - 0
204
- hash: 1348488274421313650
205
186
  required_rubygems_version: !ruby/object:Gem::Requirement
206
- none: false
207
187
  requirements:
208
188
  - - ! '>='
209
189
  - !ruby/object:Gem::Version
210
190
  version: '0'
211
191
  requirements: []
212
192
  rubyforge_project:
213
- rubygems_version: 1.8.23
193
+ rubygems_version: 2.1.11
214
194
  signing_key:
215
- specification_version: 3
195
+ specification_version: 4
216
196
  summary: A simple gem for ease of use in generating reports with ActiveRecord
217
197
  test_files: []
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3@bisque