bisque 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -20,7 +20,7 @@ Bisque is meant to ease the pain of "reporting"-style ad-hoc SQL queries in Acti
20
20
 
21
21
  *Cons*: Your reports are ultimately instances of some model - but most reports are not that at all! They're aggregate views over your models, and trying to cram them into existing instances forces you to conflate two very distinct concepts in the domain.
22
22
 
23
- == Even Fuglier: Query straight from the connection, then use the raw result or OpenStruct it in order to achieve some measure of separation
23
+ == Even Fuglier: Query straight from the connection, then use the raw result or OpenStruct in order to achieve some measure of separation
24
24
 
25
25
  *Example*:
26
26
 
@@ -78,24 +78,24 @@ Reports inherit from Bisque::Report, and have the following API:
78
78
  Every report *must* have a query. Define it here, using colon-prefixed words to designate parameters
79
79
 
80
80
  ==== Bisque::Report.defaults
81
- This method takes a hash of defaults, if any, for the parameters in your query. Each parameter must either have some default set for it, or be passed a value at runtime (see instantiatino below)
81
+ This method takes a hash of defaults - if extant - for the parameters in your query. Each parameter must either have some default value, or be passed a value at instantiation (see below)
82
82
 
83
83
  ==== Bisque::Report.rows
84
- If you wish to define custom methods on each individual row item of the report, define them here, and they will be evaluated in the context of the dynamically generated row class (which will be namespaced the same as the report class and named <YourReportClassName>Row).
84
+ If you wish to define custom methods on each individual row of the report, define them here; they will be evaluated in the context of the dynamically generated row class (which will be namespaced identically to the report class itself, and named <YourReportClassName>Row).
85
85
 
86
86
  === Step 2: Instantiate the report
87
- To use run a given report, just create a new instance of it. Each report instance is enumerable and so may be iterated over as usual.
87
+ To run a given report, just create a new instance of it. Each report instance is enumerable and so may be iterated over as usual.
88
88
 
89
89
  report = FooReport.new :customer_id => 42
90
90
 
