acts_as_stripped 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ rdoc
5
5
  pkg
6
6
  *.sqlite3
7
7
  *.log
8
+ test/*.log
@@ -4,22 +4,12 @@ Simple utility to strip whitespace from string attributes.
4
4
 
5
5
  = Installation
6
6
 
7
- Command line installation
8
-
9
- sudo gem install wireframe-acts_as_stripped
10
-
11
- Rails environment.rb configuration
12
-
13
- config.gem 'wireframe-acts_as_stripped', :source => 'http://gems.github.com', :lib => 'acts_as_stripped'
7
+ Bundler configuration
8
+ gem 'acts_as_stripped'
14
9
 
15
10
  = Usage
16
11
 
17
- # strip whitespace from *all* string attributes
18
- class User < ActiveRecord::Base
19
- acts_as_stripped
20
- end
21
-
22
- # strip whitespace from *select* string attributes
12
+ # strip whitespace from specified string attributes
23
13
  class Post < ActiveRecord::Base
24
14
  acts_as_stripped :title, :summary
25
15
  end
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.authors = ["Ryan Sonnek"]
12
12
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
13
  end
14
-
14
+ Jeweler::GemcutterTasks.new
15
15
  rescue LoadError
16
16
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
17
  end
@@ -1,4 +1,5 @@
1
- ---
2
- :major: 0
3
- :minor: 1
4
- :patch: 1
1
+ ---
2
+ :major: 1
3
+ :build:
4
+ :minor: 0
5
+ :patch: 0
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{acts_as_stripped}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Sonnek"]
12
+ s.date = %q{2010-06-15}
13
+ s.email = %q{ryan.sonnek@gmail.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION.yml",
25
+ "acts_as_stripped.gemspec",
26
+ "lib/acts_as_stripped.rb",
27
+ "test/acts_as_stripped_test.rb",
28
+ "test/database.yml",
29
+ "test/test_helper.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/wireframe/acts_as_stripped}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{strip whitespace from string attributes}
36
+ s.test_files = [
37
+ "test/acts_as_stripped_test.rb",
38
+ "test/test_helper.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ else
47
+ end
48
+ else
49
+ end
50
+ end
51
+
@@ -21,13 +21,10 @@ module ActsAsStripped
21
21
  module InstanceMethods
22
22
  private
23
23
  def strip_fields
24
- strippable_attributes.each do |attr|
25
- self[attr.to_s].strip!
24
+ self.acts_as_stripped_attributes.each do |attr|
25
+ self[attr.to_s].strip! unless self[attr.to_s].nil?
26
26
  end
27
27
  end
28
- def strippable_attributes
29
- self.acts_as_stripped_attributes || self.attributes.keys.select {|attr| self[attr].respond_to?(:strip!) }
30
- end
31
28
  end
32
29
  end
33
30
 
@@ -1,52 +1,39 @@
1
1
  require 'test_helper'
2
2
 
3
3
  ActiveRecord::Schema.define(:version => 1) do
4
- create_table :users, :force => true do |t|
5
- t.column :first_name, :string
6
- t.column :last_name, :string
7
- t.column :logged_in_at, :datetime
8
- end
9
4
  create_table :posts, :force => true do |t|
10
5
  t.column :title, :string
11
6
  t.column :body, :string
12
7
  end
13
8
  end
14
9
 
15
- class User < ActiveRecord::Base
16
- acts_as_stripped
17
- end
18
-
19
10
  class Post < ActiveRecord::Base
20
11
  acts_as_stripped :title
21
12
  end
22
13
 
23
14
  class ActsAsStrippedTest < Test::Unit::TestCase
24
- context 'a basic user instance' do
25
- setup do
26
- @user = User.new
27
- end
28
- should "strips all string attributes of extra whitespace" do
29
- @user.first_name = ' ryan '
30
- @user.last_name = ' sonnek '
31
- @user.logged_in_at = Time.now
32
-
33
- @user.save!
34
- assert_equal 'ryan', @user.first_name
35
- assert_equal 'sonnek', @user.last_name
36
- end
37
- end
38
-
39
15
  context 'a basic post instance' do
40
16
  setup do
41
17
  @post = Post.new
42
18
  end
43
- should 'strip whitespace only from title' do
19
+ should 'strip whitespace from title' do
44
20
  @post.title = ' hello world '
45
- @post.body = ' awesome '
46
21
  @post.save!
47
22
 
48
23
  assert_equal 'hello world', @post.title
24
+ end
25
+ should 'not strip whitespace from body' do
26
+ @post.body = ' awesome '
27
+ @post.save!
28
+
49
29
  assert_equal ' awesome ', @post.body
50
30
  end
31
+ should 'not fail if title is nil' do
32
+ @post.title = nil
33
+ assert_nothing_raised do
34
+ @post.save!
35
+ end
36
+ assert_nil @post.title
37
+ end
51
38
  end
52
39
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_stripped
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Ryan Sonnek
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-06-25 00:00:00 -06:00
18
+ date: 2010-06-15 00:00:00 -05:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -29,10 +35,10 @@ files:
29
35
  - README.rdoc
30
36
  - Rakefile
31
37
  - VERSION.yml
38
+ - acts_as_stripped.gemspec
32
39
  - lib/acts_as_stripped.rb
33
40
  - test/acts_as_stripped_test.rb
34
41
  - test/database.yml
35
- - test/debug.log
36
42
  - test/test_helper.rb
37
43
  has_rdoc: true
38
44
  homepage: http://github.com/wireframe/acts_as_stripped
@@ -44,24 +50,30 @@ rdoc_options:
44
50
  require_paths:
45
51
  - lib
46
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
47
54
  requirements:
48
55
  - - ">="
49
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
50
60
  version: "0"
51
- version:
52
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
53
63
  requirements:
54
64
  - - ">="
55
65
  - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
56
69
  version: "0"
57
- version:
58
70
  requirements: []
59
71
 
60
72
  rubyforge_project:
61
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.7
62
74
  signing_key:
63
- specification_version: 2
64
- summary: strip whitespace from string attributes (forked and pushed by Daniel Huckstep)
75
+ specification_version: 3
76
+ summary: strip whitespace from string attributes
65
77
  test_files:
66
78
  - test/acts_as_stripped_test.rb
67
79
  - test/test_helper.rb