slugworth 1.0.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8d0d9cc6d5dddc361b06e46ec62babe1b7f2899c
4
- data.tar.gz: 1899d71cb7f912ade4e4c7bf10be1210be93bac5
2
+ SHA256:
3
+ metadata.gz: b2eddb3e353d9f21b578d73fc6d1be2225610b181ff8b894040ba0e01b5aaffa
4
+ data.tar.gz: d39977db71c156734bcd5ea278cf3bcae87260555cb3c235f584decb4abb71a5
5
5
  SHA512:
6
- metadata.gz: cb945a26dcecc920f07b02effb13582c6bfad506ec8c647bdd2ae1be40cd961936d074f107f4cf8d107639e6d9ac6a986e2df02c524bb9fbd40b94293ddb6cfa
7
- data.tar.gz: cfd6f446625a3b27ec775e12c0a3b004824523ae70aedf8ae8de604ef83d4de25ad45eb3651ca5568212884cc6a7a83a1dfcf294b54c436c7ed953e0c4c9c40d
6
+ metadata.gz: 9b81795147c0714e607a86afad35a78bd21716761b105f95efb1e25f851d53fe2a0181a0863001d0eb9096a2fd3531f6dd35d5ad3e3613cf744c55ed439d2fe3
7
+ data.tar.gz: 15496a654fc906d5b070d359e9d874d7030a0510e43bbb912cb16400504260feee62da0afcf79dca72a2ff3541c2f09044f0068855c85e4383e2e572cc2d3a57
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 1.2.1
4
+
5
+ - Bug fix for slug generation on a slug attribute that is nil
6
+
7
+ ## 1.2.0
8
+
9
+ - Uniqueness scoping for a slug
10
+ - Auto incrementing of slug
11
+ - Slugs can be monitored for updates
12
+
13
+ ## 1.1.0
14
+
15
+ - `#find_by_slug` has been changed to `#find_by_slug` to keep in line with AR
16
+ finder syntax
17
+
18
+ ## 1.0.2
19
+
20
+ - [Bug fix] Bypassing validations for `#find_by_slug` spec in shared example.
21
+ This will allow the example group to run in other app test suites without
22
+ worrying about existing validations.
23
+
24
+ ## 1.0.1
25
+
26
+ - [Bug fix] Shared example had `User` class hard coded
27
+
28
+ ## 1.0.0
29
+
30
+ - Initial functionality
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in slugworth.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # Slugworth
1
+ ![Slugworth](http://f.cl.ly/items/3T1K3g040S0u2l0G0d3V/slugworth_header.png)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/slugworth.png)](http://badge.fury.io/rb/sluggle)
4
- [![Build Status](https://travis-ci.org/mattpolito/slugworth.png?branch=master)](https://travis-ci.org/mattpolito/sluggle)
5
- [![Code Climate](https://codeclimate.com/github/mattpolito/slugworth.png)](https://codeclimate.com/github/mattpolito/sluggle)
3
+ [![Gem Version](http://img.shields.io/gem/v/slugworth.svg?style=flat)](http://badge.fury.io/rb/slugworth)
4
+ [![Build Status](https://img.shields.io/github/workflow/status/mattpolito/slugworth/CI)](https://github.com/mattpolito/slugworth/actions?query=workflow%3ACI)
6
5
 
7
6
  Simple slug functionality for your ActiveRecord objects
8
7
 
@@ -32,7 +31,7 @@ install it yourself with
32
31
 
33
32
  Getting started is easy! Just ensure that your model has a database column of type `String` called `slug`
34
33
 
35
- To use just add two declarations to your module and away you go!
34
+ To use, just add two declarations to your `ActiveRecord` class and away you go!
36
35
 
37
36
  ```ruby
38
37
  class User < ActiveRecord::Base
@@ -41,11 +40,75 @@ class User < ActiveRecord::Base
41
40
  end
42
41
  ```
43
42
 
43
+ After you `include` the `Slugworth` module, all you need to do is declare what method will be used to create the slug. The method passed to `slugged_with` will then be parameterized.
44
+
44
45
  This provides most of the default slug functionality you would need.
45
46
 
46
- * A finder `.find_by_slug` is provided. This will, of course, do what you expect and find a single record by the slug attribute provided. However, it will throw an `ActiveRecord::RecordNotFound` exception... if not found.
47
- * `#to_param` has been defined as a paramaterized version of the attribute declared to `slugged_with`.
48
- * Validations stating that slug is present and unique in the database.
47
+ * Finders `.find_by_slug` & `.find_by_slug!` are provided. This will, of course, do what you expect and find a single record by the slug attribute provided.
48
+ * `#to_param` has been defined as a parameterized version of the attribute declared to `slugged_with`.
49
+ * Validations stating that `slug` is present and unique in the database.
50
+
51
+ ### Scoping uniqueness
52
+
53
+ By default the slug is unique to the entire table, but you can specify the scope of the uniqueness as the following:
54
+
55
+ ```ruby
56
+ class Product < ActiveRecord::Base
57
+ include Slugworth
58
+ belongs_to :user
59
+ slugged_with :name, scope: :user_id
60
+ end
61
+ ```
62
+
63
+ ### Updating slugs
64
+
65
+ Sometimes you want to update the slug if the attribute is changed.
66
+
67
+ ```ruby
68
+ class User < ActiveRecord::Base
69
+ include Slugworth
70
+ slugged_with :name, updatable: true
71
+ end
72
+
73
+ user = User.create(name: 'Jack')
74
+ => User(id: 1, name: 'Jack', slug: 'jack')
75
+
76
+ user.update_attribute(:name, 'John')
77
+ => User(id: 1, name: 'John', slug: 'john')
78
+ ```
79
+
80
+ ### Incremental slugs
81
+
82
+ If another record already exists with the same slug it will generate an uniqueness validation error, but if incremental slugs is enabled, then it will append an incremented number to the slug:
83
+
84
+ ```ruby
85
+ class User < ActiveRecord::Base
86
+ include Slugworth
87
+ slugged_with :name, incremental: true
88
+ end
89
+
90
+ User.create(name: 'Jack')
91
+ => User(id: 1, name: 'Jack', slug: 'jack')
92
+
93
+ User.create(name: 'Jack')
94
+ => User(id: 2, name: 'Jack', slug: 'jack-1')
95
+ ```
96
+
97
+ ## Test Helper
98
+
99
+ To aid in testing your models that implement the Slugworth functionality, I've added a shared example group that can be added to your test suite. Add this to your `spec_helper.rb`
100
+
101
+ ```ruby
102
+ include 'slugworth_shared_examples'
103
+ ```
104
+
105
+ And then in your specs just add:
106
+
107
+ ```ruby
108
+ it_behaves_like :has_slug_functionality
109
+ ```
110
+
111
+ This will add the same specs to your model that get run on Slugworth itself!
49
112
 
50
113
  ## Contributing
51
114
 
@@ -54,3 +117,16 @@ This provides most of the default slug functionality you would need.
54
117
  3. Commit your changes (`git commit -am 'Add some feature'`)
55
118
  4. Push to the branch (`git push origin my-new-feature`)
56
119
  5. Create new Pull Request
120
+
121
+ ## Thanks
122
+
123
+ * [Rye Mason][] for the fantastic heading image.
124
+
125
+ [Rye Mason]: https://github.com/ryenotbread
126
+
127
+ ## About
128
+
129
+ [![Hashrocket logo](https://hashrocket.com/hashrocket_logo.svg)](https://hashrocket.com)
130
+
131
+ Slugworth is supported by the team at [Hashrocket, a
132
+ multidisciplinary design and development consultancy](https://hashrocket.com). If you'd like to [work with us](https://hashrocket.com/contact-us/hire-us) or [join our team](https://hashrocket.com/contact-us/jobs), don't hesitate to get in touch.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rails", "5.2.4.4"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rails", "6.0.3.4"
@@ -4,29 +4,74 @@ module Slugworth
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- cattr_accessor :slug_attribute
8
- before_validation(:add_slug)
9
- validates_uniqueness_of :slug
7
+ cattr_accessor :slug_attribute, :slug_scope, :slug_incremental, :slug_updatable
8
+ before_validation(:add_slug, if: :slug_attribute_value)
10
9
  end
11
10
 
12
11
  module ClassMethods
13
- def slugged_with(slug_attribute)
12
+ def slugged_with(slug_attribute, opts = {})
14
13
  self.slug_attribute = slug_attribute
14
+ self.slug_scope = opts.delete(:scope)
15
+ self.slug_incremental = opts.delete(:incremental)
16
+ self.slug_updatable = opts.delete(:updatable)
17
+ validates_uniqueness_of :slug, scope: slug_scope
15
18
  end
16
19
 
17
- def find_by_slug(slug)
20
+ def find_by_slug!(slug)
18
21
  find_by!(slug: slug)
19
22
  end
23
+
24
+ def find_by_slug(slug)
25
+ find_by(slug: slug)
26
+ end
20
27
  end
21
28
 
22
- def to_param; slug; end
29
+ def to_param
30
+ slug
31
+ end
23
32
 
24
33
  private
34
+
25
35
  def add_slug
26
- self.slug = processed_slug unless slug.present?
36
+ self.slug = processed_slug if generate_slug?
37
+ end
38
+
39
+ def generate_slug?
40
+ !slug.present? || slug_updatable && changes[slug_attribute].present?
41
+ end
42
+
43
+ def slug_attribute_value
44
+ public_send(slug_attribute)
27
45
  end
28
46
 
29
47
  def processed_slug
30
- send(slug_attribute).parameterize
48
+ slug_incremental ? process_incremental_slug : parameterized_slug
49
+ end
50
+
51
+ def parameterized_slug
52
+ slug_attribute_value.parameterize
53
+ end
54
+
55
+ def process_incremental_slug
56
+ slugs = matching_slugs
57
+ if slugs.include?(parameterized_slug)
58
+ (1..slugs.size).each do |i|
59
+ incremented_slug = "#{parameterized_slug}-#{i}"
60
+ return incremented_slug unless slugs.include?(incremented_slug)
61
+ end
62
+ else
63
+ parameterized_slug
64
+ end
65
+ end
66
+
67
+ def matching_slugs
68
+ table = self.class.arel_table
69
+ primary_key = self.class.primary_key
70
+ query = table[:slug].matches("#{parameterized_slug}%")
71
+ query = query.and(table[primary_key].not_eq(read_attribute(primary_key))) unless new_record?
72
+ Array.wrap(slug_scope).each do |scope|
73
+ query = query.and(table[scope].eq(read_attribute(scope)))
74
+ end
75
+ self.class.where(query).pluck(:slug)
31
76
  end
32
77
  end
@@ -1,3 +1,3 @@
1
1
  module Slugworth
2
- VERSION = "1.0.1"
2
+ VERSION = "1.2.2".freeze
3
3
  end
@@ -1,57 +1,199 @@
1
1
  shared_examples_for :has_slug_functionality do
2
2
  describe "#slug" do
3
3
  context "when no slug is set" do
4
- specify 'slug is generated' do
5
- obj = described_class.new(described_class.slug_attribute => 'Generated slug')
4
+ specify "slug is generated with slug attribute" do
5
+ obj = described_class.new(described_class.slug_attribute => "Generated slug")
6
6
  obj.valid?
7
- expect(obj.slug).to eq('generated-slug')
7
+ expect(obj.slug).to eq("generated-slug")
8
+ end
9
+
10
+ specify "slug is not generated with no slug attribute" do
11
+ obj = described_class.new
12
+ obj.valid?
13
+ expect(obj.slug).to be_nil
8
14
  end
9
15
  end
10
16
 
11
17
  context "when the slug is set" do
12
- specify 'slug is set to passed value' do
13
- obj = described_class.new(slug: 'passed-slug')
18
+ specify "slug is set to passed value" do
19
+ obj = described_class.new(slug: "passed-slug")
14
20
  obj.valid?
15
- expect(obj.slug).to eq('passed-slug')
21
+ expect(obj.slug).to eq("passed-slug")
16
22
  end
17
23
  end
18
24
 
19
25
  context "when slug is already taken" do
20
26
  before do
21
- existing = described_class.new(slug: 'taken-slug')
27
+ existing = described_class.new(slug: "taken-slug")
22
28
  existing.save(validate: false)
23
29
  end
24
30
 
25
31
  specify "object is not valid" do
26
- obj = described_class.new(slug: 'taken-slug')
32
+ obj = described_class.new(slug: "taken-slug")
27
33
  obj.valid?
28
34
  expect(obj.errors[:slug]).to_not be_empty
29
35
  end
30
36
  end
31
37
  end
32
38
 
33
- describe '#to_param' do
34
- specify 'parameter uses slug' do
35
- obj = described_class.new(slug: 'passed-slug')
36
- expect(obj.to_param).to eq('passed-slug')
39
+ describe "#to_param" do
40
+ specify "parameter uses slug" do
41
+ obj = described_class.new(slug: "passed-slug")
42
+ expect(obj.to_param).to eq("passed-slug")
37
43
  end
38
44
  end
39
45
 
40
46
  describe ".find_by_slug" do
41
- context 'when record is available to be found' do
47
+ context "when record is available to be found" do
42
48
  before do
43
- described_class.create(slug: 'named-slug')
49
+ record = described_class.new(slug: "named-slug")
50
+ record.save(validate: false)
44
51
  end
45
52
 
46
- specify 'record is returned' do
47
- record = described_class.find_by_slug('named-slug')
53
+ specify "record is returned" do
54
+ record = described_class.find_by_slug("named-slug")
48
55
  expect(record).to be_present
49
56
  end
50
57
  end
51
58
 
52
- context 'when record is not found' do
53
- specify 'error is returned' do
54
- expect { described_class.find_by_slug('named-slug') }.to raise_error(ActiveRecord::RecordNotFound)
59
+ context "when record is not found" do
60
+ specify "nil is returned" do
61
+ expect(described_class.find_by_slug("named-slug")).to eq(nil)
62
+ end
63
+
64
+ specify "error is raised" do
65
+ expect { described_class.find_by_slug!("named-slug") }.to raise_error(ActiveRecord::RecordNotFound)
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ shared_examples_for :has_updatable_slug_functionality do
72
+ describe "#slug :updatable" do
73
+ let!(:existing) { described_class.create(described_class.slug_attribute => "Name") }
74
+ context "when attribute is changed" do
75
+ specify "updates the slug" do
76
+ existing[described_class.slug_attribute] = "New Name"
77
+ expect(existing).to be_valid
78
+ expect(existing.slug).to eq("new-name")
79
+ end
80
+ end
81
+ context "when attribute is not changed" do
82
+ specify "does not update the slug" do
83
+ expect(existing).to be_valid
84
+ expect(existing.slug).to eq("name")
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ shared_examples_for :has_incremental_slug_functionality do
91
+ describe "#slug :incremental" do
92
+ context "when slug is already taken" do
93
+ before do
94
+ existing = described_class.new(slug: "taken-slug")
95
+ existing.save(validate: false)
96
+ end
97
+
98
+ specify "increments the slug" do
99
+ obj = described_class.new(described_class.slug_attribute => "Taken Slug")
100
+ expect(obj).to be_valid
101
+ expect(obj.slug).to eq("taken-slug-1")
102
+ end
103
+ end
104
+ context "when incremented slug is already taken" do
105
+ before do
106
+ existing = described_class.new(slug: "taken-slug")
107
+ existing.save(validate: false)
108
+ existing = described_class.new(slug: "taken-slug-1")
109
+ existing.save(validate: false)
110
+ end
111
+
112
+ specify "increments the slug" do
113
+ obj = described_class.new(described_class.slug_attribute => "Taken Slug")
114
+ expect(obj).to be_valid
115
+ expect(obj.slug).to eq("taken-slug-2")
116
+ end
117
+ end
118
+ context "when existing slug is reset" do
119
+ let!(:existing) { described_class.create(described_class.slug_attribute => "New Name") }
120
+
121
+ specify "does not increment the slug" do
122
+ existing.slug = nil
123
+ expect(existing).to be_valid
124
+ expect(existing.slug).to eq("new-name")
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ shared_examples_for :has_scoped_slug_functionality do
131
+ describe "#slug :scope" do
132
+ context "when slug is already taken on same scope" do
133
+ before do
134
+ existing = described_class.new(:slug => "taken-slug", described_class.slug_scope => 1)
135
+ existing.save(validate: false)
136
+ end
137
+
138
+ specify "object is not valid" do
139
+ obj = described_class.new(:slug => "taken-slug", described_class.slug_scope => 1)
140
+ expect(obj).to_not be_valid
141
+ expect(obj.errors[:slug]).to_not be_empty
142
+ end
143
+ end
144
+
145
+ context "when slug is already taken on another scope" do
146
+ before do
147
+ existing = described_class.new(:slug => "taken-slug", described_class.slug_scope => 1)
148
+ existing.save(validate: false)
149
+ end
150
+
151
+ specify "object is valid" do
152
+ obj = described_class.new(:slug => "taken-slug", described_class.slug_scope => 2)
153
+ expect(obj).to be_valid
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+ shared_examples_for :has_incremental_scoped_slug_functionality do
160
+ describe "#slug :incremental" do
161
+ context "when slug is already taken" do
162
+ before do
163
+ existing = described_class.new(:slug => "taken-slug", described_class.slug_scope => 1)
164
+ existing.save(validate: false)
165
+ end
166
+
167
+ specify "increments the slug" do
168
+ obj = described_class.new(described_class.slug_attribute => "Taken Slug", described_class.slug_scope => 1)
169
+ expect(obj).to be_valid
170
+ expect(obj.slug).to eq("taken-slug-1")
171
+ end
172
+ end
173
+ context "when incremented slug is already taken" do
174
+ before do
175
+ existing = described_class.new(:slug => "taken-slug", described_class.slug_scope => 1)
176
+ existing.save(validate: false)
177
+ existing = described_class.new(:slug => "taken-slug-1", described_class.slug_scope => 1)
178
+ existing.save(validate: false)
179
+ end
180
+
181
+ specify "increments the slug" do
182
+ obj = described_class.new(described_class.slug_attribute => "Taken Slug", described_class.slug_scope => 1)
183
+ expect(obj).to be_valid
184
+ expect(obj.slug).to eq("taken-slug-2")
185
+ end
186
+ end
187
+ context "when slug is already taken in another scope" do
188
+ before do
189
+ existing = described_class.new(:slug => "taken-slug", described_class.slug_scope => 1)
190
+ existing.save(validate: false)
191
+ end
192
+
193
+ specify "does not increment the slug" do
194
+ obj = described_class.new(described_class.slug_attribute => "Taken Slug", described_class.slug_scope => 2)
195
+ expect(obj).to be_valid
196
+ expect(obj.slug).to eq("taken-slug")
55
197
  end
56
198
  end
57
199
  end
@@ -1,28 +1,30 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'slugworth/version'
3
+ require "slugworth/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "slugworth"
8
- spec.version = Slugworth::VERSION
9
- spec.authors = ["Matt Polito"]
10
- spec.email = ["matt.polito@gmail.com"]
11
- spec.description = %q{Easy slug functionality}
12
- spec.summary = %q{Easy slug functionality}
13
- spec.homepage = "https://github.com/mattpolito/slugworth"
14
- spec.license = "MIT"
6
+ spec.name = "slugworth"
7
+ spec.version = Slugworth::VERSION
8
+ spec.authors = ["Matt Polito"]
9
+ spec.email = ["matt.polito@gmail.com"]
10
+ spec.description = "Easy slug functionality"
11
+ spec.summary = "Easy slug functionality"
12
+ spec.homepage = "https://github.com/mattpolito/slugworth"
13
+ spec.license = "MIT"
15
14
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|.github)/}) }
17
+ end
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.required_ruby_version = ">= 2.6"
22
+
22
23
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", "~> 2.13"
24
- spec.add_development_dependency 'activerecord', '~> 4.0.0'
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "activerecord", ">= 4.0"
25
26
  spec.add_development_dependency "pry"
26
- spec.add_development_dependency "database_cleaner"
27
+ spec.add_development_dependency "database_cleaner", "~> 1.0"
27
28
  spec.add_development_dependency "sqlite3"
29
+ spec.add_development_dependency "standard"
28
30
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugworth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Polito
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-01 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - '>='
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
19
  version: '0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - '>='
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ~>
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '2.13'
33
+ version: '3.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ~>
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '2.13'
40
+ version: '3.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: activerecord
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ~>
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: 4.0.0
47
+ version: '4.0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ~>
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: 4.0.0
54
+ version: '4.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pry
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '>='
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
61
  version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - '>='
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: database_cleaner
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - '>='
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: sqlite3
98
+ name: standard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Easy slug functionality
@@ -115,44 +115,39 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .gitignore
119
- - .ruby-gemset
120
- - .ruby-version
121
- - CHANGELOG
118
+ - ".gitignore"
119
+ - CHANGELOG.md
122
120
  - Gemfile
123
121
  - LICENSE.txt
124
122
  - README.md
125
123
  - Rakefile
124
+ - gemfiles/Gemfile.rails-5.2.4.4
125
+ - gemfiles/Gemfile.rails-6.0.3.4
126
126
  - lib/slugworth.rb
127
127
  - lib/slugworth/version.rb
128
128
  - lib/slugworth_shared_examples.rb
129
129
  - slugworth.gemspec
130
- - spec/sluggle_spec.rb
131
- - spec/spec_helper.rb
132
130
  homepage: https://github.com/mattpolito/slugworth
133
131
  licenses:
134
132
  - MIT
135
133
  metadata: {}
136
- post_install_message:
134
+ post_install_message:
137
135
  rdoc_options: []
138
136
  require_paths:
139
137
  - lib
140
138
  required_ruby_version: !ruby/object:Gem::Requirement
141
139
  requirements:
142
- - - '>='
140
+ - - ">="
143
141
  - !ruby/object:Gem::Version
144
- version: '0'
142
+ version: '2.6'
145
143
  required_rubygems_version: !ruby/object:Gem::Requirement
146
144
  requirements:
147
- - - '>='
145
+ - - ">="
148
146
  - !ruby/object:Gem::Version
149
147
  version: '0'
150
148
  requirements: []
151
- rubyforge_project:
152
- rubygems_version: 2.0.3
153
- signing_key:
149
+ rubygems_version: 3.2.3
150
+ signing_key:
154
151
  specification_version: 4
155
152
  summary: Easy slug functionality
156
- test_files:
157
- - spec/sluggle_spec.rb
158
- - spec/spec_helper.rb
153
+ test_files: []
@@ -1 +0,0 @@
1
- slugworth
@@ -1 +0,0 @@
1
- 2.0.0
data/CHANGELOG DELETED
@@ -1,9 +0,0 @@
1
- # Changelog
2
-
3
- ## 1.0.1
4
-
5
- - [Bug fix] Shared example had `User` class hard coded
6
-
7
- ## 1.0.0
8
-
9
- - Initial functionality
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- require 'slugworth_shared_examples'
3
- require 'slugworth'
4
-
5
- ActiveRecord::Base.connection.execute(
6
- %{CREATE TABLE users (id INTEGER PRIMARY KEY, name STRING, slug STRING);}
7
- )
8
-
9
- class User < ActiveRecord::Base
10
- include Slugworth
11
- slugged_with :name
12
- end
13
-
14
- describe User do
15
- it_behaves_like :has_slug_functionality
16
- end
@@ -1,26 +0,0 @@
1
- require 'rspec'
2
- require 'database_cleaner'
3
-
4
- require 'active_support/concern'
5
- require 'active_record'
6
-
7
- ActiveRecord::Base.establish_connection(
8
- adapter: 'sqlite3', database: ':memory:'
9
- )
10
-
11
- RSpec.configure do |config|
12
- config.order = "random"
13
-
14
- config.before(:suite) do
15
- DatabaseCleaner.clean_with(:truncation)
16
- end
17
-
18
- config.before(:each) do
19
- DatabaseCleaner.strategy = :transaction
20
- DatabaseCleaner.start
21
- end
22
-
23
- config.after(:each) do
24
- DatabaseCleaner.clean
25
- end
26
- end