kukushka 0.1.10 → 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 +4 -4
- data/Gemfile.lock +1 -1
- data/exe/kuku +39 -12
- data/lib/kukushka/version.rb +1 -1
- data/lib/kukushka.rb +71 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87f7d2da9cffcb01bf3b7dba61f237ab4f75f5e47451657832371a1222cdd754
|
4
|
+
data.tar.gz: 7363f9843f96e990b3ec29ac31e13cfe74339ca402ce2e2a9672f3d57bcd440b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4e589c8f6d58c55700e9d080d01d8903f130c44b17ff3b70072fdf8a1342fa2cf2e11a7c5922f90785e6aeaded821986b3c5f9eb56b00ec142a69057d608154
|
7
|
+
data.tar.gz: bca9109ddb4d06224e25e27dc2cdd3a972c260e9242a4c520accfaa1e6228b7590955d9c10de299ffd193abe92e41fc384b2ec8f6e8234b5a4f556858e740f96
|
data/Gemfile.lock
CHANGED
data/exe/kuku
CHANGED
@@ -7,7 +7,6 @@ require 'redis'
|
|
7
7
|
require 'redis-namespace'
|
8
8
|
require 'json'
|
9
9
|
|
10
|
-
|
11
10
|
redis_connection = Redis.new
|
12
11
|
redis = Redis::Namespace.new(:kukushka, redis: redis_connection)
|
13
12
|
|
@@ -21,6 +20,10 @@ Commander.configure do
|
|
21
20
|
c.syntax = 'kuku sample'
|
22
21
|
c.description = 'Show next sample'
|
23
22
|
c.action do |args, options|
|
23
|
+
unless redis.get('source')
|
24
|
+
Kukushka.restore(redis)
|
25
|
+
end
|
26
|
+
|
24
27
|
next unless redis.get('enabled') == 'true'
|
25
28
|
annoying = redis.get(:annoying).to_i
|
26
29
|
if annoying > 0
|
@@ -36,6 +39,7 @@ Commander.configure do
|
|
36
39
|
c.syntax = 'kuku init'
|
37
40
|
c.description = 'Default initiation'
|
38
41
|
c.action do |args, options|
|
42
|
+
Kukushka.reset(redis)
|
39
43
|
# res = Kukushka.kuku(ARGV)
|
40
44
|
# puts res if res
|
41
45
|
end
|
@@ -45,16 +49,17 @@ Commander.configure do
|
|
45
49
|
c.syntax = 'kuku annoying [int]'
|
46
50
|
c.description = 'Sets annoying factor'
|
47
51
|
c.action do |args, options|
|
48
|
-
|
49
|
-
|
52
|
+
Kukushka.store({ annoying: args.first })
|
53
|
+
Kukushka.restore(redis)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
|
-
command :
|
54
|
-
c.syntax = 'kuku
|
55
|
-
c.description = '
|
57
|
+
command :format do |c|
|
58
|
+
c.syntax = 'kuku format simple'
|
59
|
+
c.description = 'format output'
|
56
60
|
c.action do |args, options|
|
57
|
-
|
61
|
+
Kukushka.store({ format: args.first })
|
62
|
+
Kukushka.restore(redis)
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
@@ -62,24 +67,46 @@ Commander.configure do
|
|
62
67
|
c.syntax = 'kuku source file_path'
|
63
68
|
c.description = 'Add new source'
|
64
69
|
c.action do |args, options|
|
65
|
-
lines = File.readlines(args.first, chomp: true)
|
66
|
-
redis.set(:lines, lines.to_json)
|
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)
|
67
74
|
end
|
68
75
|
end
|
69
76
|
|
70
77
|
command :on do |c|
|
71
78
|
c.syntax = 'kuku on'
|
72
|
-
c.description = '
|
79
|
+
# c.description = 'enable'
|
73
80
|
c.action do |args, options|
|
74
|
-
|
81
|
+
Kukushka.store({enabled: true})
|
82
|
+
Kukushka.restore(redis)
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
78
86
|
command :off do |c|
|
79
87
|
c.syntax = 'kuku off'
|
88
|
+
# c.description = 'disable'
|
89
|
+
c.action do |args, options|
|
90
|
+
Kukushka.store({enabled: false})
|
91
|
+
Kukushka.restore(redis)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
command :status do |c|
|
96
|
+
c.syntax = 'kuku status'
|
80
97
|
c.description = 'disable'
|
81
98
|
c.action do |args, options|
|
82
|
-
|
99
|
+
%i(source enabled format counter from circle annoying).each do |key|
|
100
|
+
puts "#{key}: #{redis.get(key.to_s)}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
command :reset do |c|
|
106
|
+
c.syntax = 'kuku reset'
|
107
|
+
c.description = 'reset config'
|
108
|
+
c.action do |args, options|
|
109
|
+
Kukushka.reset(redis)
|
83
110
|
end
|
84
111
|
end
|
85
112
|
end
|
data/lib/kukushka/version.rb
CHANGED
data/lib/kukushka.rb
CHANGED
@@ -7,11 +7,81 @@ 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
|
|
16
|
+
def self.store(config_entry)
|
17
|
+
Config.store(config_entry)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.restore(redis)
|
21
|
+
Config.restore(redis)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset(redis)
|
25
|
+
Config.reset(redis)
|
26
|
+
end
|
27
|
+
|
28
|
+
class Config
|
29
|
+
CONFIG_FILE = File.dirname(__FILE__) + '/../tmp/config/kuku.yaml'
|
30
|
+
SOURCE = File.dirname(__FILE__) + '/../spec/fixtures/pl_001.txt'
|
31
|
+
|
32
|
+
CONFIG_DIR = File.dirname(CONFIG_FILE)
|
33
|
+
dir = File.dirname(CONFIG_FILE)
|
34
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
35
|
+
|
36
|
+
def self.store(config_entry)
|
37
|
+
new.store(config_entry)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.restore(redis)
|
41
|
+
new.restore(redis)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.reset(redis)
|
45
|
+
config = new
|
46
|
+
config.reset
|
47
|
+
config.restore(redis)
|
48
|
+
end
|
49
|
+
|
50
|
+
def reset
|
51
|
+
config = {
|
52
|
+
source: SOURCE,
|
53
|
+
enabled: true,
|
54
|
+
counter: 0,
|
55
|
+
from: 0,
|
56
|
+
circle: 0,
|
57
|
+
annoying: 0,
|
58
|
+
format: nil,
|
59
|
+
}
|
60
|
+
|
61
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
62
|
+
end
|
63
|
+
|
64
|
+
def store(config_entry)
|
65
|
+
raise 'unknown config' if (config_entry.keys - CONFIG_ENTRIES).any?
|
66
|
+
|
67
|
+
config = YAML::load_file(CONFIG_FILE)
|
68
|
+
config.merge!(config_entry)
|
69
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
70
|
+
end
|
71
|
+
|
72
|
+
def restore(redis)
|
73
|
+
config.each do |key, value|
|
74
|
+
redis.set(key, value)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def config
|
81
|
+
@config ||= YAML::load_file(CONFIG_FILE)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
15
85
|
class Kukushka
|
16
86
|
def self.kuku(redis)
|
17
87
|
new(redis).kuku
|
@@ -55,7 +125,7 @@ module Kukushka
|
|
55
125
|
end
|
56
126
|
|
57
127
|
|
58
|
-
return lines[counter] if redis.get(:
|
128
|
+
return lines[counter] if redis.get(:format) == 'simple'
|
59
129
|
return "#{lines[counter]} #{counter} [#{from}-#{to}/#{lines.size - 1}]"
|
60
130
|
end
|
61
131
|
|
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.
|
4
|
+
version: 0.1.12
|
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-
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|