signore 0.3.1 → 0.3.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
2
  SHA1:
3
- metadata.gz: 4429b92a7301b71b4b710583e55ce18a5b46777f
4
- data.tar.gz: dcf99b4753c4e304385ae67c2b90a9c69eb53899
3
+ metadata.gz: bfa7081166f66138934fa81485de2426aedf599f
4
+ data.tar.gz: b793a96754856ac62bc6343843b0197354c0e00b
5
5
  SHA512:
6
- metadata.gz: 7b091b37f94a2451db56b668896b2faa52ed05e00dd583d12f633d292b767fdfee282bf70f4d316b861b3de11a745728191f00225a76d0702905225a9e8a0010
7
- data.tar.gz: 12648f89f7636705a019a020c94cd279d302ea110e57ec317fdd0ebc6f7636a0fcb87c038d11f4e50950dc6347253858ce771a8369cfe238ac380bd1ce3673b2
6
+ metadata.gz: 3287652982fef7bd53702ef29f6d3f1ec6b4cd0ef3b02c74078e2d75b92829f513fa0069f18bc2939ea2cf9685deca9116125bc805736a39ecaaa692c5f7df68
7
+ data.tar.gz: 15f769de2fdda15cacb79dfd8f611747a051f2a58253cca0cc29c91ab26912277632b3a55022c50bf6c2eb5f7b1978664438b07a00dc439e6283dc77c698b5c0
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- signore (0.3.1)
5
- lovely_rufus (~> 0.2.0)
4
+ signore (0.3.2)
5
+ lovely_rufus (~> 0.2.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -17,12 +17,12 @@ GEM
17
17
  dependor (1.0.1)
18
18
  ffi (1.9.6)
19
19
  hitimes (1.2.2)
20
- listen (2.7.11)
20
+ listen (2.8.0)
21
21
  celluloid (>= 0.15.2)
22
22
  rb-fsevent (>= 0.9.3)
23
23
  rb-inotify (>= 0.9)
24
- lovely_rufus (0.2.0)
25
- minitest (5.4.2)
24
+ lovely_rufus (0.2.1)
25
+ minitest (5.4.3)
26
26
  minitest-focus (1.1.0)
27
27
  minitest (>= 4, < 6)
28
28
  parser (2.2.0.pre.7)
@@ -34,16 +34,16 @@ GEM
34
34
  rb-fsevent (0.9.4)
35
35
  rb-inotify (0.9.5)
36
36
  ffi (>= 0.5.0)
37
- reek (1.3.8)
37
+ reek (1.4.0)
38
38
  rainbow (>= 1.99, < 3.0)
39
39
  ruby2ruby (>= 2.0.8, < 3.0)
40
- ruby_parser (~> 3.3)
41
- sexp_processor
40
+ ruby_parser (>= 3.5.0, < 4.0)
41
+ sexp_processor (~> 4.4)
42
42
  rerun (0.10.0)
43
43
  listen (~> 2.7, >= 2.7.3)
44
- rubocop (0.27.0)
44
+ rubocop (0.27.1)
45
45
  astrolabe (~> 1.3)
46
- parser (>= 2.2.0.pre.6, < 3.0)
46
+ parser (>= 2.2.0.pre.7, < 3.0)
47
47
  powerpack (~> 0.0.6)
48
48
  rainbow (>= 1.99.1, < 3.0)
49
49
  ruby-progressbar (~> 1.4)
data/README.md CHANGED
@@ -71,7 +71,7 @@ Another aproach would be to create a named pipe that your email program reads fr
71
71
  Properties
72
72
  ----------
73
73
 
74
- Most `Signature`s have `text` and `tags`, some also have `author`, `source` and `subject`. Currently `tags` are used to query the sig database, while `author`, `source` and `subject` are combined into meta information displayed below the actual signature (right aligned and and in square brackets).
74
+ Most `Signature`s have `text` and `tags`, some also have `author`, `source` and `subject`. Currently `tags` are used to query the sig repository, while `author`, `source` and `subject` are combined into meta information displayed below the actual signature (right aligned and and in square brackets).
75
75
 
76
76
  The `text` of the `Signature`s is wrapped to 80 characters or fewer upon display (separately for every line). Additionally, if the result is two lines, signore attempts to make them roughly the same length. The wrapping engine also attempts to avoid one-letter words at ends of lines (moving them to the next line if possible).
77
77
 
data/config/reek.yml CHANGED
@@ -17,4 +17,4 @@ NestedIterators:
17
17
  UtilityFunction:
18
18
  exclude:
19
19
  - Signore::Mapper#from_h
20
- - Signore::Settings#db_path
20
+ - Signore::Settings#repo_path
data/lib/signore/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'forwardable'
2
- require_relative 'database'
2
+ require_relative 'repo'
3
3
  require_relative 'settings'
4
4
  require_relative 'sig_from_stream'
5
5
 
@@ -9,9 +9,9 @@ module Signore
9
9
 
10
10
  delegate %i(action tags) => :settings
11
11
 
12
- def initialize(args = ARGV, db: Database.new)
12
+ def initialize(args = ARGV, repo: Repo.new)
13
13
  @settings = Settings.new(args)
14
- @db = db
14
+ @repo = repo
15
15
  end
16
16
 
17
17
  def run(input: $stdin)
@@ -22,17 +22,17 @@ module Signore
22
22
  end
23
23
  end
24
24
 
25
- attr_reader :db, :settings
26
- private :db, :settings
25
+ attr_reader :repo, :settings
26
+ private :repo, :settings
27
27
 
28
28
  private
29
29
 
30
30
  def create_sig_from(input)
31
- SigFromStream.sig_from(input, tags: tags).tap { |sig| db << sig }
31
+ SigFromStream.sig_from(input, tags: tags).tap { |sig| repo << sig }
32
32
  end
33
33
 
34
34
  def retrieve_sig
35
- db.find(tags: tags)
35
+ repo.find(tags: tags)
36
36
  end
37
37
  end
38
38
  end
@@ -7,8 +7,8 @@ require_relative 'signature'
7
7
  require_relative 'tags'
8
8
 
9
9
  module Signore
10
- class Database
11
- def initialize(path: Settings.new.db_path, sig_finder: SigFinder)
10
+ class Repo
11
+ def initialize(path: Settings.new.repo_path, sig_finder: SigFinder)
12
12
  @path = path
13
13
  @sig_finder = sig_finder
14
14
  initialise_store if path.zero? or not path.exist?
@@ -11,9 +11,9 @@ module Signore
11
11
  args.first
12
12
  end
13
13
 
14
- def db_path
15
- db_dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') }
16
- Pathname.new("#{db_dir}/signore/signatures.yml")
14
+ def repo_path
15
+ dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') }
16
+ Pathname.new("#{dir}/signore/signatures.yml")
17
17
  end
18
18
 
19
19
  def tags
data/signore.gemspec CHANGED
@@ -7,13 +7,13 @@ 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.1'
10
+ gem.version = '0.3.2'
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) }
14
14
  gem.test_files = gem.files.grep(/^spec\/.*\.rb$/)
