fluent-query 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,13 +3,12 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  gem "hash-utils", ">= 0.18.0"
5
5
  gem "abstract", ">= 1.0.0"
6
- gem "hashie", ">= 1.0.0"
7
6
 
8
7
  # Add dependencies to develop your gem here.
9
8
  # Include everything needed to run rake, tests, features, etc.
10
9
  group :development do
11
- gem "bundler", "~> 1.0.13"
12
- gem "jeweler", "~> 1.6.0"
10
+ gem "bundler", ">= 1.0.13"
11
+ gem "jeweler2", ">= 2.0.0"
13
12
  end
14
13
 
15
14
 
data/Gemfile.lock CHANGED
@@ -3,20 +3,17 @@ GEM
3
3
  specs:
4
4
  abstract (1.0.0)
5
5
  git (1.2.5)
6
- hash-utils (0.18.0)
7
- hashie (1.0.0)
8
- jeweler (1.6.3)
9
- bundler (~> 1.0)
6
+ hash-utils (2.0.0)
7
+ ruby-version
8
+ jeweler2 (2.0.9)
10
9
  git (>= 1.2.5)
11
- rake
12
- rake (0.9.2)
10
+ ruby-version (0.3.1)
13
11
 
14
12
  PLATFORMS
15
13
  ruby
16
14
 
17
15
  DEPENDENCIES
18
16
  abstract (>= 1.0.0)
19
- bundler (~> 1.0.13)
17
+ bundler (>= 1.0.13)
20
18
  hash-utils (>= 0.18.0)
21
- hashie (>= 1.0.0)
22
- jeweler (~> 1.6.0)
19
+ jeweler2 (>= 2.0.0)
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 - 2011 Martin Kozák (martinkozak@martinkozak.net)
1
+ Copyright (c) 2009 - 2012 Martin Kozák (martinkozak@martinkozak.net)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -221,7 +221,7 @@ Contributing
221
221
  Copyright
222
222
  ---------
223
223
 
224
- Copyright © 2009-2011 [Martin Kozák][3]. See `LICENSE.txt` for
224
+ Copyright © 2009-2012 [Martin Kozák][3]. See `LICENSE.txt` for
225
225
  further details.
226
226
 
227
227
  [1]: http://dibiphp.com/
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
 
13
13
  require 'rake'
14
- require 'jeweler'
14
+ require 'jeweler2'
15
15
 
16
16
  Jeweler::Tasks.new do |gem|
17
17
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.3
data/fluent-query.gemspec CHANGED
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{fluent-query}
8
- s.version = "0.9.1"
7
+ s.name = "fluent-query"
8
+ s.version = "0.9.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Martin Kozák}]
12
- s.date = %q{2011-07-14}
13
- s.email = %q{martinkozak@martinkozak.net}
11
+ s.authors = ["Martin Koz\u{e1}k"]
12
+ s.date = "2012-05-30"
13
+ s.email = "martinkozak@martinkozak.net"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
16
16
  "README.md"
@@ -42,11 +42,11 @@ Gem::Specification.new do |s|
42
42
  "lib/fluent-query/token.rb",
43
43
  "lib/fluent-query/tokens/raw.rb"
44
44
  ]
