signore 0.2.3 → 0.2.4

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: b5b9c7abacbf5730fdbadf79e7d5fe61ec37cdd3
4
- data.tar.gz: 587a3996c7fabb7e31b3bd27250310749b588f0c
3
+ metadata.gz: 574592e64de19564735c0cb34ed8176d4a2c2ef2
4
+ data.tar.gz: e2c9d9a4e3ca171b214f936865fabbaf675a1786
5
5
  SHA512:
6
- metadata.gz: 0f04915b49b5d7f3678bd178def6607a7bd20727f2bcf1db2731ee86ef8e058c5107004183d7ac4fd47c5aa418b00ccc5df3f53cee0f0f1de35a8c5ca2c3ad14
7
- data.tar.gz: b37a86a56e2309943664de9ad3a5b1934d037fca249d123dcfb82cf6bd05f29357c91fa177c8d0e8bd0eb4ab14571c451dbf6014365c9c50568d17ef8158a1c2
6
+ metadata.gz: 7789db08a85ae9121a8764d677297c3f165b163804edf4819fe60619e5614c5c36709ef9bedf469d613294d4ffc5e9f8251a0f1c7874a0395520cd8a0d4dd242
7
+ data.tar.gz: ec717cbde5846a0aea3dc693b76edbfee3f2f85bece044452c9eec4b39acb92be1e9a5d021c6c3cf3dc7af58a35c4a99f1854735b60e23a57c4f3d4fd5e9e31e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- signore (0.2.2)
4
+ signore (0.2.4)
5
5
  lovely_rufus (~> 0.2.0)
6
6
 
7
7
  GEM
@@ -15,17 +15,17 @@ GEM
15
15
  celluloid (0.16.0)
16
16
  timers (~> 4.0.0)
17
17
  dependor (1.0.1)
18
- ffi (1.9.3)
18
+ ffi (1.9.6)
19
19
  hitimes (1.2.2)
20
- listen (2.7.9)
20
+ listen (2.7.11)
21
21
  celluloid (>= 0.15.2)
22
22
  rb-fsevent (>= 0.9.3)
23
23
  rb-inotify (>= 0.9)
24
24
  lovely_rufus (0.2.0)
25
- minitest (5.4.1)
25
+ minitest (5.4.2)
26
26
  minitest-focus (1.1.0)
27
27
  minitest (>= 4, < 6)
28
- parser (2.2.0.pre.4)
28
+ parser (2.2.0.pre.5)
29
29
  ast (>= 1.1, < 3.0)
30
30
  slop (~> 3.4, >= 3.4.5)
31
31
  powerpack (0.0.9)
@@ -41,17 +41,17 @@ GEM
41
41
  sexp_processor
42
42
  rerun (0.10.0)
43
43
  listen (~> 2.7, >= 2.7.3)
44
- rubocop (0.26.0)
44
+ rubocop (0.26.1)
45
45
  astrolabe (~> 1.3)
46
46
  parser (>= 2.2.0.pre.4, < 3.0)
47
47
  powerpack (~> 0.0.6)
48
48
  rainbow (>= 1.99.1, < 3.0)
49
49
  ruby-progressbar (~> 1.4)
50
- ruby-progressbar (1.5.1)
51
- ruby2ruby (2.1.2)
50
+ ruby-progressbar (1.6.0)
51
+ ruby2ruby (2.1.3)
52
52
  ruby_parser (~> 3.1)
53
53
  sexp_processor (~> 4.0)
54
- ruby_parser (3.6.2)
54
+ ruby_parser (3.6.3)
55
55
  sexp_processor (~> 4.1)
56
56
  sexp_processor (4.4.4)
57
57
  slop (3.6.0)
data/lib/signore/cli.rb CHANGED
@@ -1,28 +1,39 @@
1
+ require 'forwardable'
1
2
  require_relative 'database'
2
3
  require_relative 'settings'
3
4
  require_relative 'sig_from_stream'
4
5
 
5
6
  module Signore
6
7
  class CLI
8
+ extend Forwardable
9
+
10
+ delegate %i(action tags) => :settings
11
+
7
12
  def initialize(args = ARGV, db: Database.new)
