coercionlogic 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2debf064f6f92e1d7c3fd4b1eb96849c96008a96
4
+ data.tar.gz: 7ebc67978fa6efd003502051ce5e55b79ccd9eea
5
+ SHA512:
6
+ metadata.gz: e1d0c4cb8894ee68ec3711c49df4b9d9b843fc4b411331dc40ed7cea06a7c8aa57a604f0b57f587d67195851007ee0f7c43217e9c2c44e6d8965ce3f5dfdbf5a
7
+ data.tar.gz: 141a40a97c997f7e76e3a1918458a9cf94c076f235d4666e37d88008b5101da85e4286d5848a61e6b12f812e3b60e4c23bef54f56f8707dd27019d1f32a41839
data/README.rdoc CHANGED
@@ -1,6 +1,9 @@
1
1
  = Coercionlogic
2
2
 
3
- Extremely simple module to coerce blank strings into nil objects for ActiveRecord.
3
+ Extremely simple module to coerce blank strings into nil objects for ActiveRecord to create consistency in your database data. It keeps you from having to write query conditions like:
4
4
 
5
+ name = '' OR name IS NULL
6
+
7
+ This library is part of my attempt to start pulling out common code in my applications and sharing them via gems.
5
8
 
6
9
  Copyright (c) 2008 {Ben Johnson of Binary Logic}[http://www.binarylogic.com], released under the MIT license
data/Rakefile CHANGED
@@ -1,25 +1,8 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "coercionlogic"
8
- gem.summary = "Coerce blank strings into nil objects for ActiveRecord"
9
- gem.description = "Coerce blank strings into nil objects for ActiveRecord"
10
- gem.email = "bjohnson@binarylogic.com"
11
- gem.homepage = "http://github.com/binarylogic/coercionlogic"
12
- gem.authors = ["binarylogic"]
13
- gem.rubyforge_project = "coercionlogic"
14
- gem.add_dependency "activerecord"
15
- gem.add_development_dependency "rspec"
16
- end
17
- Jeweler::RubyforgeTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
- end
21
-
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ Bundler.setup
22
4
  require 'spec/rake/spectask'
5
+
23
6
  Spec::Rake::SpecTask.new(:spec) do |spec|
24
7
  spec.libs << 'lib' << 'spec'
25
8
  spec.spec_files = FileList['spec/**/*_spec.rb']
@@ -31,20 +14,4 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
14
  spec.rcov = true
32
15
  end
33
16
 
34
- task :spec => :check_dependencies
35
-
36
17
  task :default => :spec
37
-
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- if File.exist?('VERSION')
41
- version = File.read('VERSION')
42
- else
43
- version = ""
44
- end
45
-
46
- rdoc.rdoc_dir = 'rdoc'
47
- rdoc.title = "coercionlogic #{version}"
48
- rdoc.rdoc_files.include('README*')
49
- rdoc.rdoc_files.include('lib/**/*.rb')
50
- end
data/lib/coercionlogic.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'activerecord'
1
+ require 'active_record'
2
2
 
3
3
  module Coercionlogic
4
4
  def write_attribute_with_coercion(attr_name, value)
@@ -8,4 +8,11 @@ describe "Coercionlogic" do
8
8
  user.reload
9
9
  user.name.should be_nil
10
10
  end
11
+
12
+ it "should work when creating off of associations" do
13
+ company = Company.create
14
+ user = company.users.create(:name => "")
15
+ user.reload
16
+ user.name.should be_nil
17
+ end
11
18
  end
data/spec/spec_helper.rb CHANGED
@@ -5,19 +5,31 @@ require 'spec/autorun'
5
5
  require 'rubygems'
6
6
  require 'coercionlogic'
7
7
 
8
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
8
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
9
9
  ActiveRecord::Base.configurations = true
10
10
 
11
11
  ActiveRecord::Schema.verbose = false
12
12
  ActiveRecord::Schema.define(:version => 1) do
13
+ create_table :companies do |t|
14
+ t.datetime :created_at
15
+ t.datetime :updated_at
16
+ t.string :name
17
+ end
18
+
13
19
  create_table :users do |t|
14
20
  t.datetime :created_at
15
21
  t.datetime :updated_at
22
+ t.integer :company_id
16
23
  t.string :name
17
24
  end
18
25
  end
19
26
 
27
+ class Company < ActiveRecord::Base
28
+ has_many :users
29
+ end
30
+
20
31
  class User < ActiveRecord::Base
32
+ belongs_to :company
21
33
  end
22
34
 
23
35
  Spec::Runner.configure do |config|
metadata CHANGED
@@ -1,83 +1,109 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: coercionlogic
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
5
  platform: ruby
6
- authors:
7
- - binarylogic
6
+ authors:
7
+ - Ben Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2009-08-12 00:00:00 -04:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
17
20
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
21
38
  - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
26
42
  name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.1
27
48
  type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
31
59
  - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
35
69
  description: Coerce blank strings into nil objects for ActiveRecord
36
- email: bjohnson@binarylogic.com
70
+ email:
71
+ - bjohnson@binarylogic.com
37
72
  executables: []
38
-
39
73
  extensions: []
40
-
41
- extra_rdoc_files:
42
- - LICENSE
43
- - README.rdoc
44
- files:
45
- - .document
46
- - .gitignore
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".document"
77
+ - ".gitignore"
47
78
  - LICENSE
48
79
  - README.rdoc
49
80
  - Rakefile
50
81
  - lib/coercionlogic.rb
51
82
  - spec/coercionlogic_spec.rb
52
83
  - spec/spec_helper.rb
53
- has_rdoc: true
54
84
  homepage: http://github.com/binarylogic/coercionlogic
55
85
  licenses: []
56
-
86
+ metadata: {}
57
87
  post_install_message:
58
- rdoc_options:
59
- - --charset=UTF-8
60
- require_paths:
88
+ rdoc_options: []
89
+ require_paths:
61
90
  - lib
62
- required_ruby_version: !ruby/object:Gem::Requirement
63
- requirements:
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
64
93
  - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
67
- version:
68
- required_rubygems_version: !ruby/object:Gem::Requirement
69
- requirements:
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
70
98
  - - ">="
71
- - !ruby/object:Gem::Version
72
- version: "0"
73
- version:
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
74
101
  requirements: []
75
-
76
- rubyforge_project: coercionlogic
77
- rubygems_version: 1.3.5
102
+ rubyforge_project:
103
+ rubygems_version: 2.2.0
78
104
  signing_key:
79
- specification_version: 3
105
+ specification_version: 4
80
106
  summary: Coerce blank strings into nil objects for ActiveRecord
81
- test_files:
107
+ test_files:
82
108
  - spec/coercionlogic_spec.rb
83
109
  - spec/spec_helper.rb