nameq 0.0.1 → 0.0.3
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 +5 -5
- data/.github/workflows/gem-push.yml +31 -0
- data/.github/workflows/ruby.yml +6 -4
- data/.travis.yml +2 -1
- data/Gemfile +2 -1
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/lib/nameq.rb +1 -1
- data/lib/nameq/directory.rb +2 -1
- data/lib/nameq/support/filename_entry.rb +2 -1
- data/lib/nameq/support/list.rb +1 -0
- data/lib/nameq/support/pool.rb +2 -1
- data/lib/nameq/support/string_entry.rb +1 -0
- data/lib/nameq/support/suffix.rb +6 -5
- data/lib/nameq/text_pool.rb +1 -0
- data/lib/nameq/version.rb +2 -1
- data/nameq.gemspec +15 -14
- data/spec/directory_spec.rb +14 -14
- data/spec/spec_helper.rb +1 -1
- data/spec/support/filename_entry_spec.rb +10 -10
- data/spec/support/list_spec.rb +26 -26
- data/spec/support/pool_spec.rb +13 -13
- data/spec/support/string_entry_spec.rb +5 -5
- data/spec/support/suffix_spec.rb +17 -17
- data/spec/text_pool_spec.rb +9 -9
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33d2494ae24fd2306fd2b38d256d6a84e676c9a93101d7f31ec43f8c739737cb
|
4
|
+
data.tar.gz: dbbef6e57237f2a8bf7ff08c8829f8b774334694985158ea802e8813b096c285
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfbc3bf458ae77a6aa9f3ef005f44c18139994a5608b0d24dc7a21160539e3da005ba3fbff3d920901d3262930296571f98a18b943af8a97596dcf1c64fa15d
|
7
|
+
data.tar.gz: 40eaad3397af6d361c55139c0824061475f999e462a82d18ae198de9f70422b751e0f09704bcee8e0079e8137f4ff7291b51f3f5cac9b584f8bcaea18021e852
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
packages: write
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby 2.6
|
18
|
+
uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.6.x
|
21
|
+
|
22
|
+
- name: Publish to RubyGems
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build *.gemspec
|
29
|
+
gem push *.gem
|
30
|
+
env:
|
31
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.github/workflows/ruby.yml
CHANGED
@@ -17,6 +17,9 @@ jobs:
|
|
17
17
|
test:
|
18
18
|
|
19
19
|
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
20
23
|
|
21
24
|
steps:
|
22
25
|
- uses: actions/checkout@v2
|
@@ -24,10 +27,9 @@ jobs:
|
|
24
27
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
28
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
29
|
# uses: ruby/setup-ruby@v1
|
27
|
-
uses: ruby/setup-ruby@
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
28
31
|
with:
|
29
|
-
ruby-version:
|
30
|
-
|
31
|
-
run: bundle install
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
32
34
|
- name: Run tests
|
33
35
|
run: bundle exec rspec
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# NameQ
|
1
|
+
# NameQ  [](https://badge.fury.io/rb/nameq)
|
2
2
|
|
3
3
|
For when you need to name things, but not worry about whether or not those names are already taken.
|
4
4
|
|
data/Rakefile
CHANGED
data/lib/nameq.rb
CHANGED
data/lib/nameq/directory.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module NameQ
|
3
4
|
class Directory < Support::Pool
|
4
5
|
# Set up a new directory-based pool.
|
@@ -7,7 +8,7 @@ module NameQ
|
|
7
8
|
# @return [Directory]
|
8
9
|
def initialize(name, case_sensitive: true)
|
9
10
|
list = Support::List.new(case_sensitive: case_sensitive) do
|
10
|
-
Dir[File.join(name,
|
11
|
+
Dir[File.join(name, "*")].map { |f| File.basename(f) }
|
11
12
|
end
|
12
13
|
super list
|
13
14
|
end
|
data/lib/nameq/support/list.rb
CHANGED
data/lib/nameq/support/pool.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module NameQ
|
3
4
|
module Support
|
4
5
|
class Pool
|
@@ -33,7 +34,7 @@ module NameQ
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def suffixes
|
36
|
-
(1
|
37
|
+
(1..Float::INFINITY).lazy.map { |i| Suffix.new(i) }
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
data/lib/nameq/support/suffix.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module NameQ
|
3
4
|
module Support
|
4
5
|
class Suffix
|
5
|
-
TOKEN =
|
6
|
+
TOKEN = "%{index}"
|
6
7
|
attr_reader :index
|
7
8
|
|
8
9
|
def initialize(index, template: nil)
|
@@ -11,7 +12,7 @@ module NameQ
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def strip(text)
|
14
|
-
text.sub(regex,
|
15
|
+
text.sub(regex, "")
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_s
|
@@ -22,9 +23,9 @@ module NameQ
|
|
22
23
|
|
23
24
|
def regex
|
24
25
|
@_regex ||= begin
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
first, last = @template.split(TOKEN)
|
27
|
+
Regexp.new(Regexp.quote(first) + "[0-9]+" + Regexp.quote(last) + "$")
|
28
|
+
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
data/lib/nameq/text_pool.rb
CHANGED
data/lib/nameq/version.rb
CHANGED
data/nameq.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path(
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "nameq/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
8
|
+
spec.name = "nameq"
|
9
|
+
spec.version = NameQ::VERSION
|
10
|
+
spec.authors = ["Kevin McDonald"]
|
11
|
+
spec.email = ["kevinstuffandthings@gmail.com"]
|
12
|
+
spec.summary = "Create unique names via numeric suffixes"
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = "https://github.com/kevinstuffandthings/nameq"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
spec.executables
|
19
|
-
spec.test_files
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler"
|
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "rack-test"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "standard"
|
28
29
|
spec.add_development_dependency "yard"
|
29
30
|
end
|
data/spec/directory_spec.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
module NameQ
|
2
2
|
describe Directory do
|
3
|
-
let(:path) {
|
3
|
+
let(:path) { "/path/to/somewhere" }
|
4
4
|
let(:subject) { described_class.new(path) }
|
5
5
|
|
6
|
-
it
|
6
|
+
it "is a kind of pool" do
|
7
7
|
expect(subject).to be_a NameQ::Support::Pool
|
8
8
|
end
|
9
9
|
|
10
|
-
context
|
11
|
-
context
|
10
|
+
context "internals" do
|
11
|
+
context "underlying list" do
|
12
12
|
let(:list) { instance_double(NameQ::Support::List) }
|
13
|
-
let(:result) { subject.instance_variable_get(
|
13
|
+
let(:result) { subject.instance_variable_get("@list") }
|
14
14
|
|
15
|
-
it
|
15
|
+
it "builds the right kind of list by default" do
|
16
16
|
expect(NameQ::Support::List).to receive(:new).with(case_sensitive: true).and_return list
|
17
17
|
expect(result).to eq list
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
20
|
+
context "case-insensitive" do
|
21
21
|
let(:subject) { described_class.new(path, case_sensitive: false) }
|
22
22
|
|
23
|
-
it
|
23
|
+
it "builds the right kind of list by default" do
|
24
24
|
expect(NameQ::Support::List).to receive(:new).with(case_sensitive: false).and_return list
|
25
25
|
expect(result).to eq list
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context
|
30
|
-
let(:path) { File.expand_path(
|
29
|
+
context "refresh" do
|
30
|
+
let(:path) { File.expand_path(".") }
|
31
31
|
let(:items) { result.send(:all) }
|
32
32
|
|
33
|
-
it
|
34
|
-
expect(items).to include(
|
33
|
+
it "has a block that does the right stuff" do
|
34
|
+
expect(items).to include("nameq.gemspec", "Gemfile", "Rakefile")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it
|
39
|
+
describe "#entry_factory" do
|
40
|
+
it "has a special filename entry factory" do
|
41
41
|
expect(subject.send(:entry_factory)).to eq NameQ::Support::FilenameEntry
|
42
42
|
end
|
43
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
module NameQ
|
2
2
|
module Support
|
3
3
|
describe FilenameEntry do
|
4
|
-
let(:text) {
|
4
|
+
let(:text) { "Some Filename" }
|
5
5
|
let(:subject) { described_class.new(text) }
|
6
6
|
|
7
|
-
describe
|
8
|
-
let(:suffix) { instance_double(NameQ::Support::Suffix, to_s:
|
7
|
+
describe "#resolve" do
|
8
|
+
let(:suffix) { instance_double(NameQ::Support::Suffix, to_s: "-yup") }
|
9
9
|
let(:stripped_text) { "#{text} stripped" }
|
10
10
|
before(:each) { allow(suffix).to receive(:strip).with(text).and_return stripped_text }
|
11
11
|
|
12
|
-
context
|
13
|
-
it
|
12
|
+
context "without extension" do
|
13
|
+
it "resolves itself without a suffix" do
|
14
14
|
expect(subject.resolve).to eq text
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it "resolves itself with a suffix" do
|
18
18
|
expect(subject.resolve(suffix)).to eq "#{stripped_text}#{suffix}"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
context
|
23
|
-
let(:extension) {
|
22
|
+
context "with extension" do
|
23
|
+
let(:extension) { ".meh" }
|
24
24
|
let(:subject) { described_class.new("#{text}#{extension}") }
|
25
25
|
|
26
|
-
it
|
26
|
+
it "resolves itself without a suffix" do
|
27
27
|
expect(subject.resolve).to eq "#{text}#{extension}"
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it "resolves itself with a suffix" do
|
31
31
|
expect(subject.resolve(suffix)).to eq "#{stripped_text}#{suffix}#{extension}"
|
32
32
|
end
|
33
33
|
end
|
data/spec/support/list_spec.rb
CHANGED
@@ -4,71 +4,71 @@ module NameQ
|
|
4
4
|
let(:array) { %w[One Two Three] }
|
5
5
|
let(:subject) { described_class.new(array.clone) }
|
6
6
|
|
7
|
-
context
|
8
|
-
describe
|
7
|
+
context "internals" do
|
8
|
+
describe "#all" do
|
9
9
|
let(:refiller) { %w[Four Five] }
|
10
10
|
let(:all) { subject.send(:all) }
|
11
11
|
|
12
|
-
context
|
13
|
-
it
|
12
|
+
context "array only" do
|
13
|
+
it "knows all its stuff" do
|
14
14
|
expect(all).to match_array array
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
context
|
18
|
+
context "refiller only" do
|
19
19
|
let(:subject) { described_class.new { refiller } }
|
20
20
|
|
21
|
-
it
|
21
|
+
it "knows all its stuff" do
|
22
22
|
expect(all).to match_array refiller
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
context
|
26
|
+
context "all options" do
|
27
27
|
let(:subject) { described_class.new(array) { refiller } }
|
28
28
|
|
29
|
-
it
|
29
|
+
it "knows all its stuff" do
|
30
30
|
expect(all).to match_array(array + refiller)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
context
|
38
|
-
it
|
39
|
-
expect(subject.include?(
|
36
|
+
describe "#include?" do
|
37
|
+
context "default (case-sensitive)" do
|
38
|
+
it "can miss" do
|
39
|
+
expect(subject.include?("Eight")).to be false
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
expect(subject.include?(
|
42
|
+
it "can miss due to case" do
|
43
|
+
expect(subject.include?("two")).to be false
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
expect(subject.include?(
|
46
|
+
it "can match" do
|
47
|
+
expect(subject.include?("Two")).to be true
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
51
|
+
context "case-insensitive" do
|
52
52
|
let(:subject) { described_class.new(array, case_sensitive: false) }
|
53
53
|
|
54
|
-
it
|
55
|
-
expect(subject.include?(
|
54
|
+
it "can miss" do
|
55
|
+
expect(subject.include?("Eight")).to be false
|
56
56
|
end
|
57
57
|
|
58
|
-
it
|
59
|
-
expect(subject.include?(
|
58
|
+
it "can match outside case" do
|
59
|
+
expect(subject.include?("three")).to be true
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
expect(subject.include?(
|
62
|
+
it "can match" do
|
63
|
+
expect(subject.include?("Three")).to be true
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
describe
|
69
|
-
let(:value) {
|
68
|
+
describe "#add" do
|
69
|
+
let(:value) { "Eight" }
|
70
70
|
|
71
|
-
it
|
71
|
+
it "adds items when you ask it to" do
|
72
72
|
expect(subject.send(:all)).to match_array array
|
73
73
|
expect(subject.add(value)).to eq value
|
74
74
|
expect(subject.send(:all)).to match_array(array + [value])
|
data/spec/support/pool_spec.rb
CHANGED
@@ -4,17 +4,17 @@ module NameQ
|
|
4
4
|
let(:list) { instance_double(NameQ::Support::List) }
|
5
5
|
let(:subject) { described_class.new(list) }
|
6
6
|
|
7
|
-
context
|
8
|
-
describe
|
7
|
+
context "internals" do
|
8
|
+
describe "#suffixes" do
|
9
9
|
let(:suffixes) { subject.send(:suffixes) }
|
10
10
|
|
11
|
-
it
|
11
|
+
it "can get a suffix" do
|
12
12
|
result = suffixes.first
|
13
13
|
expect(result).to be_a NameQ::Support::Suffix
|
14
14
|
expect(result.index).to eq 1
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it "can get 10 suffixes and you have to just trust that it can get even more" do
|
18
18
|
count = 0
|
19
19
|
suffixes.each_with_index do |suffix, i|
|
20
20
|
expect(suffix).to be_a NameQ::Support::Suffix
|
@@ -25,13 +25,13 @@ module NameQ
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
28
|
+
describe "#entry_factory" do
|
29
|
+
it "has a default entry factory" do
|
30
30
|
expect(subject.send(:entry_factory)).to eq NameQ::Support::StringEntry
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
34
|
+
describe "#resolve" do
|
35
35
|
let(:resolution) { double }
|
36
36
|
let(:entry) { instance_double(NameQ::Support::StringEntry, resolve: resolution) }
|
37
37
|
let(:suffixes) { 3.times.map { |i| instance_double(NameQ::Support::Suffix, index: (i + 1) * 8) } }
|
@@ -41,32 +41,32 @@ module NameQ
|
|
41
41
|
allow(list).to receive(:include?).with(resolution).and_return false
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it "can hit on the first try" do
|
45
45
|
expect(subject.send(:resolve, entry)).to eq resolution
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it "can hit... eventually..." do
|
49
49
|
[0, 1].each { |i| allow(entry).to receive(:resolve).with(suffixes[i]).and_return double }
|
50
50
|
expect(subject.send(:resolve, entry)).to eq resolution
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe
|
55
|
+
describe "#take" do
|
56
56
|
let(:name) { double }
|
57
57
|
|
58
|
-
it
|
58
|
+
it "can take a name when available" do
|
59
59
|
allow(list).to receive(:include?).with(name).and_return false
|
60
60
|
expect(list).to receive(:add).with(name).and_return name
|
61
61
|
expect(subject.take(name)).to eq name
|
62
62
|
end
|
63
63
|
|
64
|
-
context
|
64
|
+
context "fallback" do
|
65
65
|
let(:entry) { double }
|
66
66
|
let(:resolved_name) { double }
|
67
67
|
before(:each) { allow(subject.send(:entry_factory)).to receive(:new).with(name).and_return entry }
|
68
68
|
|
69
|
-
it
|
69
|
+
it "can fall back a few when needed" do
|
70
70
|
allow(list).to receive(:include?).with(name).and_return true
|
71
71
|
expect(subject).to receive(:resolve).with(entry).and_return resolved_name
|
72
72
|
expect(list).to receive(:add).with(resolved_name)
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module NameQ
|
2
2
|
module Support
|
3
3
|
describe StringEntry do
|
4
|
-
let(:text) {
|
4
|
+
let(:text) { "This is something" }
|
5
5
|
let(:subject) { described_class.new(text) }
|
6
6
|
|
7
|
-
describe
|
8
|
-
let(:suffix) { instance_double(NameQ::Support::Suffix, to_s:
|
7
|
+
describe "#resolve" do
|
8
|
+
let(:suffix) { instance_double(NameQ::Support::Suffix, to_s: "!") }
|
9
9
|
let(:stripped_text) { "#{text} stripped" }
|
10
10
|
before(:each) { allow(suffix).to receive(:strip).with(text).and_return stripped_text }
|
11
11
|
|
12
|
-
it
|
12
|
+
it "resolves itself without a suffix" do
|
13
13
|
expect(subject.resolve).to eq text
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it "resolves itself with a suffix" do
|
17
17
|
expect(subject.resolve(suffix)).to eq "#{stripped_text}!"
|
18
18
|
end
|
19
19
|
end
|
data/spec/support/suffix_spec.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
1
|
module NameQ
|
2
2
|
module Support
|
3
3
|
describe Suffix do
|
4
|
-
let(:index) {
|
4
|
+
let(:index) { "88" }
|
5
5
|
let(:subject) { described_class.new(index) }
|
6
|
-
let(:custom_template) {
|
6
|
+
let(:custom_template) { "-[%{index}]-" }
|
7
7
|
|
8
|
-
describe
|
9
|
-
let(:text) {
|
8
|
+
describe "#strip" do
|
9
|
+
let(:text) { "How about this" }
|
10
10
|
|
11
|
-
it
|
11
|
+
it "can ignore templateless content" do
|
12
12
|
expect(subject.strip(text)).to eq text
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it "can strip the content of its template" do
|
16
16
|
expect(subject.strip("#{text} (7)")).to eq text
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it "is not tripped up by template-like content" do
|
20
20
|
expect(subject.strip("#{text} (7)!")).to eq "#{text} (7)!"
|
21
21
|
end
|
22
22
|
|
23
|
-
context
|
23
|
+
context "overridden template" do
|
24
24
|
let(:subject) { described_class.new(index, template: custom_template) }
|
25
25
|
|
26
|
-
it
|
26
|
+
it "can strip the content of its template" do
|
27
27
|
expect(subject.strip("#{text}-[7]-")).to eq text
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it "is not tripped up by template-like content" do
|
31
31
|
expect(subject.strip("#{text}-[7]-!")).to eq "#{text}-[7]-!"
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it "is not tripped up by default template-like content" do
|
35
35
|
expect(subject.strip("#{text} (7)")).to eq "#{text} (7)"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
41
|
-
it
|
42
|
-
expect(subject.to_s).to eq
|
40
|
+
describe "#to_s" do
|
41
|
+
it "works out fine with the default template" do
|
42
|
+
expect(subject.to_s).to eq " (88)"
|
43
43
|
end
|
44
44
|
|
45
|
-
context
|
45
|
+
context "overridden template" do
|
46
46
|
let(:subject) { described_class.new(index, template: custom_template) }
|
47
47
|
|
48
|
-
it
|
49
|
-
expect(subject.to_s).to eq
|
48
|
+
it "works out fine with the overridden template" do
|
49
|
+
expect(subject.to_s).to eq "-[88]-"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/spec/text_pool_spec.rb
CHANGED
@@ -3,32 +3,32 @@ module NameQ
|
|
3
3
|
let(:items) { %w[all of these names] }
|
4
4
|
let(:subject) { described_class.new(items) }
|
5
5
|
|
6
|
-
it
|
6
|
+
it "is a kind of pool" do
|
7
7
|
expect(subject).to be_a NameQ::Support::Pool
|
8
8
|
end
|
9
9
|
|
10
|
-
context
|
11
|
-
context
|
10
|
+
context "internals" do
|
11
|
+
context "underlying list" do
|
12
12
|
let(:list) { instance_double(NameQ::Support::List) }
|
13
|
-
let(:result) { subject.instance_variable_get(
|
13
|
+
let(:result) { subject.instance_variable_get("@list") }
|
14
14
|
|
15
|
-
it
|
15
|
+
it "builds the right kind of list by default" do
|
16
16
|
expect(NameQ::Support::List).to receive(:new).with(items, case_sensitive: true).and_return list
|
17
17
|
expect(result).to eq list
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
20
|
+
context "case-insensitive" do
|
21
21
|
let(:subject) { described_class.new(items, case_sensitive: false) }
|
22
22
|
|
23
|
-
it
|
23
|
+
it "builds the right kind of list by default" do
|
24
24
|
expect(NameQ::Support::List).to receive(:new).with(items, case_sensitive: false).and_return list
|
25
25
|
expect(result).to eq list
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
31
|
-
it
|
30
|
+
describe "#entry_factory" do
|
31
|
+
it "has a regular string entry factory" do
|
32
32
|
expect(subject.send(:entry_factory)).to eq NameQ::Support::StringEntry
|
33
33
|
end
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nameq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McDonald
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: standard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: yard
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +131,7 @@ extra_rdoc_files: []
|
|
117
131
|
files:
|
118
132
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
119
133
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
134
|
+
- ".github/workflows/gem-push.yml"
|
120
135
|
- ".github/workflows/ruby.yml"
|
121
136
|
- ".gitignore"
|
122
137
|
- ".rspec"
|
@@ -149,7 +164,7 @@ homepage: https://github.com/kevinstuffandthings/nameq
|
|
149
164
|
licenses:
|
150
165
|
- MIT
|
151
166
|
metadata: {}
|
152
|
-
post_install_message:
|
167
|
+
post_install_message:
|
153
168
|
rdoc_options: []
|
154
169
|
require_paths:
|
155
170
|
- lib
|
@@ -164,9 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
179
|
- !ruby/object:Gem::Version
|
165
180
|
version: '0'
|
166
181
|
requirements: []
|
167
|
-
|
168
|
-
|
169
|
-
signing_key:
|
182
|
+
rubygems_version: 3.0.3.1
|
183
|
+
signing_key:
|
170
184
|
specification_version: 4
|
171
185
|
summary: Create unique names via numeric suffixes
|
172
186
|
test_files:
|