8
13
  @settings = Settings.new(args)
9
14
  @db = db
10
15
  end
11
16
 
12
17
  def run(input: $stdin)
13
- case settings.action
14
- when 'prego'
15
- puts db.find(tags: settings.tags)
16
- when 'pronto'
17
- sig = SigFromStream.sig_from(input, tags: settings.tags)
18
- db << sig
19
- puts sig
20
- else
21
- abort 'usage: signore prego|pronto [tag, …]'
18
+ trap(:INT) { exit }
19
+ case action
20
+ when 'prego' then puts retrieve_sig
21
+ when 'pronto' then puts create_sig_from(input)
22
+ else abort 'usage: signore prego|pronto [tag, …]'
22
23
  end
23
24
  end
24
25
 
25
26
  attr_reader :db, :settings
26
27
  private :db, :settings
28
+
29
+ private
30
+
31
+ def create_sig_from(input)
32
+ SigFromStream.sig_from(input, tags: tags).tap { |sig| db << sig }
33
+ end
34
+
35
+ def retrieve_sig
36
+ db.find(tags: tags)
37
+ end
27
38
  end
28
39
  end
@@ -15,7 +15,6 @@ module Signore
15
15
 
16
16
  def <<(sig)
17
17
  store.transaction { store['signatures'] << sig }
18
- sig
19
18
  end
20
19
 
21
20
  def find(tags: Tags.new)
@@ -26,11 +26,15 @@ module Signore
26
26
  private
27
27
 
28
28
  def forbidden
29
- args[1..-1].select { |tag| tag.start_with?('~') }.map { |tag| tag[1..-1] }
29
+ tag_names.select { |tag| tag.start_with?('~') }.map { |tag| tag[1..-1] }
30
30
  end
31
31
 
32
32
  def required
33
- args[1..-1].reject { |tag| tag.start_with?('~') }
33
+ tag_names.reject { |tag| tag.start_with?('~') }
34
+ end
35
+
36
+ def tag_names
37
+ args[1..-1] or []
34
38
  end
35
39
  end
36
40
  end
data/signore.gemspec CHANGED
@@ -7,7 +7,7 @@ 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.2.3'
10
+ gem.version = '0.2.4'
11
11
 
12
12
  gem.files = `git ls-files -z`.split "\0"
13
13
  gem.executables = gem.files.grep(/^bin\//).map { |path| File.basename(path) }
@@ -10,17 +10,12 @@ require_relative '../../lib/signore/tags'
10
10
  module Signore
11
11
  describe Database do
12
12
  describe '#<<' do
13
- let(:file) { Tempfile.new('') }
14
- let(:sig) { Signature.new(text) }
15
- let(:text) { 'Normaliser Unix c’est comme pasteuriser le camembert.' }
16
-
17
13
  it 'saves the provided signature to disk' do
18
- Database.new(path: Pathname.new(file.path)) << sig
19
- file.read.must_include text
20
- end
21
-
22
- it 'returns the saved signature' do
23
- Database.new(path: Pathname.new(file.path)).<<(sig).must_equal sig
14
+ text = 'Normaliser Unix c’est comme pasteuriser le camembert.'
15
+ sig = Signature.new(text)
16
+ path = Pathname.new(Tempfile.new('').path)
17
+ Database.new(path: path) << sig
18
+ path.read.must_include text
24
19
  end
25
20
  end
26
21
 
@@ -42,6 +42,10 @@ module Signore
42
42
  tags = Tags.new(forbidden: %w(tech), required: %w(en))
43
43
  Settings.new(%w(prego ~tech en)).tags.must_equal tags
44
44
  end
45
+
46
+ it 'doesn’t blow up on empty args' do
47
+ Settings.new([]).tags.must_equal Tags.new
48
+ end
45
49
  end
46
50
  end
47
51
  end
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,6 @@ Bogus.configure { |config| config.search_modules << Signore }
9
9
 
10
10
  class String
11
11
  def dedent
12
- gsub(/^#{self[/\A\s*/]}/, '')
12
+ gsub(/^#{scan(/^ +/).min}/, '')
13
13
  end
14
14
  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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Szotkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lovely_rufus