signore 0.3.3 → 0.4.0

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
2
  SHA1:
3
- metadata.gz: 6cfb842786a542e13dc3cdee1e74bc008dd789a4
4
- data.tar.gz: 3f0c4e0cb4e27b390fd32b62cb59fe7317b9f58b
3
+ metadata.gz: 9b75dc357e994a66d6b3e1d8622244a16b8c4431
4
+ data.tar.gz: 645d959046b8c6a25da47aa7b0e041dbea08a622
5
5
  SHA512:
6
- metadata.gz: 961505f7494b297608087821fb41c95f9d1fa4fa7cb9afb096467708cc036cf7011146fa9bac5aceaba0e4aab1d44fd90078917d5bdfe144841c103db415a14d
7
- data.tar.gz: 5ffbfc986b267f701ddc91ba1bfcba3f9274c303b8fd7a24d0eb581357994532b04a918294e34e9bb5cce4efe2ff38ac5ed358e52b5b7afa465049f4d2dc1947
6
+ metadata.gz: 35d632d01c86f78b0401ee0c31a65b1aca323aa2c866d5bf5fab5dd3ff071bdeafffa8dbba1ab5831853a301caebdd4c390527e1dad2faeb143d266eecf012f1
7
+ data.tar.gz: 112cc070591a0d9dd986f1c1e919e6d08298921db663ea42f0f9d132727a020a38f5e481632a2ea9e52eb58d1932d9bc638aee12cad8dc0f7c60e8e4d3e2063b
data/.reek ADDED
@@ -0,0 +1,10 @@
1
+ FeatureEnvy:
2
+ exclude:
3
+ - Signore::Settings#forbidden
4
+
5
+ IrresponsibleModule:
6
+ enabled: false
7
+
8
+ UtilityFunction:
9
+ exclude:
10
+ - Signore::Settings#repo_path
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ # FIXME: https://github.com/bbatsov/rubocop/pull/1871
2
+ Performance/Sample:
3
+ Enabled: false
4
+
1
5
  Style/AndOr:
2
6
  Enabled: false
3
7
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- signore (0.3.3)
4
+ signore (0.4.0)
5
5
  lovely_rufus (~> 0.3.0)
