effective_slugs 0.1 → 1.0.0

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: 3dfb5564879f29db8bf15459160f2e29a4307845
4
+ data.tar.gz: 4a995a792f311a2aa13675bcf71a364f21433272
5
+ SHA512:
6
+ metadata.gz: a263b6aa15b529a7da2dbe4cc69c3e17b4f8f1113efd4bb34cced03322d717b40b809afc2721bdb7f4a2fc40f8461aefbe2458b53adda7dc9012fca92e2d11a2
7
+ data.tar.gz: 29f798fe97ebcb6ccbff2a05eab7fb75f3059465abf96e63a7b741e7525812639b20699c7661cfb4d86b4820d92a8a3b200bdb774d6d10cb68370fbfd48fc96d
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 Code and Effect Inc.
1
+ Copyright 2014 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Effective Slugs
2
2
 
3
- Generates a URL-appropriate slug, as required, when saving a record.
3
+ Automatically generate URL-appropriate slugs when saving a record. Rails 3 only.
4
4
 
5
5
  Also overrides ActiveRecord .find() methods to accept the slug, or an id as the parameter.
6
6
 
@@ -109,15 +109,16 @@ Post.where(:slug => 'my-first-post').first
109
109
 
110
110
  ## License
111
111
 
112
- MIT License. Copyright Code and Effect Inc. http://www.codeandeffect.com
112
+ MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
113
+
114
+ Code and Effect is the product arm of [AgileStyle](http://www.agilestyle.com/), an Edmonton-based shop that specializes in building custom web applications with Ruby on Rails.
113
115
 
114
- You are not granted rights or licenses to the trademarks of Code and Effect
115
116
 
116
117
  ## Credits
117
118
 
118
119
  Some of the code in this gem was inspired by an old version of FriendlyId (https://github.com/FriendlyId/friendly_id)
119
120
 
120
- ### Testing
121
+ ## Testing
121
122
 
122
123
  The test suite for this gem is unfortunately not yet complete.
123
124
 
@@ -126,3 +127,15 @@ Run tests by:
126
127
  ```ruby
127
128
  rake spec
128
129
  ```
130
+
131
+
132
+ ## Contributing
133
+
134
+ 1. Fork it
135
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
136
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
137
+ 4. Push to the branch (`git push origin my-new-feature`)
138
+ 5. Bonus points for test coverage
139
+ 6. Create new Pull Request
140
+
141
+
@@ -58,10 +58,9 @@ module ActsAsSluggable
58
58
  included do
59
59
  before_validation :set_slug, :if => proc { should_generate_new_slug? }
60
60
 
61
- #attr_accessible :slug
62
61
  validates_presence_of :slug
63
62
  validates_exclusion_of :slug, :in => EffectiveSlugs.all_excluded_slugs
64
- validates_format_of :slug, :with => /^[a-zA-Z0-9_\-]*[a-zA-Z][a-zA-Z0-9_\-]*$/, :message => 'only _ and - symbols allowed'
63
+ validates_format_of :slug, :with => /\A[a-zA-Z0-9_-]*\z/, :message => 'only _ and - symbols allowed'
65
64
 
66
65
  if @acts_as_sluggable_opts[:validation_scope]
67
66
  validates_uniqueness_of :slug, :scope => @acts_as_sluggable_opts[:validation_scope]
@@ -69,64 +68,6 @@ module ActsAsSluggable
69
68
  validates_uniqueness_of :slug
70
69
  end
71
70
 
72
- class_eval do
73
- class << self
74
- alias relation_without_sluggable relation
75
- end
76
-
77
- def self.relation
78
- @relation = nil unless @relation.class <= relation_class
79
- @relation ||= relation_class.new(self, arel_table)
80
- end
81
-
82
- # Gets an anonymous subclass of the model's relation class.
83
- # This should increase long term compatibility with any gems that also override finder methods
84
- # The other idea would be to just return Class.new(ActiveRecord::Relation)
85
-
86
- def self.relation_class
87
- @relation_class ||= Class.new(relation_without_sluggable.class) do
88
- alias_method :find_one_without_sluggable, :find_one
89
- alias_method :exists_without_sluggable?, :exists?
90
- include ActsAsSluggable::FinderMethods
91
- end
92
- end
93
- end
94
- end
95
-
96
- module ClassMethods
97
- end
98
-
99
- # We inject these methods into the ActsAsSluggable.relation class, as below
100
- # Allows us to use sluggable id's identically to numeric ids in Finders
101
- # And lets all the pages_path() type stuff work
102
- #
103
- # This makes all these the same:
104
- # Post.find(3) == Post.find('post-slug') == Post.find(post)
105
- module FinderMethods
106
- protected
107
-
108
- # Find one can be passed 4, "my-slug" or <Object>
109
- def find_one(id)
110
- begin
111
- if id.respond_to?(:slug)
112
- where(:slug => id.slug).first
113
- elsif id.kind_of?(String)
114
- where(:slug => id).first
115
- end || super
116
- rescue => e
117
- super
118
- end
119
- end
120
-
121
- def exists?(id = false)
122
- if id.respond_to?(:slug)
123
- super :slug => id.slug
124
- elsif id.kind_of?(String)
125
- super :slug => id
126
- else
127
- super
128
- end
129
- end
130
71
  end
131
72
 
132
73
  def set_slug
@@ -160,7 +101,7 @@ module ActsAsSluggable
160
101
  end
161
102
 
162
103
  def to_param
163
- slug.present? ? slug_was : id.to_s
104
+ (slug.present? rescue false) ? "#{id}-#{slug_was}" : super
164
105
  end
165
106
 
166
107
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveSlugs
2
- VERSION = "0.1"
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,121 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_slugs
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Code and Effect
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '3.2'
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
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rspec-rails
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '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: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: factory_girl_rails
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
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: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: psych
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: sqlite3
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- description: Generates a URL-appropriate slug, as required, when saving a record.
95
- Also overrides ActiveRecord .find() methods to accept the slug, or an id as the
96
- parameter.
26
+ version: '3.2'
27
+ description: Automatically generate URL-appropriate slugs when saving a record. Rails
28
+ 3 only.
97
29
  email:
98
30
  - info@codeandeffect.com
99
31
  executables: []
100
32
  extensions: []
101
33
  extra_rdoc_files: []
102
34
  files:
35
+ - MIT-LICENSE
36
+ - README.md
37
+ - Rakefile
103
38
  - app/models/concerns/acts_as_sluggable.rb
39
+ - lib/effective_slugs.rb
104
40
  - lib/effective_slugs/engine.rb
105
41
  - lib/effective_slugs/version.rb
106
- - lib/effective_slugs.rb
107
42
  - lib/generators/effective_slugs/install_generator.rb
108
- - lib/generators/templates/effective_slugs.rb
109
43
  - lib/generators/templates/README
44
+ - lib/generators/templates/effective_slugs.rb
110
45
  - lib/tasks/effective_slugs_tasks.rake
111
- - MIT-LICENSE
112
- - Rakefile
113
- - README.md
46
+ - spec/dummy/README.rdoc
47
+ - spec/dummy/Rakefile
114
48
  - spec/dummy/app/assets/javascripts/application.js
115
49
  - spec/dummy/app/assets/stylesheets/application.css
116
50
  - spec/dummy/app/controllers/application_controller.rb
117
51
  - spec/dummy/app/helpers/application_helper.rb
118
52
  - spec/dummy/app/views/layouts/application.html.erb
53
+ - spec/dummy/config.ru
119
54
  - spec/dummy/config/application.rb
120
55
  - spec/dummy/config/boot.rb
121
56
  - spec/dummy/config/database.yml
@@ -131,46 +66,39 @@ files:
131
66
  - spec/dummy/config/initializers/wrap_parameters.rb
132
67
  - spec/dummy/config/locales/en.yml
133
68
  - spec/dummy/config/routes.rb
134
- - spec/dummy/config.ru
135
- - spec/dummy/db/development.sqlite3
136
69
  - spec/dummy/db/schema.rb
137
- - spec/dummy/db/test.sqlite3
138
- - spec/dummy/log/development.log
139
- - spec/dummy/log/test.log
140
70
  - spec/dummy/public/404.html
141
71
  - spec/dummy/public/422.html
142
72
  - spec/dummy/public/500.html
143
73
  - spec/dummy/public/favicon.ico
144
- - spec/dummy/Rakefile
145
- - spec/dummy/README.rdoc
146
74
  - spec/dummy/script/rails
147
75
  - spec/effective_slugs_spec.rb
148
76
  - spec/spec_helper.rb
149
77
  - spec/support/factories.rb
150
78
  homepage: https://github.com/code-and-effect/effective_slugs
151
79
  licenses: []
80
+ metadata: {}
152
81
  post_install_message:
153
82
  rdoc_options: []
154
83
  require_paths:
155
84
  - lib
156
85
  required_ruby_version: !ruby/object:Gem::Requirement
157
- none: false
158
86
  requirements:
159
- - - ! '>='
87
+ - - ">="
160
88
  - !ruby/object:Gem::Version
161
89
  version: '0'
162
90
  required_rubygems_version: !ruby/object:Gem::Requirement
163
- none: false
164
91
  requirements:
165
- - - ! '>='
92
+ - - ">="
166
93
  - !ruby/object:Gem::Version
167
94
  version: '0'
168
95
  requirements: []
169
96
  rubyforge_project:
170
- rubygems_version: 1.8.25
97
+ rubygems_version: 2.4.3
171
98
  signing_key:
172
- specification_version: 3
173
- summary: Effectively create url-appropriate slugs for any object
99
+ specification_version: 4
100
+ summary: Automatically generate URL-appropriate slugs when saving a record. Rails
101
+ 3 only.
174
102
  test_files:
175
103
  - spec/dummy/app/assets/javascripts/application.js
176
104
  - spec/dummy/app/assets/stylesheets/application.css
@@ -193,11 +121,7 @@ test_files:
193
121
  - spec/dummy/config/locales/en.yml
194
122
  - spec/dummy/config/routes.rb
195
123
  - spec/dummy/config.ru
196
- - spec/dummy/db/development.sqlite3
197
124
  - spec/dummy/db/schema.rb
198
- - spec/dummy/db/test.sqlite3
199
- - spec/dummy/log/development.log
200
- - spec/dummy/log/test.log
201
125
  - spec/dummy/public/404.html
202
126
  - spec/dummy/public/422.html
203
127
  - spec/dummy/public/500.html
@@ -208,4 +132,3 @@ test_files:
208
132
  - spec/effective_slugs_spec.rb
209
133
  - spec/spec_helper.rb
210
134
  - spec/support/factories.rb
211
- has_rdoc:
Binary file
Binary file
@@ -1,6 +0,0 @@
1
- Connecting to database specified by database.yml
2
-  (1.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3
-  (0.1ms) SELECT version FROM "schema_migrations"
4
- Connecting to database specified by database.yml
5
-  (1.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6
-  (0.1ms) SELECT version FROM "schema_migrations"
@@ -1,2 +0,0 @@
1
- Connecting to database specified by database.yml
2
- Connecting to database specified by database.yml