parameterize 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  source :rubygems
2
2
 
3
+ gem 'parameterize', :path => File.expand_path('../..', __FILE__)
4
+
3
5
  gem 'activerecord', '~> 3.0.0'
4
6
  gem 'activesupport', '~> 3.0.0'
5
7
 
@@ -1,7 +1,9 @@
1
1
  source :rubygems
2
2
 
3
- gem 'activerecord', '~> 3.1.0.rc1'
4
- gem 'activesupport', '~> 3.1.0.rc1'
3
+ gem 'parameterize', :path => File.expand_path('../..', __FILE__)
4
+
5
+ gem 'activerecord', '~> 3.1.0'
6
+ gem 'activesupport', '~> 3.1.0'
5
7
 
6
8
  group :development do
7
9
  gem 'rake', '>= 0.8.7'
data/lib/parameterize.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_record'
1
2
  require 'active_support/core_ext/array/extract_options'
2
3
  require 'active_support/core_ext/string/inflections'
3
4
 
@@ -8,21 +9,21 @@ module Parameterize
8
9
  # @param [Symbol, String] source The field to parameterize
9
10
  def parameterize(source = :title)
10
11
  include InstanceMethods
11
-
12
+
12
13
  class_attribute :param_source_field
13
14
  before_validation :update_param
14
-
15
+
15
16
  self.param_source_field = source
16
17
  end
17
-
18
+
18
19
  module InstanceMethods
19
20
  # Overwrite #to_param to return the generated param.
20
21
  def to_param
21
22
  self.param
22
23
  end
23
-
24
+
24
25
  protected
25
-
26
+
26
27
  # Updates the param field with the parameterized version of the source field.
27
28
  def update_param
28
29
  self.param = __send__(self.class.param_source_field).to_s.parameterize
@@ -30,8 +31,4 @@ module Parameterize
30
31
  end
31
32
  end
32
33
 