6
- private_attr (~> 1.0)
6
+ private_attr (~> 1.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -24,54 +24,54 @@ GEM
24
24
  equalizer (~> 0.0.9)
25
25
  dependor (1.0.1)
26
26
  diff-lcs (1.2.5)
27
- equalizer (0.0.9)
28
- ffi (1.9.6)
27
+ equalizer (0.0.11)
28
+ ffi (1.9.8)
29
29
  hitimes (1.2.2)
30
30
  ice_nine (0.11.1)
31
- listen (2.8.5)
32
- celluloid (>= 0.15.2)
31
+ listen (2.10.0)
32
+ celluloid (~> 0.16.0)
33
33
  rb-fsevent (>= 0.9.3)
34
34
  rb-inotify (>= 0.9)
35
- lovely_rufus (0.3.0)
35
+ lovely_rufus (0.3.1)
36
36
  private_attr (~> 1.0)
37
37
  memoizable (0.4.2)
38
38
  thread_safe (~> 0.3, >= 0.3.1)
39
- minitest (5.5.1)
40
- minitest-focus (1.1.0)
39
+ minitest (5.6.1)
40
+ minitest-focus (1.1.1)
41
41
  minitest (>= 4, < 6)
42
- parser (2.2.0.2)
42
+ parser (2.2.2.2)
43
43
  ast (>= 1.1, < 3.0)
44
- powerpack (0.1.0)
45
- private_attr (1.0.0)
44
+ powerpack (0.1.1)
45
+ private_attr (1.1.0)
46
46
  procto (0.0.2)
47
47
  rainbow (2.0.0)
48
48
  rake (10.4.2)
49
49
  rb-fsevent (0.9.4)
50
50
  rb-inotify (0.9.5)
51
51
  ffi (>= 0.5.0)
52
- reek (2.0.0)
52
+ reek (2.2.0)
53
53
  parser (~> 2.2)
54
54
  rainbow (~> 2.0)
55
55
  unparser (~> 0.2.2)
56
56
  rerun (0.10.0)
57
57
  listen (~> 2.7, >= 2.7.3)
58
- rubocop (0.29.0)
58
+ rubocop (0.31.0)
59
59
  astrolabe (~> 1.3)
60
- parser (>= 2.2.0.1, < 3.0)
60
+ parser (>= 2.2.2.1, < 3.0)
61
61
  powerpack (~> 0.1)
62
62
  rainbow (>= 1.99.1, < 3.0)
63
63
  ruby-progressbar (~> 1.4)
64
- ruby-progressbar (1.7.1)
65
- thread_safe (0.3.4)
64
+ ruby-progressbar (1.7.5)
65
+ thread_safe (0.3.5)
66
66
  timers (4.0.1)
67
67
  hitimes
68
- unparser (0.2.2)
68
+ unparser (0.2.3)
69
69
  abstract_type (~> 0.0.7)
70
70
  adamantium (~> 0.2.0)
71
71
  concord (~> 0.1.5)
72
72
  diff-lcs (~> 1.2.5)
73
73
  equalizer (~> 0.0.9)
74
- parser (~> 2.2.0.2)
74
+ parser (~> 2.2.2, >= 2.2.2.2)
75
75
  procto (~> 0.0.2)
76
76
 
77
77
  PLATFORMS
@@ -84,5 +84,5 @@ DEPENDENCIES
84
84
  rake (~> 10.1)
85
85
  reek (~> 2.0)
86
86
  rerun (~> 0.10.0)
87
- rubocop (~> 0.29.0)
87
+ rubocop (~> 0.31.0)
88
88
  signore!
data/Rakefile CHANGED
@@ -10,10 +10,12 @@ Rake::TestTask.new do |task|
10
10
  end
11
11
 
12
12
  Reek::Rake::Task.new do |task|
13
- task.config_file = 'config/reek.yml'
14
13
  task.fail_on_error = false
15
14
  end
16
15
 
17
16
  RuboCop::RakeTask.new do |task|
18
17
  task.options << '--display-cop-names'
18
+ if Gem.loaded_specs['rubocop'].version > Gem::Version.create('0.31.0')
19
+ fail 'remove Performance/Sample exclusion from .rubocop.yml'
20
+ end
19
21
  end
@@ -1,23 +1,13 @@
1
+ require_relative 'signature'
1
2
  require_relative 'tags'
2
3
 
3
4
  module Signore
4
- class SigFinder
5
- def self.find(sigs, random: Random.new, tags: Tags.new)
6
- new(sigs, random: random).find_tagged(tags: tags)
7
- end
8
-
9
- def initialize(sigs, random: Random.new)
10
- @random = random
11
- @sigs = sigs
12
- end
5
+ module SigFinder
6
+ module_function
13
7
 
14
- def find_tagged(tags: Tags.new)
15
- sigs
16
- .select { |sig| tags.required.all? { |tag| sig.tagged_with?(tag) } }
17
- .reject { |sig| tags.forbidden.any? { |tag| sig.tagged_with?(tag) } }
18
- .sample(random: random) or Signature.new
8
+ def find(sigs, random: Random.new, tags: Tags.new)
9
+ found = sigs.shuffle(random: random).find { |sig| tags.match?(sig.tags) }
10
+ found or Signature.new
19
11
  end
20
-
21
- private_attr_reader :random, :sigs
22
12
  end
23
13
  end
@@ -7,10 +7,6 @@ module Signore
7
7
  each_pair { |key, value| self[key] = nil if value and value.empty? }
8
8
  end
9
9
 
10
- def tagged_with?(tag)
11
- tags and tags.include?(tag)
12
- end
13
-
14
10
  def to_h
15
11
  super.map { |key, val| [key.to_s, val] }.to_h.keep_if { |_, value| value }
16
12
  end
data/lib/signore/tags.rb CHANGED
@@ -3,5 +3,10 @@ module Signore
3
3
  def initialize(forbidden: [], required: [])
4
4
  super forbidden, required
5
5
  end
6
+
7
+ def match?(sig_tags)
8
+ sig_tags ||= []
9
+ (required & sig_tags) == required and (forbidden & sig_tags).empty?
10
+ end
6
11
  end
7
12
  end
data/lib/signore.rb CHANGED
@@ -1,4 +1,2 @@
1
- require 'private_attr'
2
- Class.include PrivateAttr
3
-
1
+ require 'private_attr/everywhere'
4
2
  require_relative 'signore/cli'
data/signore.gemspec CHANGED
@@ -7,14 +7,14 @@ Gem::Specification.new do |gem|
7
7
  gem.license = 'AGPL-3.0'
8
8
  gem.name = 'signore'
9
9
  gem.summary = 'signore: an email signature manager/randomiser'
10
- gem.version = '0.3.3'
10
+ gem.version = '0.4.0'
11
11
 
12
12
  gem.files = `git ls-files -z`.split "\0"
13
- gem.executables = gem.files.grep(/^bin\//).map { |path| File.basename(path) }
14
- gem.test_files = gem.files.grep(/^test\/.*\.rb$/)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map { |path| File.basename(path) }
14
+ gem.test_files = gem.files.grep(%r{^test/.*\.rb$})
15
15
 
16
16
  gem.add_dependency 'lovely_rufus', '~> 0.3.0'
17
- gem.add_dependency 'private_attr', '~> 1.0'
17
+ gem.add_dependency 'private_attr', '~> 1.1'
18
18
 
19
19
  gem.add_development_dependency 'bogus', '~> 0.1.3'
20
20
  gem.add_development_dependency 'minitest', '~> 5.0'
@@ -22,5 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'rake', '~> 10.1'
23
23
  gem.add_development_dependency 'reek', '~> 2.0'
24
24
  gem.add_development_dependency 'rerun', '~> 0.10.0'
25
- gem.add_development_dependency 'rubocop', '~> 0.29.0'
25
+ gem.add_development_dependency 'rubocop', '~> 0.31.0'
26
26
  end
@@ -13,14 +13,14 @@ module Signore
13
13
 
14
14
  describe '.find' do
15
15
  it 'returns a random Signature by default' do
16
- SigFinder.find(sigs, random: Random.new(1981)).text
16
+ SigFinder.find(sigs, random: Random.new(0)).text
17
17
  .must_include 'Amateur fighter pilot ignores orders'
18
- SigFinder.find(sigs, random: Random.new(2009)).text
18
+ SigFinder.find(sigs, random: Random.new(1)).text
19
19
  .must_equal '// sometimes I believe compiler ignores all my comments'
20
20
  end
21
21
 
22
22
  it 'returns a random signature if the tags are empty' do
23
- SigFinder.find(sigs, tags: Tags.new, random: Random.new(2013)).text
23
+ SigFinder.find(sigs, tags: Tags.new, random: Random.new(1)).text
24
24
  .must_equal '// sometimes I believe compiler ignores all my comments'
25
25
  end
26
26
 
@@ -27,19 +27,6 @@ module Signore
27
27
  end
28
28
  end
29
29
 
30
- describe '#tagged_with?' do
31
- it 'says whether a tagged signature is tagged with a given tag' do
32
- sig = Signature.new(tags: %w(programming tech), text: '')
33
- refute sig.tagged_with?('fnord')
34
- assert sig.tagged_with?('programming')
35
- assert sig.tagged_with?('tech')
36
- end
37
-
38
- it 'says that an untagged signature is not tagged with any tag' do
39
- refute Signature.new.tagged_with?('fnord')
40
- end
41
- end
42
-
43
30
  describe '#to_h' do
44
31
  it 'returns a String-keyed Hash representation of the Signature' do
45
32
  text = 'For the sake of topic titles, I’d rather if Monty saved Python.'
@@ -0,0 +1,20 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../../lib/signore/tags'
3
+
4
+ module Signore
5
+ describe Tags do
6
+ describe '#match?' do
7
+ it 'is a predicate whether the Tags match the given list of tags' do
8
+ tags = %w(programming tech)
9
+ assert Tags.new.match?(nil)
10
+ assert Tags.new(forbidden: %w(fnord)).match?(nil)
11
+ assert Tags.new.match?(tags)
12
+ assert Tags.new(required: %w(programming)).match?(tags)
13
+ assert Tags.new(required: %w(programming tech)).match?(tags)
14
+ refute Tags.new(required: %w(programming tech Ruby)).match?(tags)
15
+ refute Tags.new(forbidden: %w(programming)).match?(tags)
16
+ refute Tags.new(forbidden: %w(tech), required: %w(tech)).match?(tags)
17
+ end
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Szotkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lovely_rufus
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bogus
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.29.0
131
+ version: 0.31.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.29.0
138
+ version: 0.31.0
139
139
  description: signore helps manage email signatures and select random ones based on
140
140
  their tags
141
141
  email: chastell@chastell.net
@@ -144,6 +144,7 @@ executables:
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
+ - ".reek"
147
148
  - ".rubocop.yml"
148
149
  - ".ruby-version"
149
150
  - Gemfile
@@ -152,7 +153,6 @@ files:
152
153
  - README.md
153
154
  - Rakefile
154
155
  - bin/signore
155
- - config/reek.yml
156
156
  - lib/signore.rb
157
157
  - lib/signore/cli.rb
158
158
  - lib/signore/mapper.rb
@@ -173,6 +173,7 @@ files:
173
173
  - test/signore/sig_finder_test.rb
174
174
  - test/signore/sig_from_stream_test.rb
175
175
  - test/signore/signature_test.rb
176
+ - test/signore/tags_test.rb
176
177
  - test/test_helper.rb
177
178
  homepage: http://github.com/chastell/signore
178
179
  licenses:
@@ -206,4 +207,6 @@ test_files:
206
207
  - test/signore/sig_finder_test.rb
207
208
  - test/signore/sig_from_stream_test.rb
208
209
  - test/signore/signature_test.rb
210
+ - test/signore/tags_test.rb
209
211
  - test/test_helper.rb
212
+ has_rdoc:
data/config/reek.yml DELETED
@@ -1,20 +0,0 @@
1
- DuplicateMethodCall:
2
- exclude:
3
- - Signore::SigFinder#find_tagged
4
-
5
- FeatureEnvy:
6
- exclude:
7
- - Signore::Mapper#from_h
8
- - Signore::Mapper#to_h
9
- - Signore::Settings#forbidden
10
-
11
- IrresponsibleModule:
12
- enabled: false
13
-
14
- NestedIterators:
15
- max_allowed_nesting: 2
16
-
17
- UtilityFunction:
18
- exclude:
19
- - Signore::Mapper#from_h
20
- - Signore::Settings#repo_path