activerecord-postgres-array 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "activerecord-postgres-array"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.6"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Tim Connor"]
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.rubygems_version = %q{1.3.7}
14
14
  s.summary = s.description
15
15
 
16
- s.add_dependency "rails"
16
+ s.add_dependency "activerecord"
17
17
  s.add_development_dependency 'rake'
18
18
  s.add_development_dependency 'rspec', '~> 2.0'
19
19
  s.add_development_dependency 'pg'
@@ -1,12 +1,16 @@
1
- require 'rails'
1
+ if defined? Rails
2
+ class ActiveRecordPostgresArray < Rails::Railtie
2
3
 
3
- class ActiveRecordPostgresArray < Rails::Railtie
4
-
5
- initializer 'activerecord-postgres-array' do
6
- ActiveSupport.on_load :active_record do
7
- require "activerecord-postgres-array/activerecord"
4
+ initializer 'activerecord-postgres-array' do
5
+ ActiveSupport.on_load :active_record do
6
+ require "activerecord-postgres-array/activerecord"
7
+ end
8
8
  end
9
9
  end
10
+ else
11
+ ActiveSupport.on_load :active_record do
12
+ require "activerecord-postgres-array/activerecord"
13
+ end
10
14
  end
11
15
 
12
16
  require "activerecord-postgres-array/string"
@@ -13,6 +13,8 @@ class Array
13
13
  value = value.gsub(/"/, '\"')
14
14
  value = "\"#{ value }\""
15
15
  value
16
+ elsif value.is_a?(NilClass)
17
+ value = 'NULL'
16
18
  else
17
19
  value
18
20
  end
@@ -22,7 +22,8 @@ class String
22
22
  else
23
23
  elements = match(/\{(.*)\}/).captures.first.gsub(/\\"/, '$ESCAPED_DOUBLE_QUOTE$').split(/(,)(?=(?:[^"]|"[^"]*")*$)/).reject {|e| e == ',' }
24
24
  elements = elements.map do |e|
25
- e.gsub('$ESCAPED_DOUBLE_QUOTE$', '"').gsub("\\\\", "\\").gsub(/^"/, '').gsub(/"$/, '').gsub("''", "'").strip
25
+ res = e.gsub('$ESCAPED_DOUBLE_QUOTE$', '"').gsub("\\\\", "\\").gsub(/^"/, '').gsub(/"$/, '').gsub("''", "'").strip
26
+ res == 'NULL' ? nil : res
26
27
  end
27
28
 
28
29
  if base_type == :decimal
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgres-array
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Connor
@@ -19,7 +19,7 @@ date: 2012-02-08 00:00:00 +13:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rails
22
+ name: activerecord
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false