much-slug 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: d01ea124052633b468872a2c8ab13273d39999bd8fa4a068fbb009c777b41451
4
- data.tar.gz: c1f745df34088bfb001719692c5033deaef9346c857046e9f756da65859c7d23
3
+ metadata.gz: dbe42cdcdaafd6505b00426cd011ac984a56939d6654cafed64f54df72a46615
4
+ data.tar.gz: 6bf1b4aae86da836b8a637e32da79e1b53fe8de30710cd6dc5a9af8b9d7f2388
5
5
  SHA512:
6
- metadata.gz: 95199593bb0065a2d17f926a910cd3175657522f07f07aac8b776c69289693cb4568d3f619f46aa96493763efa1d50250dd9260de0d2f886aaafb780704df984
7
- data.tar.gz: d6cdb5f3e2b35665f59b8daf266cd560e3eded1dc30584519b45b2d2769f7db6f38e7d6a31a96d4b58f1792bc3481ce7471c4e687055138297e9d7f730c43164
6
+ metadata.gz: 2ba93e73c2437bddf33b920bfaeedcd27e96db540201364e252418a7e7e279788b61b3f849240e55864797c953f132094b89cf0eff8cfc8ec713d36e7e3f9506
7
+ data.tar.gz: cf311ed407e9517c282363082b29a28ad828f180ede3e27c898219777bd2d4a3092e8aefa0c55205d805f6a842324796c1ed1caa92d503a9b78bde05a4de4655
@@ -9,6 +9,13 @@ module MuchSlug::ActiveRecord
9
9
  include MuchMixin
10
10
 
11
11
  mixin_class_methods do
12
+ def inherited(child_class)
13
+ super
14
+ child_class.much_slug_has_slug_registry.copy_from(
15
+ much_slug_has_slug_registry,
16
+ )
17
+ end
18
+
12
19
  def much_slug_has_slug_registry
13
20
  @much_slug_has_slug_registry ||= MuchSlug::HasSlugRegistry.new
14
21
  end
@@ -35,6 +35,12 @@ class MuchSlug::HasSlugRegistry < ::Hash
35
35
  attribute
36
36
  end
37
37
 
38
+ def copy_from(has_slug_registry)
39
+ has_slug_registry.each do |attribute, entry|
40
+ self[attribute] = entry.dup
41
+ end
42
+ end
43
+
38
44
  Entry =
39
45
  Struct.new(
40
46
  :source_proc,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuchSlug
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/much-slug.gemspec CHANGED
@@ -15,7 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.homepage = "https://github.com/redding/much-slug"
16
16
  gem.license = "MIT"
17
17
 
18
- gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
19
+
19
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
22
  gem.require_paths = ["lib"]
@@ -144,6 +144,26 @@ module MuchSlug::ActiveRecord
144
144
  end
145
145
  end
146
146
 
147
+ class ReceiverInheritedTests < ReceiverTests
148
+ desc "is inherited from"
149
+
150
+ setup do
151
+ subject.has_slug(source: :name)
152
+
153
+ Assert.stub_tap(MuchSlug::HasSlugRegistry, :new) do |has_slug_registry|
154
+ Assert.stub_on_call(has_slug_registry, :copy_from) do |call|
155
+ @has_slug_registry_copy_from_call = call
156
+ end
157
+ end
158
+ end
159
+
160
+ should "copy its MuchSlug::HasSlugRegistry to the child class" do
161
+ Class.new(receiver_class)
162
+ assert_that(@has_slug_registry_copy_from_call.args)
163
+ .equals([subject.much_slug_has_slug_registry])
164
+ end
165
+ end
166
+
147
167
  class ReceiverInitTests < ReceiverTests
148
168
  desc "when init"
149
169
  subject{ receiver }
@@ -25,7 +25,7 @@ class MuchSlug::HasSlugRegistry
25
25
  let(:separator){ "|" }
26
26
  let(:allow_underscores){ Factory.boolean }
27
27
 
28
- should have_imeths :register
28
+ should have_imeths :register, :copy_from
29
29
 
30
30
  should "default empty entries for unregisterd attributes" do
31
31
  assert_that(subject[Factory.string]).is_an_instance_of(unit_class::Entry)
@@ -74,6 +74,45 @@ class MuchSlug::HasSlugRegistry
74
74
  end
75
75
  end
76
76
 
77
+ class CopyFromTests < InitTests
78
+ desc "#copy_from"
79
+
80
+ setup do
81
+ parent_has_slug_registry.register(
82
+ attribute: attribute,
83
+ source: source,
84
+ preprocessor: nil,
85
+ separator: nil,
86
+ allow_underscores: nil,
87
+ )
88
+ parent_has_slug_registry.register(
89
+ attribute: other_attribute,
90
+ source: other_source,
91
+ preprocessor: nil,
92
+ separator: nil,
93
+ allow_underscores: nil,
94
+ )
95
+ end
96
+
97
+ let(:other_attribute){ Factory.symbol }
98
+ let(:other_source){ :to_s }
99
+
100
+ let(:parent_has_slug_registry){ unit_class.new }
101
+
102
+ should "copy entries from the passed MuchSlug::HasSlugRegistry" do
103
+ subject.copy_from(parent_has_slug_registry)
104
+
105
+ assert_that(subject[attribute])
106
+ .equals(parent_has_slug_registry[attribute])
107
+ assert_that(subject[attribute])
108
+ .is_not(parent_has_slug_registry[attribute])
109
+ assert_that(subject[other_attribute])
110
+ .equals(parent_has_slug_registry[other_attribute])
111
+ assert_that(subject[other_attribute])
112
+ .is_not(parent_has_slug_registry[other_attribute])
113
+ end
114
+ end
115
+
77
116
  class EntryUnitTests < UnitTests
78
117
  desc "Entry"
79
118
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: much-slug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-10 00:00:00.000000000 Z
12
+ date: 2021-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ardb
@@ -75,11 +75,6 @@ executables: []
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - ".gitignore"
79
- - ".l.yml"
80
- - ".rubocop.yml"
81
- - ".ruby-version"
82
- - ".t.yml"
83
78
  - Gemfile
84
79
  - LICENSE
85
80
  - README.md
data/.gitignore DELETED
@@ -1,19 +0,0 @@
1
- *.gem
2
- *.log
3
- *.rbc
4
- .rbx/
5
- .bundle
6
- .config
7
- .yardoc
8
- Gemfile.lock
9
- InstalledFiles
10
- _yardoc
11
- coverage
12
- doc/
13
- lib/bundler/man
14
- pkg
15
- rdoc
16
- spec/reports
17
- test/tmp
18
- test/version_tmp
19
- tmp
data/.l.yml DELETED
@@ -1,8 +0,0 @@
1
- # https://github.com/redding/l.rb
2
-
3
- linters:
4
- - name: "Rubocop"
5
- cmd: "bundle exec rubocop"
6
- extensions:
7
- - ".rb"
8
- cli_abbrev: "u"
data/.rubocop.yml DELETED
@@ -1,3 +0,0 @@
1
- inherit_gem:
2
- much-style-guide:
3
- - "lib/much-style-guide/rubocop.yml"
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.5.8
data/.t.yml DELETED
@@ -1,4 +0,0 @@
1
- - default_cmd: "bundle exec assert"
2
- test_dir: "test"
3
- test_file_suffixes:
4
- - "_tests.rb"