signore 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.overcommit.yml +4 -0
- data/.reek.yml +3 -0
- data/.rubocop.yml +13 -5
- data/.ruby-version +1 -1
- data/.travis.yml +5 -4
- data/Rakefile +2 -4
- data/bin/signore +0 -1
- data/certs/chastell.pem +23 -19
- data/gems.locked +83 -0
- data/{Gemfile → gems.rb} +0 -2
- data/lib/signore.rb +0 -2
- data/lib/signore/cli.rb +4 -5
- data/lib/signore/repo.rb +25 -23
- data/lib/signore/settings.rb +1 -9
- data/lib/signore/sig_finder.rb +3 -11
- data/lib/signore/sig_from_stream.rb +6 -18
- data/lib/signore/signature.rb +10 -12
- data/lib/signore/tags.rb +1 -3
- data/signore.gemspec +7 -7
- data/test/fixtures/wrapper.yml +28 -19
- data/test/signore/cli_test.rb +30 -25
- data/test/signore/repo_test.rb +38 -40
- data/test/signore/settings_test.rb +3 -28
- data/test/signore/sig_finder_test.rb +9 -12
- data/test/signore/sig_from_stream_test.rb +9 -10
- data/test/signore/signature_test.rb +28 -16
- data/test/signore/tags_test.rb +10 -12
- data/test/test_helper.rb +0 -8
- metadata +65 -35
- metadata.gz.sig +0 -0
- data/.reek +0 -2
- data/Gemfile.lock +0 -67
- data/lib/signore/mapper.rb +0 -17
- data/test/signore/mapper_test.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbdddb275117ac24cdd81c8c415abd9141edb88b99336fe6ba1f85949f5b8c21
|
4
|
+
data.tar.gz: 3f24b5ec1f8e15e82e39c5bb1475027c3fb5eb4fecca76b89ca3129f1df0ef7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26afc9d20e02346291c5cc5df08740f4b22a35b1f1207ec63b81d25fbb79a476e9cd3f83769de77c7198611f0d302a16af52e73c6a4977708218d4d268a2bbf8
|
7
|
+
data.tar.gz: cfc553dbcc66881b8562124f478a034657ba486811ce965e45906af5d0a1ab66c21448bbbdaa8bba8145fa8d6b33491bf48039d20ee5998c211651a0aa101258
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.overcommit.yml
ADDED
data/.reek.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
Metrics/BlockLength:
|
2
|
+
Exclude:
|
3
|
+
- signore.gemspec
|
4
|
+
- test/**/*
|
5
|
+
|
6
|
+
Naming/HeredocDelimiterCase:
|
7
|
+
Enabled: false
|
8
|
+
|
1
9
|
Style/AndOr:
|
2
10
|
Enabled: false
|
3
11
|
|
@@ -7,11 +15,11 @@ Style/Documentation:
|
|
7
15
|
Style/EmptyCaseCondition:
|
8
16
|
Enabled: false
|
9
17
|
|
10
|
-
Style/
|
18
|
+
Style/FrozenStringLiteralComment:
|
11
19
|
Enabled: false
|
12
20
|
|
13
|
-
Style/
|
14
|
-
|
21
|
+
Style/Not:
|
22
|
+
Enabled: false
|
15
23
|
|
16
|
-
Style/
|
17
|
-
|
24
|
+
Style/StructInheritance:
|
25
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'bundler/setup'
|
3
2
|
require 'rake/testtask'
|
4
3
|
require 'reek/rake/task'
|
5
4
|
require 'rubocop/rake_task'
|
6
5
|
|
7
|
-
task default: %i
|
6
|
+
task default: %i[test rubocop reek]
|
8
7
|
|
9
8
|
Rake::TestTask.new do |task|
|
10
9
|
task.pattern = 'test/**/*_test.rb'
|
@@ -13,7 +12,6 @@ end
|
|
13
12
|
|
14
13
|
Reek::Rake::Task.new do |task|
|
15
14
|
task.fail_on_error = false
|
16
|
-
task.reek_opts = '--no-wiki-links'
|
17
15
|
end
|
18
16
|
|
19
17
|
RuboCop::RakeTask.new do |task|
|
data/bin/signore
CHANGED
data/certs/chastell.pem
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
2
|
+
MIIERDCCAqygAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBtjaGFz
|
3
|
+
dGVsbC9EQz1jaGFzdGVsbC9EQz1uZXQwHhcNMTgxMTEzMTkzNDIxWhcNMTkxMTEz
|
4
|
+
MTkzNDIxWjAmMSQwIgYDVQQDDBtjaGFzdGVsbC9EQz1jaGFzdGVsbC9EQz1uZXQw
|
5
|
+
ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC1jioiuQD8eIyuCXhry37a
|
6
|
+
KBqipfFlkc6Oz37i/LN6NE+TJCtGmgn/wDZDdJVTv3SOGomI1fFVkP7cWAIF+/4+
|
7
|
+
965ktOvenWIwok3LRaMvpnkzo0cqPoUYF9x5kx+9W2ATjmPldNsfC5gtfg5qEsPs
|
8
|
+
wqdeMet0Ll5ZMR36GfB+FDlGCD7OetSN7p3oZLqp0tMaac+VYWLdHbBNBmB1jQ3s
|
9
|
+
yXYndD3U/NjcTQhVJvpV/Qx9LnDdgsGlXYChiZcy1UTuTj/947WYc40/q9lVFAKg
|
10
|
+
MawVC/0NJhB5CC2+eTFX5fSioNNEecET5nJlIhxPO3YhL1o04cZ9a5qL3cfKouUp
|
11
|
+
Sf/QSolrGMS6K6fkUK6pkgoQSsjKqdgNXWe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
|
+
specs:
|
4
|
+
signore (0.7.0)
|
5
|
+
lovely_rufus (~> 1.0)
|
6
|
+
procto (~> 0.0.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.0)
|
12
|
+
axiom-types (0.1.1)
|
13
|
+
descendants_tracker (~> 0.0.4)
|
14
|
+
ice_nine (~> 0.11.0)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
16
|
+
bogus (0.1.6)
|
17
|
+
dependor (>= 0.0.4)
|
18
|
+
childprocess (0.9.0)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
codeclimate-engine-rb (0.4.1)
|
21
|
+
virtus (~> 1.0)
|
22
|
+
coercible (1.0.0)
|
23
|
+
descendants_tracker (~> 0.0.1)
|
24
|
+
dependor (1.0.1)
|
25
|
+
descendants_tracker (0.0.4)
|
26
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
27
|
+
equalizer (0.0.11)
|
28
|
+
ffi (1.9.25)
|
29
|
+
ice_nine (0.11.2)
|
30
|
+
iniparse (1.4.4)
|
31
|
+
jaro_winkler (1.5.1)
|
32
|
+
kwalify (0.7.2)
|
33
|
+
lovely_rufus (1.0.1)
|
34
|
+
minitest (5.11.3)
|
35
|
+
minitest-focus (1.1.2)
|
36
|
+
minitest (>= 4, < 6)
|
37
|
+
overcommit (0.46.0)
|
38
|
+
childprocess (~> 0.6, >= 0.6.3)
|
39
|
+
iniparse (~> 1.4)
|
40
|
+
parallel (1.12.1)
|
41
|
+
parser (2.5.3.0)
|
42
|
+
ast (~> 2.4.0)
|
43
|
+
powerpack (0.1.2)
|
44
|
+
procto (0.0.3)
|
45
|
+
rainbow (3.0.0)
|
46
|
+
rake (12.3.1)
|
47
|
+
reek (5.2.0)
|
48
|
+
codeclimate-engine-rb (~> 0.4.0)
|
49
|
+
kwalify (~> 0.7.0)
|
50
|
+
parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
|
51
|
+
rainbow (>= 2.0, < 4.0)
|
52
|
+
rubocop (0.60.0)
|
53
|
+
jaro_winkler (~> 1.5.1)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 2.5, != 2.5.1.1)
|
56
|
+
powerpack (~> 0.1)
|
57
|
+
rainbow (>= 2.2.2, < 4.0)
|
58
|
+
ruby-progressbar (~> 1.7)
|
59
|
+
unicode-display_width (~> 1.4.0)
|
60
|
+
ruby-progressbar (1.10.0)
|
61
|
+
thread_safe (0.3.6)
|
62
|
+
unicode-display_width (1.4.0)
|
63
|
+
virtus (1.0.5)
|
64
|
+
axiom-types (~> 0.1)
|
65
|
+
coercible (~> 1.0)
|
66
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
67
|
+
equalizer (~> 0.0, >= 0.0.9)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bogus (~> 0.1.3)
|
74
|
+
minitest (~> 5.6)
|
75
|
+
minitest-focus (~> 1.1)
|
76
|
+
overcommit (~> 0.46.0)
|
77
|
+
rake (~> 12.0)
|
78
|
+
reek (~> 5.0)
|
79
|
+
rubocop (~> 0.60.0)
|
80
|
+
signore!
|
81
|
+
|
82
|
+
BUNDLED WITH
|
83
|
+
1.17.1
|
data/{Gemfile → gems.rb}
RENAMED
data/lib/signore.rb
CHANGED
data/lib/signore/cli.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'forwardable'
|
4
2
|
require_relative 'repo'
|
5
3
|
require_relative 'settings'
|
4
|
+
require_relative 'sig_finder'
|
6
5
|
require_relative 'sig_from_stream'
|
7
6
|
|
8
7
|
module Signore
|
9
8
|
class CLI
|
10
9
|
extend Forwardable
|
11
10
|
|
12
|
-
delegate %i
|
11
|
+
delegate %i[action tags] => :settings
|
13
12
|
|
14
13
|
def initialize(args = ARGV, repo: Repo.new)
|
15
14
|
@settings = Settings.new(args)
|
@@ -29,7 +28,7 @@ module Signore
|
|
29
28
|
attr_reader :repo, :settings
|
30
29
|
|
31
30
|
def prego
|
32
|
-
sig =
|
31
|
+
sig = SigFinder.find(repo.sigs, tags: tags)
|
33
32
|
puts case
|
34
33
|
when repo.empty? then 'No signatures found.'
|
35
34
|
when sig.empty? then "Sadly no signatures are tagged #{tags}."
|
@@ -38,7 +37,7 @@ module Signore
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def create_sig_from(input)
|
41
|
-
SigFromStream.
|
40
|
+
SigFromStream.call(input, tags: tags).tap { |sig| repo << sig }
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
data/lib/signore/repo.rb
CHANGED
@@ -1,53 +1,55 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'forwardable'
|
2
|
+
require 'pathname'
|
4
3
|
require 'yaml/store'
|
5
|
-
require_relative '
|
6
|
-
require_relative 'settings'
|
7
|
-
require_relative 'sig_finder'
|
4
|
+
require_relative 'signature'
|
8
5
|
require_relative 'tags'
|
9
6
|
|
10
7
|
module Signore
|
11
8
|
class Repo
|
9
|
+
class << self
|
10
|
+
def default_path
|
11
|
+
dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') }
|
12
|
+
Pathname.new(dir) / 'signore' / 'signatures.yml'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
12
16
|
extend Forwardable
|
13
17
|
|
14
|
-
def initialize(path:
|
15
|
-
@path
|
16
|
-
@sig_finder = sig_finder
|
18
|
+
def initialize(path: self.class.default_path)
|
19
|
+
@path = path
|
17
20
|
convert if legacy?
|
18
21
|
end
|
19
22
|
|
20
|
-
def <<(
|
21
|
-
|
23
|
+
def <<(signature)
|
24
|
+
self.hashes = hashes + [signature.to_h]
|
22
25
|
end
|
23
26
|
|
24
|
-
delegate empty?: :
|
25
|
-
|
26
|
-
def find(tags: Tags.new)
|
27
|
-
sig_finder.find(sigs, tags: tags)
|
28
|
-
end
|
27
|
+
delegate empty?: :hashes
|
29
28
|
|
30
29
|
def sigs
|
31
|
-
|
32
|
-
hashes = store.transaction(true) { store.fetch('signatures', []) }
|
33
|
-
hashes.map(&Mapper.method(:from_h))
|
34
|
-
end
|
30
|
+
hashes.map(&Signature.method(:from_h))
|
35
31
|
end
|
36
32
|
|
37
33
|
private
|
38
34
|
|
39
|
-
attr_reader :path
|
35
|
+
attr_reader :path
|
40
36
|
|
41
37
|
def convert
|
42
|
-
|
43
|
-
store['signatures'] = store.fetch('signatures', []).map(&:to_h)
|
44
|
-
end
|
38
|
+
self.hashes = hashes.map(&:to_h)
|
45
39
|
end
|
46
40
|
|
47
41
|
def legacy?
|
48
42
|
path.exist? and path.read.include?('Signore::Signature')
|
49
43
|
end
|
50
44
|
|
45
|
+
def hashes
|
46
|
+
store.transaction(true) { store.fetch('signatures', []) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def hashes=(hashes)
|
50
|
+
store.transaction { store['signatures'] = hashes }
|
51
|
+
end
|
52
|
+
|
51
53
|
def store
|
52
54
|
@store ||= begin
|
53
55
|
path.dirname.mkpath
|
data/lib/signore/settings.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'pathname'
|
4
2
|
require_relative 'tags'
|
5
3
|
|
@@ -13,12 +11,6 @@ module Signore
|
|
13
11
|
args.first
|
14
12
|
end
|
15
13
|
|
16
|
-
# :reek:UtilityFunction
|
17
|
-
def repo_path
|
18
|
-
dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') }
|
19
|
-
Pathname.new("#{dir}/signore/signatures.yml")
|
20
|
-
end
|
21
|
-
|
22
14
|
def tags
|
23
15
|
negated, required = tag_names.partition { |name| name.start_with?('~') }
|
24
16
|
Tags.new(forbidden: negated.map { |neg| neg[1..-1] }, required: required)
|
@@ -29,7 +21,7 @@ module Signore
|
|
29
21
|
attr_reader :args
|
30
22
|
|
31
23
|
def tag_names
|
32
|
-
args[
|
24
|
+
args.empty? ? [] : args[1..-1]
|
33
25
|
end
|
34
26
|
end
|
35
27
|
end
|
data/lib/signore/sig_finder.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative 'signature'
|
4
2
|
require_relative 'tags'
|
5
3
|
|
6
4
|
module Signore
|
7
|
-
|
8
|
-
|
9
|
-
@random = random
|
10
|
-
end
|
5
|
+
module SigFinder
|
6
|
+
module_function
|
11
7
|
|
12
|
-
def find(sigs, tags: Tags.new)
|
8
|
+
def find(sigs, random: Random.new, tags: Tags.new)
|
13
9
|
shuffled = sigs.shuffle(random: random)
|
14
10
|
shuffled.find(-> { Signature.new }) { |sig| tags.match?(sig.tags) }
|
15
11
|
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :random
|
20
12
|
end
|
21
13
|
end
|
@@ -1,20 +1,17 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'procto'
|
3
2
|
require_relative 'signature'
|
4
3
|
require_relative 'tags'
|
5
4
|
|
6
5
|
module Signore
|
7
6
|
class SigFromStream
|
8
|
-
|
9
|
-
new(input, tags: tags).to_sig
|
10
|
-
end
|
7
|
+
include Procto.call
|
11
8
|
|
12
9
|
def initialize(input, tags: Tags.new)
|
13
10
|
@input = input
|
14
11
|
@tags = tags
|
15
12
|
end
|
16
13
|
|
17
|
-
def
|
14
|
+
def call
|
18
15
|
Signature.new(author: params.author, source: params.source,
|
19
16
|
subject: params.subject, tags: tags.required,
|
20
17
|
text: params.text)
|
@@ -27,18 +24,9 @@ module Signore
|
|
27
24
|
Params = Struct.new(:text, :author, :subject, :source)
|
28
25
|
|
29
26
|
def get_param(param)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
input.gets.strip
|
34
|
-
end
|
35
|
-
|
36
|
-
# :reek:FeatureEnvy
|
37
|
-
def get_text # rubocop:disable AccessorMethodName
|
38
|
-
puts 'text?'
|
39
|
-
value = ''
|
40
|
-
value += input.gets until value.lines.to_a.last == "\n"
|
41
|
-
value.strip
|
27
|
+
puts "\n#{param}?"
|
28
|
+
separator = param == :text ? "\n\n" : "\n"
|
29
|
+
input.gets(separator).strip
|
42
30
|
end
|
43
31
|
|
44
32
|
def params
|