auto_strip_attributes 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a7ac55106cdf488624097278556284e5cced729
4
+ data.tar.gz: 91d718d5d9fc16cf949e4cc8f8d646359ab550e7
5
+ SHA512:
6
+ metadata.gz: c629d3df637f944d64511d5d141b347c4d5f292bf20463810509a9730a0452b2b42af9695d2b9e66cb80fc7ebfe4eb3a4ce164c5cca5f737454efc3e2e1229be
7
+ data.tar.gz: 2ee77d6310f7b362448ff27bf8128897d8b054e6e60890785d1c1e147936f07b9f1273965e45f07e0344b0a223a4e2ba7bdda33f689a4b0b5b4c11e938733ca2
@@ -1,6 +1,6 @@
1
1
  rvm:
2
- - 1.8.7 # (current default)
3
- - 1.9.2
4
- gemfile:
5
- - gemfiles/Gemfile.rails-3.1.x
6
- - gemfiles/Gemfile.rails-3.0.x
2
+ - 1.9.3
3
+ - 2.1
4
+ env:
5
+ - "RAILS_VERSION=3.2.16"
6
+ - "RAILS_VERSION=4.0.2"
data/Gemfile CHANGED
@@ -2,3 +2,17 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in auto_strip_attributes.gemspec
4
4
  gemspec
5
+
6
+
7
+ # For travis testing
8
+ # http://schneems.com/post/50991826838/testing-against-multiple-rails-versions
9
+ rails_version = ENV["RAILS_VERSION"] || "default"
10
+
11
+ rails = case rails_version
12
+ when "default"
13
+ ">= 3.2"
14
+ else
15
+ "~> #{rails_version}"
16
+ end
17
+
18
+ gem "rails", rails
data/README.md CHANGED
@@ -20,10 +20,10 @@ gem "auto_strip_attributes", "~> 2.0"
20
20
  ```ruby
21
21
  class User < ActiveRecord::Base
22
22
 
23
- # Normal usage where " aaa bbb\t " changes to "aaa bbb"
23
+ # Normal usage where " aaa bbb\t " changes to "aaa bbb"
24
24
  auto_strip_attributes :nick, :comment
25
25
 
26
- # Squeezes spaces inside the string: "James Bond " => "James Bond"
26
+ # Squeezes spaces inside the string: "James Bond " => "James Bond"
27
27
  auto_strip_attributes :name, :squish => true
28
28
 
29
29
  # Won't set to null even if string is blank. " " => ""
@@ -36,6 +36,7 @@ end
36
36
 
37
37
  By default the following filters are defined (listed in the order of processing):
38
38
 
39
+ - :convert_non_breaking_spaces (disabled by default) - converts non-breaking spaces to normal spaces (Unicode U+00A0)
39
40
  - :strip (enabled by default) - removes whitespaces from the beginning and the end of string
40
41
  - :nullify (enabled by default) - replaces empty strings with nil
41
42
  - :squish (disabled by default) - replaces extra whitespaces (including tabs) with one space
@@ -96,7 +97,7 @@ AutoStripAttributes::Config.setup accepts following options
96
97
 
97
98
  # Requirements
98
99
 
99
- Gem has been tested with ruby 1.8.7, 1.9.2 and Rails 3.x. Although it should also work with previous versions of rails.
100
+ Gem has been tested with Ruby 1.9.3, Ruby 2.1, Rails 3.2 and Rails 4.0. Although it should also work with previous versions of rails.
100
101
 
101
102
  [<img src="https://secure.travis-ci.org/holli/auto_strip_attributes.png" />](http://travis-ci.org/holli/auto_strip_attributes)
102
103
 
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_runtime_dependency "activerecord", ">= 3.0"
24
24
 
25
- s.add_development_dependency "activerecord", ">= 3.0"
26
- s.add_development_dependency "minitest", "~> 2.8.1"
27
- s.add_development_dependency "mocha", "~> 0.9.12"
25
+ #s.add_development_dependency "activerecord", ">= 3.0"
26
+ #s.add_development_dependency "minitest", ">= 2.8.1"
27
+ s.add_development_dependency "mocha", "~> 0.14"
28
28
  s.add_development_dependency 'rake'
29
29
 
30
30
  end
@@ -42,6 +42,9 @@ class AutoStripAttributes::Config
42
42
  @filters_order ||= []
43
43
 
44
44
  if options[:defaults]
45
+ set_filter :convert_non_breaking_spaces => false do |value|
46
+ value.respond_to?(:gsub) ? value.gsub("\u00A0", " ") : value
47
+ end
45
48
  set_filter :strip => true do |value|
46
49
  value.respond_to?(:strip) ? value.strip : value
47
50
  end
@@ -1,3 +1,3 @@
1
1
  module AutoStripAttributes
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
@@ -6,7 +6,7 @@ require 'minitest/autorun'
6
6
  require 'minitest/spec'
7
7
  require "active_record"
8
8
  require "auto_strip_attributes"
9
- require 'mocha'
9
+ require 'mocha/setup'
10
10
 
11
11
  # if you need debug, add relevant line to auto_strip_attributes.gemspec
12
12
  # s.add_development_dependency 'ruby-debug'
@@ -35,7 +35,7 @@ end
35
35
  describe AutoStripAttributes do
36
36
 
37
37
  def setup
38
- @init_params = { :foo => "\tfoo ", :bar => " bar bar "}
38
+ @init_params = {:foo => "\tfoo ", :bar => " bar bar "}
39
39
  end
40
40
 
41
41
  it "should have defined AutoStripAttributes" do
@@ -55,6 +55,21 @@ describe AutoStripAttributes do
55
55
  @record.foo.must_equal "aaa"
56
56
  end
57
57
 
58
+ it "should not delete non breaking spaces" do
59
+ @record = MockRecordBasic.new()
60
+ @record.foo = " aaa \t\u00A0"
61
+ @record.valid?
62
+ @record.foo.must_equal "aaa \t\u00A0"
63
+ end
64
+
65
+ it "should be ok for normal strings and not squish things" do
66
+ @record = MockRecordBasic.new()
67
+ @record.foo = " aaa bbb "
68
+ @record.valid?
69
+ @record.foo.must_equal "aaa bbb"
70
+ end
71
+
72
+
58
73
  it "should set empty strings to nil" do
59
74
  @record = MockRecordBasic.new()
60
75
  @record.foo = " "
@@ -95,6 +110,23 @@ describe AutoStripAttributes do
95
110
  end
96
111
  end
97
112
 
113
+ describe "Attribute with convert non breaking spaces option" do
114
+ #class MockRecordWithConvertNBSP < ActiveRecord::Base
115
+ class MockRecordWithConvertNBSP < MockRecordParent
116
+ #column :foo, :string
117
+ attr_accessor :foo
118
+ auto_strip_attributes :foo, :convert_non_breaking_spaces => true
119
+ end
120
+
121
+ it "should delete non breaking spaces" do
122
+ @record = MockRecordWithConvertNBSP.new()
123
+ @record.foo = " aaa \t\u00A0"
124
+ @record.valid?
125
+ @record.foo.must_equal "aaa"
126
+ end
127
+
128
+ end
129
+
98
130
  describe "Attribute with nullify option" do
99
131
  #class MockRecordWithNullify < ActiveRecord::Base
100
132
  class MockRecordWithNullify < MockRecordParent
@@ -199,7 +231,7 @@ describe AutoStripAttributes do
199
231
  it "should have default filters set in right order" do
200
232
  AutoStripAttributes::Config.setup :clear => true
201
233
  filters_order = AutoStripAttributes::Config.filters_order
202
- filters_order.must_equal [:strip, :nullify, :squish, :delete_whitespaces]
234
+ filters_order.must_equal [:convert_non_breaking_spaces, :strip, :nullify, :squish, :delete_whitespaces]
203
235
  end
204
236
 
205
237
  it "should reset filters to defaults when :clear is true" do
@@ -210,7 +242,7 @@ describe AutoStripAttributes do
210
242
  end
211
243
  AutoStripAttributes::Config.setup :clear => true
212
244
  filters_order = AutoStripAttributes::Config.filters_order
213
- filters_order.must_equal [:strip, :nullify, :squish, :delete_whitespaces]
245
+ filters_order.must_equal [:convert_non_breaking_spaces, :strip, :nullify, :squish, :delete_whitespaces]
214
246
  end
215
247
 
216
248
  it "should remove all filters when :clear is true and :defaults is false" do
@@ -243,7 +275,7 @@ describe AutoStripAttributes do
243
275
  filters_order = AutoStripAttributes::Config.filters_order
244
276
  filters_enabled = AutoStripAttributes::Config.filters_enabled
245
277
 
246
- filters_order.must_equal [:strip, :nullify, :squish, :delete_whitespaces, :test]
278
+ filters_order.must_equal [:convert_non_breaking_spaces, :strip, :nullify, :squish, :delete_whitespaces, :test]
247
279
  assert Proc === filters_block[:test]
248
280
  filters_enabled[:test].must_equal true
249
281
 
@@ -288,7 +320,7 @@ describe AutoStripAttributes do
288
320
  @record.valid?
289
321
  @record.foo.must_equal "FOO"
290
322
  end
291
-
323
+
292
324
  it "should use extra filters when given" do
293
325
  @record = ComplexFirstMockRecord.new
294
326
  @record.bar_downcase = " BAR "
metadata CHANGED
@@ -1,94 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_strip_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
5
- prerelease:
4
+ version: 2.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Olli Huotari
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-04 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.0'
30
- - !ruby/object:Gem::Dependency
31
- name: activerecord
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '3.0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '3.0'
46
- - !ruby/object:Gem::Dependency
47
- name: minitest
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 2.8.1
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 2.8.1
62
27
  - !ruby/object:Gem::Dependency
63
28
  name: mocha
64
29
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
30
  requirements:
67
- - - ~>
31
+ - - "~>"
68
32
  - !ruby/object:Gem::Version
69
- version: 0.9.12
33
+ version: '0.14'
70
34
  type: :development
71
35
  prerelease: false
72
36
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
37
  requirements:
75
- - - ~>
38
+ - - "~>"
76
39
  - !ruby/object:Gem::Version
77
- version: 0.9.12
40
+ version: '0.14'
78
41
  - !ruby/object:Gem::Dependency
79
42
  name: rake
80
43
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
44
  requirements:
83
- - - ! '>='
45
+ - - ">="
84
46
  - !ruby/object:Gem::Version
85
47
  version: '0'
86
48
  type: :development
87
49
  prerelease: false
88
50
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
51
  requirements:
91
- - - ! '>='
52
+ - - ">="
92
53
  - !ruby/object:Gem::Version
93
54
  version: '0'
94
55
  description: AutoStripAttributes helps to remove unnecessary whitespaces from ActiveRecord
@@ -101,41 +62,38 @@ executables: []
101
62
  extensions: []
102
63
  extra_rdoc_files: []
103
64
  files:
104
- - .gitignore
105
- - .travis.yml
65
+ - ".gitignore"
66
+ - ".travis.yml"
106
67
  - Gemfile
107
68
  - README.md
108
69
  - Rakefile
109
70
  - auto_strip_attributes.gemspec
110
- - gemfiles/Gemfile.rails-3.0.x
111
- - gemfiles/Gemfile.rails-3.1.x
112
71
  - lib/auto_strip_attributes.rb
113
72
  - lib/auto_strip_attributes/version.rb
114
73
  - test/auto_strip_attributes_test.rb
115
74
  homepage: https://github.com/holli/auto_strip_attributes
116
75
  licenses:
117
76
  - MIT
77
+ metadata: {}
118
78
  post_install_message:
119
79
  rdoc_options: []
120
80
  require_paths:
121
81
  - lib
122
82
  required_ruby_version: !ruby/object:Gem::Requirement
123
- none: false
124
83
  requirements:
125
- - - ! '>='
84
+ - - ">="
126
85
  - !ruby/object:Gem::Version
127
86
  version: '0'
128
87
  required_rubygems_version: !ruby/object:Gem::Requirement
129
- none: false
130
88
  requirements:
131
- - - ! '>='
89
+ - - ">="
132
90
  - !ruby/object:Gem::Version
133
91
  version: '0'
134
92
  requirements: []
135
93
  rubyforge_project: auto_strip_attributes
136
- rubygems_version: 1.8.25
94
+ rubygems_version: 2.3.0
137
95
  signing_key:
138
- specification_version: 3
96
+ specification_version: 4
139
97
  summary: Removes unnecessary whitespaces in attributes. Extension to ActiveRecord
140
98
  or ActiveModel.
141
99
  test_files: []
@@ -1,8 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # This is for testing with rails 3.0
4
-
5
- gem 'rake'
6
- gem "activerecord", "~> 3.0.0"
7
- gem "minitest", "2.6.0"
8
- gem "mocha", "~> 0.9.12"
@@ -1,8 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # This is for testing with rails 3.0
4
-
5
- gem 'rake'
6
- gem "activerecord", "~> 3.0.0"
7
- gem "minitest", "2.6.0"
8
- gem "mocha", "~> 0.9.12"