15
15
 
16
- gem.add_dependency 'lovely_rufus', '~> 0.2.0'
16
+ gem.add_dependency 'lovely_rufus', '~> 0.2.1'
17
17
 
18
18
  gem.add_development_dependency 'bogus', '~> 0.1.3'
19
19
  gem.add_development_dependency 'minitest', '~> 5.0'
@@ -77,10 +77,10 @@
77
77
  text: Better to teach a man to fish than to give him a fish. And if he can’t be bothered to learn to fish and starves to death, that’s a good enough outcome for me.
78
78
  author: Steve VanDevender
79
79
  - |-
80
- Better to teach a man to fish than to give him
81
- a fish. And if he can’t be bothered to learn to
82
- fish and starves to death, that’s a good enough outcome for me.
83
- [Steve VanDevender]
80
+ Better to teach a man to fish than to give him a fish.
81
+ And if he can’t be bothered to learn to fish and starves
82
+ to death, that’s a good enough outcome for me.
83
+ [Steve VanDevender]
84
84
 
85
85
  # for two-line signatures, first line is considered for hangouts
86
86
  - - !ruby/struct:Signore::Signature
@@ -21,19 +21,19 @@ module Signore
21
21
  end
22
22
 
23
23
  describe 'prego' do
24
- let(:db) { Database.new(path: path) }
24
+ let(:repo) { Repo.new(path: path) }
25
25
  let(:path) { Pathname.new('spec/fixtures/signatures.yml') }
26
26
 
27
27
  it 'prints a signature tagged with the provided tags' do
28
28
  args = %w(prego tech programming)
29
- out = capture_io { CLI.new(args, db: db).run }.first
29
+ out = capture_io { CLI.new(args, repo: repo).run }.first
30
30
  sig = "// sometimes I believe compiler ignores all my comments\n"
31
31
  out.must_equal sig
32
32
  end
33
33
 
34
34
  it 'prints a signature based on allowed and forbidden tags' do
35
35
  args = %w(prego ~programming tech ~security)
36
- out = capture_io { CLI.new(args, db: db).run }.first
36
+ out = capture_io { CLI.new(args, repo: repo).run }.first
37
37
  out.must_equal <<-end.dedent
38
38
  You do have to be mad to work here, but it doesn’t help.
39
39
  [Gary Barnes, asr]
@@ -42,7 +42,7 @@ module Signore
42
42
  end
43
43
 
44
44
  describe 'pronto' do