91
- You must provide a hash of values for each parameter (that doesn't have a default) defined in the query, or a Bisque::MissingParameterException will be raised and the report will not be executed.
91
+ You must provide a hash of values for each parameter defined in the query without a default value, or a Bisque::MissingParameterException will be raised and the report will not be executed.
92
92
 
93
- If you have defined any custom row methods (via the rows block discussed above), you may call them on each item of the iterator as one would expect:
93
+ If you have defined any custom row methods via the rows block discussed above, you may call them on each item of the iterator as one would expect:
94
94
 
95
95
  puts report.first.total_in_cents
96
96
 
97
97
  == In closing
98
- For the time being, Bisque supports PostgreSQL exclusively (db-agnositicism is broken due to the necessities associated with typecasting dynamically selected values), because I virtually never use anything else and wanted this gem out there ASAP for my own purposes. I sincerely doubt I'll ever get around to extending it for support of other AR-supported dbs, but if one of you fine folks would like to do so, submit a pull request as described below and I'll happily include it. Of course, any other improvements, feature requests, etc. will be considered and taken into account - I would like to see this grow into a highly versatile tool, so suggest away!
98
+ For the time being, Bisque supports PostgreSQL exclusively because I virtually never use anything else and wanted this gem out there ASAP for my own purposes (db-agnositicism is broken due to the particulars associated with typecasting dynamically selected values). I sincerely doubt I'll ever get around to extending it for support of other AR-supported dbs, but if one of you fine folks would like to do so, submit a pull request as described below and I'll happily include it. Of course, any other improvements, feature requests, etc. will be considered and taken into account - I would like to see this grow into a highly versatile tool, so suggest away!
99
99
 
100
100
  == Contributing to bisque
101
101
 
@@ -107,6 +107,12 @@ For the time being, Bisque supports PostgreSQL exclusively (db-agnositicism is b
107
107
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
108
108
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
109
109
 
110
+ == TODO:
111
+ * PostgreSQL views and "pseudo-materialized" views. Maybe a DSL for defining triggers, etc therefor. Dunno, have to think about it - the materialized views typically work perfectly well when implemented as read-only models. (and you get associations that way)
112
+ * Maybe parameter validation of some sort - would that be necessary?
113
+ * Implement some kind of pagination
114
+ * Refine DSL and performance improvements - not sure architecture is the most ideal, but designed top-down and seems to work ok.
115
+
110
116
  == Copyright
111
117
 
112
118
  Copyright (c) 2012 Jeremy Holland. See LICENSE.txt for
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bisque.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bisque"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Holland"]
12
- s.date = "2012-09-01"
12
+ s.date = "2013-07-04"
13
13
  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
14
  s.email = "jeremy@jeremypholland.com"
15
15
  s.extra_rdoc_files = [
@@ -42,7 +42,7 @@ 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.15"
45
+ s.rubygems_version = "1.8.23"
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
data/lib/bisque/report.rb CHANGED
@@ -10,7 +10,7 @@ module Bisque
10
10
  self.class.params.each do |param|
11
11
  value = @params[param]
12
12
  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?
13
- @sql.gsub!(/:#{param}/, sanitize_and_sqlize(value))
13
+ @sql.gsub!(/(?<!:):#{param}/, sanitize_and_sqlize(value))
14
14
  end
15
15
  @results = ActiveRecord::Base.connection.execute @sql
16
16
  extract_datatypes
@@ -112,7 +112,7 @@ module Bisque
112
112
  def query(qstr=nil)
113
113
  if qstr
114
114
  @qstr = qstr.strip
115
- @params = qstr.scan(/:\w+/).map { |p| p.gsub(/:/,'').intern }
115
+ @params = qstr.scan(/(?<!:):\w+/).map { |p| p.gsub(/:/,'').intern }
116
116
  else
117
117
  raise Bisque::MissingQueryException, "Bisque Report #{self} missing query definition." if @qstr.nil?
118
118
  @qstr
data/spec/spec_helper.rb CHANGED
@@ -34,6 +34,7 @@ end
34
34
  RSpec.configure do |config|
35
35
  dir = File.dirname(__FILE__)
36
36
  dbconfig = {
37
+ 'host' => '127.0.0.1',
37
38
  'adapter' => 'postgresql',
38
39
  'encoding' => 'unicode',
39
40
  'database' => 'bisque_development',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-01 00:00:00.000000000 Z
12
+ date: 2013-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &18252960 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *18252960
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: pg
27
- requirement: &18531220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *18531220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &18529960 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 2.8.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *18529960
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rdoc
49
- requirement: &18527080 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '3.12'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *18527080
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.12'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: bundler
60
- requirement: &18524720 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 1.1.0
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *18524720
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.1.0
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: jeweler
71
- requirement: &19469800 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: 1.8.4
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *19469800
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.4
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: simplecov
82
- requirement: &18445260 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *18445260
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: spork
93
- requirement: &18443840 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *18443840
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: pry
104
- requirement: &18441760 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ! '>='
@@ -109,7 +149,12 @@ dependencies:
109
149
  version: '0'
110
150
  type: :development
111
151
  prerelease: false
112
- version_requirements: *18441760
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
113
158
  description: Bisque exists to ease the organizational pain of having to attach reporting
114
159
  and ad-hoc queries to ActiveRecord models in order to get any class-like behavior
115
160
  out of them by providing a new class and DSL for that express purpose.
@@ -156,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
201
  version: '0'
157
202
  segments:
158
203
  - 0
159
- hash: 3233801833892750029
204
+ hash: -194881109709687049
160
205
  required_rubygems_version: !ruby/object:Gem::Requirement
161
206
  none: false
162
207
  requirements:
@@ -165,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
210
  version: '0'
166
211
  requirements: []
167
212
  rubyforge_project:
168
- rubygems_version: 1.8.15
213
+ rubygems_version: 1.8.23
169
214
  signing_key:
170
215
  specification_version: 3
171
216
  summary: A simple gem for ease of use in generating reports with ActiveRecord