kukushka 0.1.11 → 0.1.13

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: adf8add37c4d2e2acf6abf07f0f67991aa0fe0f409b98bb51c37e155fa3a4650
4
+ data.tar.gz: c681fad37611cf93c4ad374e7fdf6cdd4f7f829820a8a83aa7cf846429148e1f
5
5
  SHA512:
6
- metadata.gz: 772d155cd2e503dd1e0e365e1c1d2a9a216c28111d2661fd222b1f33f3146dee452ed0fbf8e543b9b1d6a230bb7f69bfb79b9ba1f23ec4f8325c895b1b9f8fcb
7
- data.tar.gz: a3ac0c16a33245cc6afa1beba585ff4a0ada8982d44f2b908881e16a65e3f52344d4106395901dea9fa7465b06a882dd5e56f5680056ba9d3e769ee7ac1dce3a
6
+ metadata.gz: 73201188860cb406cfab023c0cb635e12e844434ff617d66db937aa4cf7aaab8b438fef80f02278ffe00083d3bcf947b3c2accb39b596c783e331d5c6951eaad
7
+ data.tar.gz: 72873bcd3cf8cf858f53459f0a1cc1ed5798c2913579fdfbd23ce13d37337c773687b17fc53eb9fccafc6350482f726ce8c5a1bbd958014ff2421b4960579c20
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.13"
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
 
@@ -73,6 +73,11 @@ module Kukushka
73
73
  config.each do |key, value|
74
74
  redis.set(key, value)
75
75
  end
76
+
77
+ if @source = redis.get(:source)
78
+ value = File.readlines(@source, chomp: true)
79
+ redis.set(:lines, value)
80
+ end
76
81
  end
77
82
 
78
83
  private
@@ -125,7 +130,7 @@ module Kukushka
125
130
  end
126
131
 
127
132
 
128
- return lines[counter] if redis.get(:output) == 'simple'
133
+ return lines[counter] if redis.get(:format) == 'simple'
129
134
  return "#{lines[counter]} #{counter} [#{from}-#{to}/#{lines.size - 1}]"
130
135
  end
131
136
 
metadata CHANGED
@@ -1,14 +1,14 @@
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.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serge Kislak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-03 00:00:00.000000000 Z
11
+ date: 2025-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow