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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 89502aa06cad37d7834baf70be3c8721f2836819
4
- data.tar.gz: 0b1eff879e6481e1b6a9fe5d649c8bffc07ac355
2
+ SHA256:
3
+ metadata.gz: dbdddb275117ac24cdd81c8c415abd9141edb88b99336fe6ba1f85949f5b8c21
4
+ data.tar.gz: 3f24b5ec1f8e15e82e39c5bb1475027c3fb5eb4fecca76b89ca3129f1df0ef7c
5
5
  SHA512:
6
- metadata.gz: 7b63d9935c384eb27522c0759f1bd380a24ae3c06590a2561b2cc36345015603925710de79007065a4bf59b19fc15f04eb79cb402505bb6ee628b678100f2035
7
- data.tar.gz: 3d1df2ec0ba886c86c0d06231bb001931009ee442aa944b152b84044ae0e195a373ac055a5e3f8225a0660043a1646dd3851b8ac6cba94308d50d1386f0f8aa2
6
+ metadata.gz: 26afc9d20e02346291c5cc5df08740f4b22a35b1f1207ec63b81d25fbb79a476e9cd3f83769de77c7198611f0d302a16af52e73c6a4977708218d4d268a2bbf8
7
+ data.tar.gz: cfc553dbcc66881b8562124f478a034657ba486811ce965e45906af5d0a1ab66c21448bbbdaa8bba8145fa8d6b33491bf48039d20ee5998c211651a0aa101258
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,4 @@
1
+ PreCommit:
2
+ RakeTarget:
3
+ enabled: true
4
+ targets: [default]
@@ -0,0 +1,3 @@
1
+ detectors:
2
+ IrresponsibleModule:
3
+ enabled: false
@@ -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/Not:
18
+ Style/FrozenStringLiteralComment:
11
19
  Enabled: false
12
20
 
13
- Style/TrailingCommaInArguments:
14
- EnforcedStyleForMultiline: comma
21
+ Style/Not:
22
+ Enabled: false
15
23
 
16
- Style/TrailingCommaInLiteral:
17
- EnforcedStyleForMultiline: comma
24
+ Style/StructInheritance:
25
+ Enabled: false
@@ -1 +1 @@
1
- 2.3
1
+ 2.5
@@ -1,10 +1,11 @@
1
- cache: bundler
2
- fast_finish: true
1
+ before_install:
2
+ - gem update --system
3
+ - gem install bundler
4
+ - bundle
3
5
  language: ruby
4
6
  matrix:
5
7
  allow_failures:
6
8
  - rvm: ruby-head
7
9
  rvm:
8
- - ruby-2.3.0
10
+ - 2.5
9
11
  - ruby-head
10
- sudo: false
data/Rakefile CHANGED
@@ -1,10 +1,9 @@
1
- # frozen_string_literal: true
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(test rubocop reek)
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|
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
2
 
4
3
  require_relative '../lib/signore'
5
4
  trap(:INT) { exit }
@@ -1,21 +1,25 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMREwDwYDVQQDDAhjaGFz
3
- dGVsbDEYMBYGCgmSJomT8ixkARkWCGNoYXN0ZWxsMRMwEQYKCZImiZPyLGQBGRYD
4
- bmV0MB4XDTE1MTEwOTIxMTMwOVoXDTE2MTEwODIxMTMwOVowQjERMA8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
+ IQkwo43CSWEZBCB+J9vfzYWAeVGWhupHlI/SxhrT7r8chfioDZ3viHMasmZQ5LE6
18
+ CMnQSQ/Cpj/WwmbUzVqBKFK+awivbFoOVbLWjUbhpIZ8CTJ71bj76bNfmJM+EoyJ
19
+ +e/45fxaSeq9FBuF2RN9EFndbUQ8HX2+0q66QgWV3aeegqi0HrapWE1pYMYCq3oa
20
+ YxTqzgX5Dc0hOJlfUbHa8o9Wd+uZtCUDYgW2mMFWDhtqODUelGQVE1ep+r2ezdkz
21
+ CC+NRY+4YHFBPMo6GFZvxWCuCURP5njE02LvRvQm/0sBJN5iiPrhCBC7B20vUD2W
22
+ BBp3qVHoVKxMKQ9hflY/qov85/Hgre3BKTv338CWTrDSC3HoHUXi1LhM2QYNG8oK
23
+ J29ZBdaXkaJ0zXg0Gi2ltKxs4vjxwSHdRqnaT29A8ca9mGWzzVmTqjPz8cFnt+1I
24
+ vmVyvVV5f57oDgaXeZLHRbgp+sU4WyyESZ9cHyYZks1tWKMOavbO7Q==
21
25
  -----END CERTIFICATE-----
@@ -0,0 +1,83 @@
1
+ PATH
2
+ remote: .
3
+ 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
@@ -1,4 +1,2 @@
1
- # frozen_string_literal: true
2
-
3
1
  source 'https://rubygems.org'
4
2
  gemspec
@@ -1,3 +1 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative 'signore/cli'
@@ -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(action tags) => :settings
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 = repo.find(tags: tags)
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.sig_from(input, tags: tags).tap { |sig| repo << sig }
40
+ SigFromStream.call(input, tags: tags).tap { |sig| repo << sig }
42
41
  end
43
42
  end
44
43
  end
@@ -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 'mapper'
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: Settings.new.repo_path, sig_finder: SigFinder.new)
15
- @path = 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 <<(sig)
21
- store.transaction { (store['signatures'] ||= []) << Mapper.to_h(sig) }
23
+ def <<(signature)
24
+ self.hashes = hashes + [signature.to_h]
22
25
  end
23
26
 
24
- delegate empty?: :sigs
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
- @sigs ||= begin
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, :sig_finder
35
+ attr_reader :path
40
36
 
41
37
  def convert
42
- store.transaction do
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
@@ -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[1..-1] or []
24
+ args.empty? ? [] : args[1..-1]
33
25
  end
34
26
  end
35
27
  end
@@ -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
- class SigFinder
8
- def initialize(random: Random.new)
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
- # frozen_string_literal: true
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
- def self.sig_from(input, tags: Tags.new)
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 to_sig
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
- return get_text if param == :text
31
- puts
32
- puts "#{param}?"
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