45
- let(:db) { Database.new(path: Pathname.new(Tempfile.new('').path)) }
45
+ let(:repo) { Repo.new(path: Pathname.new(Tempfile.new('').path)) }
46
46
 
47
47
  it 'asks about signature parts and saves resulting signature' do
48
48
  input = StringIO.new <<-end.dedent
@@ -51,7 +51,7 @@ module Signore
51
51
  Mark Pilgrim\n\n\n
52
52
  end
53
53
  args = %w(pronto Wikipedia ADHD)
54
- out = capture_io { CLI.new(args, db: db).run input: input }.first
54
+ out = capture_io { CLI.new(args, repo: repo).run input: input }.first
55
55
  out.must_equal <<-end.dedent
56
56
  text?
57
57
  author?
@@ -61,7 +61,7 @@ module Signore
61
61
  [Mark Pilgrim]
62
62
  end
63
63
  args = %w(prego Wikipedia ADHD)
64
- out = capture_io { CLI.new(args, db: db).run }.first
64
+ out = capture_io { CLI.new(args, repo: repo).run }.first
65
65
  out.must_equal <<-end.dedent
66
66
  The Wikipedia page on ADHD is like 20 pages long. That’s just cruel.
67
67
  [Mark Pilgrim]
@@ -75,7 +75,7 @@ module Signore
75
75
 
76
76
  Patrick Ewing\n\n\n
77
77
  end
78
- io = capture_io { CLI.new(['pronto'], db: db).run input: input }
78
+ io = capture_io { CLI.new(['pronto'], repo: repo).run input: input }
79
79
  io.first.must_equal <<-end.dedent
80
80
  text?
81
81
  author?
@@ -3,52 +3,52 @@ require 'pathname'
3
3
  require 'tempfile'
4
4
  require 'tmpdir'
5
5
  require_relative '../spec_helper'
6
- require_relative '../../lib/signore/database'
6
+ require_relative '../../lib/signore/repo'
7
7
  require_relative '../../lib/signore/signature'
8
8
  require_relative '../../lib/signore/tags'
9
9
 
10
10
  module Signore
11
- describe Database do
11
+ describe Repo do
12
12
  describe '#<<' do
13
13
  let(:path) { Pathname.new(Tempfile.new('').path) }
14
14
  let(:sig) { Signature.new(text: text) }
15
15
  let(:text) { 'Normaliser Unix c’est comme pasteuriser le camembert.' }
16
16
 
17
17
  it 'saves the provided signature to disk' do
18
- Database.new(path: path) << sig
18
+ Repo.new(path: path) << sig
19
19
  path.read.must_include text
20
20
  end
21
21
 
22
22
  it 'rewrites legacy YAML files on save' do
23
23
  FileUtils.cp Pathname.new('spec/fixtures/signatures.legacy.yml'), path
24
- Database.new(path: path) << sig
24
+ Repo.new(path: path) << sig
25
25
  path.read.wont_include 'Signore::Signature'
26
26
  end
27
27
  end
28
28
 
29
29
  describe '#find' do
30
- let(:database) { Database.new(path: path, sig_finder: sig_finder) }
31
- let(:path) { Pathname.new('spec/fixtures/signatures.yml') }
32
- let(:sig_finder) { fake(:sig_finder, as: :class) }
33
- let(:sigs) { database.sigs }
34
- let(:store) { YAML::Store.new(path) }
30
+ let(:path) { Pathname.new('spec/fixtures/signatures.yml') }
31
+ let(:repo) { Repo.new(path: path, sig_finder: sig_finder) }
32
+ let(:sig_finder) { fake(:sig_finder, as: :class) }
33
+ let(:sigs) { repo.sigs }
34
+ let(:store) { YAML::Store.new(path) }
35
35
 
36
36
  it 'returns a random signature by default' do
37
37
  stub(sig_finder).find(sigs, tags: Tags.new) { sigs.last }
38
- database.find.must_equal sigs.last
38
+ repo.find.must_equal sigs.last
39
39
  end
40
40
 
41
41
  it 'returns a random signature based on required and forbidden tags' do
42
42
  tags = Tags.new(forbidden: %w(tech), required: %w(programming security))
43
43
  stub(sig_finder).find(sigs, tags: tags) { sigs.last }
44
- database.find(tags: tags).must_equal sigs.last
44
+ repo.find(tags: tags).must_equal sigs.last
45
45
  end
46
46
 
47
47
  it 'doesn’t blow up if the path is missing' do
48
48
  begin
49
49
  tempdir = Dir.mktmpdir
50
50
  path = Pathname.new("#{tempdir}/some_intermediate_dir/sigs.yml")
51
- Database.new(path: path).find(tags: Tags.new).must_equal Signature.new
51
+ Repo.new(path: path).find(tags: Tags.new).must_equal Signature.new
52
52
  ensure
53
53
  FileUtils.rmtree tempdir
54
54
  end
@@ -56,16 +56,16 @@ module Signore
56
56
 
57
57
  it 'keeps working with legacy YAML files' do
58
58
  path = Pathname.new('spec/fixtures/signatures.legacy.yml')
59
- database = Database.new(path: path, sig_finder: sig_finder)
59
+ repo = Repo.new(path: path, sig_finder: sig_finder)
60
60
  stub(sig_finder).find(sigs, tags: Tags.new) { sigs.last }
61
- database.find.must_equal sigs.last
61
+ repo.find.must_equal sigs.last
62
62
  end
63
63
  end
64
64
 
65
65
  describe '#sigs' do
66
- it 'returns all the Signatures from the Database' do
66
+ it 'returns all the Signatures from the Repo' do
67
67
  path = Pathname.new('spec/fixtures/signatures.yml')
68
- sigs = Database.new(path: path).sigs
68
+ sigs = Repo.new(path: path).sigs
69
69
  sigs.size.must_equal 6
70
70
  sigs.first.author.must_equal 'Clive James'
71
71
  sigs.last.subject.must_equal 'Star Wars ending explained'
@@ -12,14 +12,14 @@ module Signore
12
12
  end
13
13
  end
14
14
 
15
- describe '#db_path' do
15
+ describe '#repo_path' do
16
16
  it 'honours XDG_DATA_HOME if it’s set' do
17
17
  begin
18
18
  old_xdg = ENV.delete('XDG_DATA_HOME')
19
19
  tempdir = Dir.mktmpdir
20
20
  ENV['XDG_DATA_HOME'] = tempdir
21
21
  path = "#{tempdir}/signore/signatures.yml"
22
- Settings.new.db_path.must_equal Pathname.new(path)
22
+ Settings.new.repo_path.must_equal Pathname.new(path)
23
23
  ensure
24
24
  FileUtils.rmtree tempdir
25
25
  old_xdg ? ENV['XDG_DATA_HOME'] = old_xdg : ENV.delete('XDG_DATA_HOME')
@@ -30,7 +30,7 @@ module Signore
30
30
  begin
31
31
  old_xdg = ENV.delete('XDG_DATA_HOME')
32
32
  path = File.expand_path('~/.local/share/signore/signatures.yml')
33
- Settings.new.db_path.must_equal Pathname.new(path)
33
+ Settings.new.repo_path.must_equal Pathname.new(path)
34
34
  ensure
35
35
  ENV['XDG_DATA_HOME'] = old_xdg if old_xdg
36
36
  end
@@ -6,7 +6,7 @@ require_relative '../../lib/signore/tags'
6
6
  module Signore
7
7
  describe SigFinder do
8
8
  let(:sigs) do
9
- Database.new(path: Pathname.new('spec/fixtures/signatures.yml')).sigs
9
+ Repo.new(path: Pathname.new('spec/fixtures/signatures.yml')).sigs
10
10
  end
11
11
 
12
12
  let(:sig_finder) { SigFinder.new(sigs) }
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.1
4
+ version: 0.3.2
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-11-08 00:00:00.000000000 Z
11
+ date: 2014-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lovely_rufus
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
19
+ version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.0
26
+ version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bogus
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -141,8 +141,8 @@ files:
141
141
  - config/reek.yml
142
142
  - lib/signore.rb
143
143
  - lib/signore/cli.rb
144
- - lib/signore/database.rb
145
144
  - lib/signore/mapper.rb
145
+ - lib/signore/repo.rb
146
146
  - lib/signore/settings.rb
147
147
  - lib/signore/sig_finder.rb
148
148
  - lib/signore/sig_from_stream.rb
@@ -153,8 +153,8 @@ files:
153
153
  - spec/fixtures/signatures.yml
154
154
  - spec/fixtures/wrapper.yml
155
155
  - spec/signore/cli_spec.rb
156
- - spec/signore/database_spec.rb
157
156
  - spec/signore/mapper_spec.rb
157
+ - spec/signore/repo_spec.rb
158
158
  - spec/signore/settings_spec.rb
159
159
  - spec/signore/sig_finder_spec.rb
160
160
  - spec/signore/sig_from_stream_spec.rb
@@ -186,8 +186,8 @@ specification_version: 4
186
186
  summary: 'signore: an email signature manager/randomiser'
187
187
  test_files:
188
188
  - spec/signore/cli_spec.rb
189
- - spec/signore/database_spec.rb
190
189
  - spec/signore/mapper_spec.rb
190
+ - spec/signore/repo_spec.rb
191
191
  - spec/signore/settings_spec.rb
192
192
  - spec/signore/sig_finder_spec.rb
193
193
  - spec/signore/sig_from_stream_spec.rb