33
- if defined?(ActiveRecord)
34
- ActiveRecord::Base.extend Parameterize
35
- elsif defined?(Rails)
36
- require 'parameterize/railtie'
37
- end
34
+ ActiveRecord::Base.extend Parameterize
@@ -1,3 +1,3 @@
1
1
  module Parameterize
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
data/parameterize.gemspec CHANGED
@@ -13,12 +13,12 @@ Gem::Specification.new do |s|
13
13
  s.description = %{It uses ActiveSupport's String#parameterize to create the slug. There are no validations. No slug history. No extra tables or models.}
14
14
 
15
15
  s.rubyforge_project = 'parameterize'
16
-
16
+
17
17
  s.add_dependency 'activerecord', '~> 3.0'
18
18
  s.add_dependency 'activesupport', '~> 3.0'
19
19
  s.add_development_dependency 'rake', '>= 0.8.7'
20
20
  s.add_development_dependency 'rspec', '~> 2.6'
21
- s.add_development_dependency 'sqlite3-ruby', '~> 1.3'
21
+ s.add_development_dependency 'sqlite3', '~> 1.3'
22
22
 
23
23
  s.files = `git ls-files`.split("\n")
24
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
- Bundler.require :default, :development
4
3
  require 'active_record'
4
+ require 'parameterize'
5
5
  require 'parameterize/matcher'
6
6
 
7
- ActiveRecord::Base.extend Parameterize
8
7
  ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
9
8
  ActiveRecord::Migration.verbose = false
10
9
  ActiveRecord::Schema.define :version => 1 do
@@ -12,7 +11,7 @@ ActiveRecord::Schema.define :version => 1 do
12
11
  t.string :title
13
12
  t.string :param
14
13
  end
15
-
14
+
16
15
  create_table :users do |t|
17
16
  t.string :name
18
17
  t.string :param
metadata CHANGED
@@ -1,108 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: parameterize
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Pete Browne
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-30 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: activerecord
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70213142072060 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 7
29
- segments:
30
- - 3
31
- - 0
32
- version: "3.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: activesupport
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70213142072060
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &70213142071520 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
29
+ requirements:
41
30
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 3
46
- - 0
47
- version: "3.0"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
48
33
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rake
52
34
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70213142071520
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70213142071040 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 49
59
- segments:
60
- - 0
61
- - 8
62
- - 7
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
63
43
  version: 0.8.7
64
44
  type: :development
65
- version_requirements: *id003
66
- - !ruby/object:Gem::Dependency
67
- name: rspec
68
45
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70213142071040
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70213142070540 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
51
+ requirements:
72
52
  - - ~>
73
- - !ruby/object:Gem::Version
74
- hash: 15
75
- segments:
76
- - 2
77
- - 6
78
- version: "2.6"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
79
55
  type: :development
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- name: sqlite3-ruby
83
56
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70213142070540
58
+ - !ruby/object:Gem::Dependency
59
+ name: sqlite3
60
+ requirement: &70213142070040 !ruby/object:Gem::Requirement
85
61
  none: false
86
- requirements:
62
+ requirements:
87
63
  - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 9
90
- segments:
91
- - 1
92
- - 3
93
- version: "1.3"
64
+ - !ruby/object:Gem::Version
65
+ version: '1.3'
94
66
  type: :development
95
- version_requirements: *id005
96
- description: It uses ActiveSupport's String#parameterize to create the slug. There are no validations. No slug history. No extra tables or models.
97
- email:
67
+ prerelease: false
68
+ version_requirements: *70213142070040
69
+ description: It uses ActiveSupport's String#parameterize to create the slug. There
70
+ are no validations. No slug history. No extra tables or models.
71
+ email:
98
72
  - me@petebrowne.com
99
73
  executables: []
100
-
101
74
  extensions: []
102
-
103
75
  extra_rdoc_files: []
104
-
105
- files:
76
+ files:
106
77
  - .gitignore
107
78
  - .travis.yml
108
79
  - Gemfile
@@ -113,44 +84,40 @@ files:
113
84
  - gemfiles/Gemfile.activerecord-3.1.x
114
85
  - lib/parameterize.rb
115
86
  - lib/parameterize/matcher.rb
116
- - lib/parameterize/railtie.rb
117
87
  - lib/parameterize/version.rb
118
88
  - parameterize.gemspec
119
89
  - spec/parameterize_spec.rb
120
90
  - spec/spec_helper.rb
121
91
  homepage: http://github.com/petebrowne/parameterize
122
92
  licenses: []
123
-
124
93
  post_install_message:
125
94
  rdoc_options: []
126
-
127
- require_paths:
95
+ require_paths:
128
96
  - lib
129
- required_ruby_version: !ruby/object:Gem::Requirement
97
+ required_ruby_version: !ruby/object:Gem::Requirement
130
98
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- hash: 3
135
- segments:
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ segments:
136
104
  - 0
137
- version: "0"
138
- required_rubygems_version: !ruby/object:Gem::Requirement
105
+ hash: -2472796874914442581
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
107
  none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ segments:
145
113
  - 0
146
- version: "0"
114
+ hash: -2472796874914442581
147
115
  requirements: []
148
-
149
116
  rubyforge_project: parameterize
150
- rubygems_version: 1.8.5
117
+ rubygems_version: 1.8.11
151
118
  signing_key:
152
119
  specification_version: 3
153
120
  summary: The simplest permalink/slug solution for ActiveRecord >= 3.0
154
- test_files:
121
+ test_files:
155
122
  - spec/parameterize_spec.rb
156
123
  - spec/spec_helper.rb
@@ -1,9 +0,0 @@
1
- require 'rails/railtie'
2
-
3
- module Parameterize
4
- class Railtie < Rails::Railtie
5
- initializer 'parameterize.include_macro' do |app|
6
- ActiveRecord::Base.extend Parameterize
7
- end
8
- end
9
- end