port-a-query 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/port-a-query.rb CHANGED
@@ -1,4 +1,37 @@
1
- require 'port-a-query/port-a-query'
2
- require 'port-a-query/default'
3
- require 'port-a-query/sqlite3'
4
- require 'port-a-query/mysql'
1
+ require 'port-a-query/adapters/default'
2
+ require 'port-a-query/adapters/sqlite3'
3
+ require 'port-a-query/adapters/mysql'
4
+
5
+ module PortAQuery
6
+ # Symbols should be used for field names, everything else will be quoted as a string
7
+
8
+ @adapter = nil
9
+
10
+ def self.method_missing(name, *args)
11
+
12
+ if adapter.respond_to?(name)
13
+ adapter.send(name, *args)
14
+ else
15
+ Default.send(name, *args)
16
+ end
17
+
18
+ end
19
+
20
+ protected
21
+
22
+ def self.adapter
23
+ return @adapter unless @adapter.nil?
24
+
25
+ adapter_name = ActiveRecord::Base.configurations[Rails.env]['adapter']
26
+
27
+ @adapter = case adapter_name.to_s.to_sym
28
+ when :sqlite3
29
+ SqLite3
30
+ when :mysql
31
+ MySql
32
+ when :mysql2
33
+ MySql
34
+ end
35
+ end
36
+
37
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ module PortAQuery
2
+
3
+ VERSION = '0.1.1'
4
+
5
+ end
metadata CHANGED
@@ -1,71 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: port-a-query
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Adam Crownoble
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-09-03 00:00:00 -07:00
19
- default_executable:
12
+ date: 2011-09-01 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
14
  description: Simple helper for generating portable SQL expressions.
23
15
  email: adam@obledesign.com
24
16
  executables: []
25
-
26
17
  extensions: []
27
-
28
18
  extra_rdoc_files: []
29
-
30
- files:
31
- - lib/port-a-query/default.rb
32
- - lib/port-a-query/mysql.rb
33
- - lib/port-a-query/port-a-query.rb
34
- - lib/port-a-query/sqlite3.rb
19
+ files:
20
+ - lib/port-a-query/version.rb
21
+ - lib/port-a-query/adapters/default.rb
22
+ - lib/port-a-query/adapters/mysql.rb
23
+ - lib/port-a-query/adapters/sqlite3.rb
35
24
  - lib/port-a-query.rb
36
- has_rdoc: true
37
25
  homepage: http://obledesign.com
38
26
  licenses: []
39
-
40
27
  post_install_message:
41
28
  rdoc_options: []
42
-
43
- require_paths:
29
+ require_paths:
44
30
  - lib
45
- required_ruby_version: !ruby/object:Gem::Requirement
31
+ required_ruby_version: !ruby/object:Gem::Requirement
46
32
  none: false
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 0
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
38
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
63
43
  requirements: []
64
-
65
44
  rubyforge_project:
66
- rubygems_version: 1.3.7
45
+ rubygems_version: 1.8.7
67
46
  signing_key:
68
47
  specification_version: 3
69
48
  summary: SQL query portability helpers
70
49
  test_files: []
71
-
@@ -1,34 +0,0 @@
1
- module PortAQuery
2
-
3
- # Symbols should be used for field names, everything else will be quoted as a string
4
-
5
- def self.method_missing(name, *args)
6
-
7
- adapter_class = self.adapter_class
8
-
9
- if adapter_class.respond_to?(name)
10
- adapter_class.send(name, *args)
11
- else
12
- Default.send(name, *args)
13
- end
14
-
15
- end
16
-
17
- protected
18
-
19
- def self.adapter
20
- ActiveRecord::Base.configurations[RAILS_ENV]['adapter']
21
- end
22
-
23
- def self.adapter_class
24
-
25
- case self.adapter.to_sym
26
- when :sqlite3
27
- return SqLite3
28
- when :mysql
29
- return MySql
30
- end
31
-
32
- end
33
-
34
- end