normalizr 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35d0bdb1fb701098a4ba14fcc771bac72ccebfc1
4
- data.tar.gz: aef77413b158952855f197d55bcda23f20ceaac9
3
+ metadata.gz: 9f01b405bb0c605fb3d1ee13165c30708a209ac2
4
+ data.tar.gz: 585231449522b519400d785946f8d226fee9a1c2
5
5
  SHA512:
6
- metadata.gz: df5b1e87b4532ec83d9dab7f5c6c6ae98e1926a4938348e42ac2d971d9d937d292e30dae277d5192008903aaa896a1b83c3ce2c63580f874df310b5dbaeb0e65
7
- data.tar.gz: 63226dd5fc98126dc36a7db9812be4333bcaa51bbd7600b9e51b4f27122febc1c390e0f47600654c5e8fa38e30f3a4b33e1c748d853c81cf373a16ce7720774c
6
+ metadata.gz: cfe8b07219b1869ce39d2e9795b98c0bf34af89547274e4e6e22c112ef47df6286be7c2098032584d9c40811280ecfc4ea139bbce4bc53a2a64415f0b8a6cebd
7
+ data.tar.gz: f7ca6b8dc3cc39ae349a753190eb809f734c00334bf22c5a676addd5f0485cc2c822f5801be8180f22d5e08272da66368c7a2bf446eef2da67ea09bfb4767205
data/.travis.yml CHANGED
@@ -1,10 +1,14 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
- - 2.0.0
4
- - 2.1.0
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
5
7
  gemfile:
6
8
  - gemfiles/activerecord-3.2.x.gemfile
9
+ - gemfiles/activerecord-4.0.x.gemfile
7
10
  - gemfiles/activerecord-4.1.x.gemfile
11
+ - gemfiles/activerecord-4.2.x.gemfile
8
12
  addons:
9
13
  code_climate:
10
14
  repo_token: 1cac54041089115a5bf218169b62c76c8b87a5896f5aa973f89637a8553c0376
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 4.0.0'
4
+ gem 'mongoid', '~> 4.0'
5
+ gem 'codeclimate-test-reporter', require: false
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 4.2.0'
4
+ gem 'mongoid', '~> 4.0'
5
+ gem 'codeclimate-test-reporter', require: false
6
+
7
+ gemspec path: '../'
@@ -48,7 +48,9 @@ Normalizr.configure do
48
48
  end
49
49
  end
50
50
 
51
- [:capitalize, :downcase, :strip, :upcase].each do |name|
51
+ [:capitalize, :downcase, :parameterize, :strip, :upcase].each do |name|
52
+ next unless String.method_defined?(name)
53
+
52
54
  add name do |value|
53
55
  if String === value
54
56
  value.send(:"#{name}")
@@ -1,3 +1,3 @@
1
1
  module Normalizr
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -3,36 +3,40 @@ require 'spec_helper'
3
3
  describe Author do
4
4
  context 'Testing the built in normalizers' do
5
5
  # default normalization [ :strip, :blank ]
6
- it { should normalize_attribute(:name) }
7
- it { should normalize_attribute(:name).from(' this ').to('this') }
8
- it { should normalize_attribute(:name).from(' ').to(nil) }
6
+ it { should normalize(:name) }
7
+ it { should normalize(:name).from(' this ').to('this') }
8
+ it { should normalize(:name).from(' ').to(nil) }
9
9
 
10
10
  # :strip normalizer
11
- it { should normalize_attribute(:first_name).from(' this ').to('this') }
12
- it { should normalize_attribute(:first_name).from(' ').to('') }
11
+ it { should normalize(:first_name).from(' this ').to('this') }
12
+ it { should normalize(:first_name).from(' ').to('') }
13
13
 
14
14
  # :squish normalizer
15
- it { should normalize_attribute(:nickname).from(' this nickname ').to('this nickname') }
15
+ it { should normalize(:nickname).from(' this nickname ').to('this nickname') }
16
16
 
17
17
  # :blank normalizer
18
- it { should normalize_attribute(:last_name).from('').to(nil) }
19
- it { should normalize_attribute(:last_name).from(' ').to(nil) }
20
- it { should normalize_attribute(:last_name).from(' this ').to(' this ') }
18
+ it { should normalize(:last_name).from('').to(nil) }
19
+ it { should normalize(:last_name).from(' ').to(nil) }
20
+ it { should normalize(:last_name).from(' this ').to(' this ') }
21
21
 