45
- s.homepage = %q{http://github.com/martinkozak/fluent-query}
46
- s.licenses = [%q{MIT}]
47
- s.require_paths = [%q{lib}]
48
- s.rubygems_version = %q{1.8.5}
49
- s.summary = %q{Cool way how to write SQL queries and general way how to convert series of method calls to string query in an universal and system independent manner. This gem contains base libraries only. SQL implementation is available standalone.}
45
+ s.homepage = "http://github.com/martinkozak/fluent-query"
46
+ s.licenses = ["MIT"]
47
+ s.require_paths = ["lib"]
48
+ s.rubygems_version = "1.8.24"
49
+ s.summary = "Cool way how to write SQL queries and general way how to convert series of method calls to string query in an universal and system independent manner. This gem contains base libraries only. SQL implementation is available standalone."
50
50
 
51
51
  if s.respond_to? :specification_version then
52
52
  s.specification_version = 3
@@ -54,22 +54,19 @@ Gem::Specification.new do |s|
54
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
55
  s.add_runtime_dependency(%q<hash-utils>, [">= 0.18.0"])
56
56
  s.add_runtime_dependency(%q<abstract>, [">= 1.0.0"])
57
- s.add_runtime_dependency(%q<hashie>, [">= 1.0.0"])
58
- s.add_development_dependency(%q<bundler>, ["~> 1.0.13"])
59
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
57
+ s.add_development_dependency(%q<bundler>, [">= 1.0.13"])
58
+ s.add_development_dependency(%q<jeweler2>, [">= 2.0.0"])
60
59
  else
61
60
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
62
61
  s.add_dependency(%q<abstract>, [">= 1.0.0"])
63
- s.add_dependency(%q<hashie>, [">= 1.0.0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.0.13"])
65
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
62
+ s.add_dependency(%q<bundler>, [">= 1.0.13"])
63
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
66
64
  end
67
65
  else
68
66
  s.add_dependency(%q<hash-utils>, [">= 0.18.0"])
69
67
  s.add_dependency(%q<abstract>, [">= 1.0.0"])
70
- s.add_dependency(%q<hashie>, [">= 1.0.0"])
71
- s.add_dependency(%q<bundler>, ["~> 1.0.13"])
72
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
68
+ s.add_dependency(%q<bundler>, [">= 1.0.13"])
69
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
73
70
  end
74
71
  end
75
72
 
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
- require "date"
3
- require "fluent-query/query"
4
2
  require "fluent-query/compilers/result"
3
+ require "fluent-query/query"
5
4
  require "hash-utils/array" # >= 0.17.0
5
+ require "date"
6
6
 
7
7
  module FluentQuery
8
8
 
@@ -1,4 +1,6 @@
1
1
  # encoding: utf-8
2
+
3
+ require "hash-utils/symbol"
2
4
  require "fluent-query/result"
3
5
  require "fluent-query/driver"
4
6
  require "fluent-query/exception"
@@ -268,7 +270,7 @@ module FluentQuery
268
270
 
269
271
 
270
272
  #####
271
-
273
+ =begin
272
274
  ##
273
275
  # Handles built-in shortcut.
274
276
  #
@@ -283,7 +285,7 @@ module FluentQuery
283
285
 
284
286
  return result
285
287
  end
286
-
288
+ =end
287
289
  ##
288
290
  # Performs query initiating call.
289
291
  #
@@ -295,7 +297,7 @@ module FluentQuery
295
297
  # Executes query conditionally. If query isn't suitable for
296
298
  # executing, sends the symbol to it and returns call result.
297
299
 
298
- query.send(sym, *args)
300
+ query = query.send(sym, *args)
299
301
 
300
302
  # Calls given block in query context.
301
303
 
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
- require "hash-utils/string"
3
- require "hashie/mash"
4
2
 
5
3
  module FluentQuery
6
4
 
@@ -11,7 +9,46 @@ module FluentQuery
11
9
  # access its fields by "object way".
12
10
  #
13
11
 
14
- class Data < ::Hashie::Mash
12
+ class Data
13
+
14
+ ##
15
+ # Contained data hash.
16
+ #
17
+
18
+ @data
19
+
20
+ ##
21
+ # Constructor.
22
+ #
23
+
24
+ def initialize(data)
25
+ @data = data
26
+ end
27
+
28
+ ##
29
+ # Maps missing calls to data elements.
30
+ #
31
+
32
+ def method_missing(name, *args)
33
+ @data[name]
34
+ end
35
+
36
+ ##
37
+ # Maps array access to underlying data object.
38
+ #
39
+
40
+ def [](key)
41
+ @data[key.to_sym]
42
+ end
43
+
44
+ ##
45
+ # Converts data to hash.
46
+ #
47
+
48
+ def to_hash
49
+ @data.to_hash.dup
50
+ end
51
+
15
52
  end
16
53
 
17
54
  end
@@ -273,6 +273,29 @@ module FluentQuery
273
273
  def prepare(query)
274
274
  not_implemented
275
275
  end
276
+
277
+ ##
278
+ # Checks query conditionally. It's called after first token
279
+ # of the query.
280
+ #
281
+ # @since 0.9.2
282
+ #
283
+
284
+ public
285
+ def check_conditionally(query, sym, *args, &block)
286
+ end
287
+
288
+ ##
289
+ # Corrects token before it's pushed to the token. So allows to
290
+ # modify data assigned to the query from driver level.
291
+ #
292
+ # @since 0.9.2
293
+ #
294
+
295
+ public
296
+ def correct_token(name, args)
297
+ return [name, args]
298
+ end
276
299
 
277
300
  end
278
301
  end
@@ -5,7 +5,7 @@ module FluentQuery
5
5
  module Queries
6
6
 
7
7
  ##
8
- # Compiled query.
8
+ # Prepared query.
9
9
  #
10
10
 
11
11
  class Prepared < FluentQuery::Queries::Abstract
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
- require "date"
3
2
  require "hash-utils/string"
3
+ require "hash-utils/object"
4
+ require "date"
4
5
 
5
6
  require "fluent-query/query"
6
7
  require "fluent-query/compiler"
@@ -120,12 +121,9 @@ module FluentQuery
120
121
 
121
122
  public
122
123
  def process_array(array, glue = ",")
123
- result = [ ]
124
-
125
- array.each do |item|
126
- result << self.quote_value(item)
124
+ result = array.map do |i|
125
+ self.quote_value(i)
127
126
  end
128
-
129
127
  return result.join(glue + " ")
130
128
  end
131
129
 
@@ -232,9 +230,12 @@ module FluentQuery
232
230
  ##
233
231
  # Processed strings with format definitions and data specifications.
234
232
  #
235
- # Mode can be :compile, :build or :finish. Compiling means building the
236
- # query without expanding the formatting directives. Finishing means
237
- # building the prepared query.
233
+ # Mode can be +:compile+, +:build+, +:prepare+ or +:finish+.
234
+ # Compiling means building the query without expanding the
235
+ # formatting directives. Finishing means building the
236
+ # compiled query. Building means both of them. Preparing is
237
+ # basically the same as compiling, but modifies behaviour
238
+ # of some tokens such as +INSERT+.
238
239
  #
239
240
 
240
241
  public
@@ -258,14 +259,14 @@ module FluentQuery
258
259
  # finding expression directive processing. In each call increases
259
260
  # sequence position counter so moves forward.
260
261
 
261
- if mode != :finish
262
+ if mode.in? [:compile, :build, :prepare]
262
263
  item.gsub!(self.replacer) do |directive|
263
264
  directive.strip!
264
265
  self.process_directive(directive, nil, replacer_settings)
265
266
  end
266
267
  end
267
268
 
268
- if mode != :compile
269
+ if mode.in? [:finish, :build]
269
270
  item.gsub!(self.expander) do |directive|
270
271
  self.process_directive(directive, sequence[i += 1], expander_settings)
271
272
  end
@@ -300,7 +301,7 @@ module FluentQuery
300
301
  result = directive.gsub(self.class::COLUMN_DIRECTIVE_SIMPLE) { |value| self.quote_identifier(value[1..-2]) }
301
302
  elsif (replacements & self.class::STRING_REPLACEMENT > 0) and (directive[-1].ord == 34) # "\"", String directive
302
303
  result = directive.gsub('"', @driver.quote_string("").last)
303
- elsif (replacements & self.class::FORMATTING_REPLACEMENT > 0) and (directive[0..1].to_sym == :"%%") # Formatting directive
304
+ elsif (replacements & self.class::FORMATTING_REPLACEMENT > 0) and (directive[0..1] == "%%") # Formatting directive
304
305
  result = directive.gsub(self.class::FORMATTING_DIRECTIVE_SIMPLE) { |value| self.process_formatting(value[2..-1], argument) }
305
306
  else
306
307
  result = directive
@@ -36,17 +36,18 @@ module FluentQuery
36
36
 
37
37
  public
38
38
  def method_missing(sym, *args, &block)
39
-
40
- self.push_token(sym, args)
41
39
  driver = @connection.driver
42
- conditionally = driver.execute_conditionally(self, sym, *args, &block)
43
-
40
+ _sym, args = driver.correct_token(sym, args)
41
+ # p [sym, args]
42
+ self.push_token(_sym, args)
43
+ conditionally = driver.check_conditionally(self, sym, *args, &block)
44
+
44
45
  if not conditionally.nil?
45
46
  result = conditionally
46
47
  else
47
48
  result = self
48
49
  end
49
-
50
+
50
51
  return result
51
52
  end
52
53
 
metadata CHANGED
@@ -1,82 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fluent-query
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
4
5
  prerelease:
5
- version: 0.9.1
6
6
  platform: ruby
7
- authors:
8
- - "Martin Koz\xC3\xA1k"
7
+ authors:
8
+ - Martin Kozák
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-07-14 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: hash-utils
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
22
21
  version: 0.18.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.18.0
30
+ - !ruby/object:Gem::Dependency
27
31
  name: abstract
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
33
37
  version: 1.0.0
34
38
  type: :runtime
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: hashie
39
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
40
41
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
44
45
  version: 1.0.0
45
- type: :runtime
46
- prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ - !ruby/object:Gem::Dependency
49
47
  name: bundler
50
- requirement: &id004 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
51
49
  none: false
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
55
53
  version: 1.0.13
56
54
  type: :development
57
55
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: jeweler
61
- requirement: &id005 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
62
57
  none: false
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
66
- version: 1.6.0
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.13
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler2
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.0
67
70
  type: :development
68
71
  prerelease: false
69
- version_requirements: *id005
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.0
70
78
  description:
71
79
  email: martinkozak@martinkozak.net
72
80
  executables: []
73
-
74
81
  extensions: []
75
-
76
- extra_rdoc_files:
82
+ extra_rdoc_files:
77
83
  - LICENSE.txt
78
84
  - README.md
79
- files:
85
+ files:
80
86
  - .document
81
87
  - Gemfile
82
88
  - Gemfile.lock
@@ -103,34 +109,33 @@ files:
103
109
  - lib/fluent-query/token.rb
104
110
  - lib/fluent-query/tokens/raw.rb
105
111
  homepage: http://github.com/martinkozak/fluent-query
106
- licenses:
112
+ licenses:
107
113
  - MIT
108
114
  post_install_message:
109
115
  rdoc_options: []
110
-
111
- require_paths:
116
+ require_paths:
112
117
  - lib
113
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
114
119
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 1837985845976862931
119
- segments:
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
120
125
  - 0
121
- version: "0"
122
- required_rubygems_version: !ruby/object:Gem::Requirement
126
+ hash: 3034922038781819026
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
128
  none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
128
133
  requirements: []
129
-
130
134
  rubyforge_project:
131
- rubygems_version: 1.8.5
135
+ rubygems_version: 1.8.24
132
136
  signing_key:
133
137
  specification_version: 3
134
- summary: Cool way how to write SQL queries and general way how to convert series of method calls to string query in an universal and system independent manner. This gem contains base libraries only. SQL implementation is available standalone.
138
+ summary: Cool way how to write SQL queries and general way how to convert series of
139
+ method calls to string query in an universal and system independent manner. This
140
+ gem contains base libraries only. SQL implementation is available standalone.
135
141
  test_files: []
136
-