kukushka 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1868389f90b7966de784b7c01ef008fb3112a851dbc90a8f09acf57df8120bd8
4
- data.tar.gz: 4ffa3548b1f651dc8dbb459718dd2fdc2f4f0dc1844c198cc38b49cc6cb139a3
3
+ metadata.gz: 87f7d2da9cffcb01bf3b7dba61f237ab4f75f5e47451657832371a1222cdd754
4
+ data.tar.gz: 7363f9843f96e990b3ec29ac31e13cfe74339ca402ce2e2a9672f3d57bcd440b
5
5
  SHA512:
6
- metadata.gz: 772d155cd2e503dd1e0e365e1c1d2a9a216c28111d2661fd222b1f33f3146dee452ed0fbf8e543b9b1d6a230bb7f69bfb79b9ba1f23ec4f8325c895b1b9f8fcb
7
- data.tar.gz: a3ac0c16a33245cc6afa1beba585ff4a0ada8982d44f2b908881e16a65e3f52344d4106395901dea9fa7465b06a882dd5e56f5680056ba9d3e769ee7ac1dce3a
6
+ metadata.gz: c4e589c8f6d58c55700e9d080d01d8903f130c44b17ff3b70072fdf8a1342fa2cf2e11a7c5922f90785e6aeaded821986b3c5f9eb56b00ec142a69057d608154
7
+ data.tar.gz: bca9109ddb4d06224e25e27dc2cdd3a972c260e9242a4c520accfaa1e6228b7590955d9c10de299ffd193abe92e41fc384b2ec8f6e8234b5a4f556858e740f96
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kukushka (0.1.11)
4
+ kukushka (0.1.12)
5
5
  commander (~> 4.4)
6
6
  rainbow (~> 3.0)
7
7
  redis (~> 5.3)
data/exe/kuku CHANGED
@@ -39,6 +39,7 @@ Commander.configure do
39
39
  c.syntax = 'kuku init'
40
40
  c.description = 'Default initiation'
41
41
  c.action do |args, options|
42
+ Kukushka.reset(redis)
42
43
  # res = Kukushka.kuku(ARGV)
43
44
  # puts res if res
44
45
  end
@@ -48,18 +49,17 @@ Commander.configure do
48
49
  c.syntax = 'kuku annoying [int]'
49
50
  c.description = 'Sets annoying factor'
50
51
  c.action do |args, options|
51
- redis.set(:annoying, args.first)
52
- Kukushka.store(redis)
53
- # puts res if res
52
+ Kukushka.store({ annoying: args.first })
53
+ Kukushka.restore(redis)
54
54
  end
55
55
  end
56
56
 
57
57
  command :format do |c|
58
58
  c.syntax = 'kuku format simple'
59
- c.description = 'Output format'
59
+ c.description = 'format output'
60
60
  c.action do |args, options|
61
- redis.set(:format, args.first)
62
- Kukushka.store(redis)
61
+ Kukushka.store({ format: args.first })
62
+ Kukushka.restore(redis)
63
63
  end
64
64
  end
65
65
 
@@ -67,10 +67,10 @@ Commander.configure do
67
67
  c.syntax = 'kuku source file_path'
68
68
  c.description = 'Add new source'
69
69
  c.action do |args, options|
70
- lines = File.readlines(args.first, chomp: true)
71
- redis.set(:source, args.first)
72
- redis.set(:lines, lines.to_json)
73
- Kukushka.store(redis)
70
+ # lines = File.readlines(args.first, chomp: true)
71
+ # redis.set(:lines, lines.to_json)
72
+ Kukushka.store({source: args.first})
73
+ Kukushka.restore(redis)
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,8 @@ Commander.configure do
78
78
  c.syntax = 'kuku on'
79
79
  # c.description = 'enable'
80
80
  c.action do |args, options|
81
- redis.set('enabled', true)
81
+ Kukushka.store({enabled: true})
82
+ Kukushka.restore(redis)
82
83
  end
83
84
  end
84
85
 
@@ -86,7 +87,8 @@ Commander.configure do
86
87
  c.syntax = 'kuku off'
87
88
  # c.description = 'disable'
88
89
  c.action do |args, options|
89
- redis.set('enabled', false)
90
+ Kukushka.store({enabled: false})
91
+ Kukushka.restore(redis)
90
92
  end
91
93
  end
92
94
 
@@ -94,7 +96,7 @@ Commander.configure do
94
96
  c.syntax = 'kuku status'
95
97
  c.description = 'disable'
96
98
  c.action do |args, options|
97
- %i(source enabled annoying output counter from circle).each do |key|
99
+ %i(source enabled format counter from circle annoying).each do |key|
98
100
  puts "#{key}: #{redis.get(key.to_s)}"
99
101
  end
100
102
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kukushka
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.12"
5
5
  end
data/lib/kukushka.rb CHANGED
@@ -7,13 +7,14 @@ require 'yaml'
7
7
  module Kukushka
8
8
  EXAMPLE_SOURCE ||= File.dirname(__FILE__) + '/../fixtures/pl_001.txt'
9
9
  DEFULAT_LINES = File.readlines(EXAMPLE_SOURCE, chomp: true)
10
+ CONFIG_ENTRIES = %i(source enabled annoying format counter from circle)
10
11
 
11
12
  def self.kuku(redis)
12
13
  Kukushka.kuku(redis)
13
14
  end
14
15
 
15
- def self.store(redis)
16
- Config.store(redis)
16
+ def self.store(config_entry)
17
+ Config.store(config_entry)
17
18
  end
18
19
 
19
20
  def self.restore(redis)
@@ -32,8 +33,8 @@ module Kukushka
32
33
  dir = File.dirname(CONFIG_FILE)
33
34
  FileUtils.mkdir_p(dir) unless File.exist?(dir)
34
35
 
35
- def self.store(redis)
36
- new.store(redis)
36
+ def self.store(config_entry)
37
+ new.store(config_entry)
37
38
  end
38
39
 
39
40
  def self.restore(redis)
@@ -54,18 +55,17 @@ module Kukushka
54
55
  from: 0,
55
56
  circle: 0,
56
57
  annoying: 0,
57
- output: nil,
58
+ format: nil,
58
59
  }
59
60
 
60
61
  File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
61
62
  end
62
63
 
63
- def store(redis)
64
- config = {}
65
- %i(source enabled annoying output counter from circle).each do |key|
66
- config[key] = redis.get(key)
67
- end
64
+ def store(config_entry)
65
+ raise 'unknown config' if (config_entry.keys - CONFIG_ENTRIES).any?
68
66
 
67
+ config = YAML::load_file(CONFIG_FILE)
68
+ config.merge!(config_entry)
69
69
  File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
70
70
  end
71
71
 
@@ -125,7 +125,7 @@ module Kukushka
125
125
  end
126
126
 
127
127
 
128
- return lines[counter] if redis.get(:output) == 'simple'
128
+ return lines[counter] if redis.get(:format) == 'simple'
129
129
  return "#{lines[counter]} #{counter} [#{from}-#{to}/#{lines.size - 1}]"
130
130
  end
131
131
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kukushka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serge Kislak