22
22
  # :whitespace normalizer
23
- it { should normalize_attribute(:biography).from(" this line\nbreak ").to("this line\nbreak") }
24
- it { should normalize_attribute(:biography).from("\tthis\tline\nbreak ").to("this line\nbreak") }
25
- it { should normalize_attribute(:biography).from(" \tthis \tline \nbreak \t \nthis").to("this line\nbreak\nthis") }
26
- it { should normalize_attribute(:biography).from(' ').to('') }
23
+ it { should normalize(:biography).from(" this line\nbreak ").to("this line\nbreak") }
24
+ it { should normalize(:biography).from("\tthis\tline\nbreak ").to("this line\nbreak") }
25
+ it { should normalize(:biography).from(" \tthis \tline \nbreak \t \nthis").to("this line\nbreak\nthis") }
26
+ it { should normalize(:biography).from(' ').to('') }
27
27
 
28
28
  # :control_chars normalizer
29
- it { should normalize_attribute(:bibliography).from("No \bcontrol\u0003 chars").to("No control chars") }
30
- it { should normalize_attribute(:bibliography).from("Except for\tspaces.\r\nAll kinds").to("Except for\tspaces.\r\nAll kinds") }
29
+ it { should normalize(:bibliography).from("No \bcontrol\u0003 chars").to("No control chars") }
30
+ it { should normalize(:bibliography).from("Except for\tspaces.\r\nAll kinds").to("Except for\tspaces.\r\nAll kinds") }
31
+
32
+ # :parameterize normalizer
33
+ it { should normalize(:slug).from("Obi One Kenobi").to("obi-one-kenobi") }
34
+ it { should normalize(:slug).from(" ").to("") }
31
35
  end
32
36
 
33
37
  context 'on default attribute with the default normalizer changed' do
34
- it { should normalize_attribute(:phone_number).from('no-numbers-here').to(nil) }
35
- it { should normalize_attribute(:phone_number).from('1.877.987.9875').to('18779879875') }
36
- it { should normalize_attribute(:phone_number).from('+ 1 (877) 987-9875').to('18779879875') }
38
+ it { should normalize(:phone_number).from('no-numbers-here').to(nil) }
39
+ it { should normalize(:phone_number).from('1.877.987.9875').to('18779879875') }
40
+ it { should normalize(:phone_number).from('+ 1 (877) 987-9875').to('18779879875') }
37
41
  end
38
42
  end
@@ -1,9 +1,10 @@
1
1
  class Author < ActiveRecord::Base
2
- normalize_attribute :name
3
- normalize_attribute :nickname, with: :squish
4
- normalize_attribute :first_name, with: :strip
5
- normalize_attribute :last_name, with: :blank
6
- normalize_attribute :phone_number, with: :phone
7
- normalize_attribute :biography, with: :whitespace
8
- normalize_attribute :bibliography, with: :control_chars
2
+ normalize :name
3
+ normalize :nickname, with: :squish
4
+ normalize :first_name, with: :strip
5
+ normalize :last_name, with: :blank
6
+ normalize :phone_number, with: :phone
7
+ normalize :biography, with: :whitespace
8
+ normalize :bibliography, with: :control_chars
9
+ normalize :slug, with: :parameterize
9
10
  end
@@ -12,6 +12,7 @@ ActiveRecord::Schema.define do
12
12
  t.string :phone_number
13
13
  t.text :biography
14
14
  t.text :bibliography
15
+ t.string :slug
15
16
  end
16
17
 
17
18
  create_table :books, force: true do |t|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalizr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-30 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -152,7 +152,9 @@ files:
152
152
  - README.md
153
153
  - Rakefile
154
154
  - gemfiles/activerecord-3.2.x.gemfile
155
+ - gemfiles/activerecord-4.0.x.gemfile
155
156
  - gemfiles/activerecord-4.1.x.gemfile
157
+ - gemfiles/activerecord-4.2.x.gemfile
156
158
  - lib/normalizr.rb
157
159
  - lib/normalizr/concern.rb
158
160
  - lib/normalizr/configuration.rb
@@ -211,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
213
  version: '0'
212
214
  requirements: []
213
215
  rubyforge_project:
214
- rubygems_version: 2.2.2
216
+ rubygems_version: 2.4.8
215
217
  signing_key:
216
218
  specification_version: 4
217
219
  summary: Writer methods parameters normalization