kukushka 0.1.10 → 0.1.11
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 +32 -7
- data/lib/kukushka/version.rb +1 -1
- data/lib/kukushka.rb +70 -0
- 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: 1868389f90b7966de784b7c01ef008fb3112a851dbc90a8f09acf57df8120bd8
|
4
|
+
data.tar.gz: 4ffa3548b1f651dc8dbb459718dd2fdc2f4f0dc1844c198cc38b49cc6cb139a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 772d155cd2e503dd1e0e365e1c1d2a9a216c28111d2661fd222b1f33f3146dee452ed0fbf8e543b9b1d6a230bb7f69bfb79b9ba1f23ec4f8325c895b1b9f8fcb
|
7
|
+
data.tar.gz: a3ac0c16a33245cc6afa1beba585ff4a0ada8982d44f2b908881e16a65e3f52344d4106395901dea9fa7465b06a882dd5e56f5680056ba9d3e769ee7ac1dce3a
|
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
|
@@ -46,15 +49,17 @@ Commander.configure do
|
|
46
49
|
c.description = 'Sets annoying factor'
|
47
50
|
c.action do |args, options|
|
48
51
|
redis.set(:annoying, args.first)
|
52
|
+
Kukushka.store(redis)
|
49
53
|
# puts res if res
|
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 = 'Output format'
|
56
60
|
c.action do |args, options|
|
57
|
-
redis.set(:
|
61
|
+
redis.set(:format, args.first)
|
62
|
+
Kukushka.store(redis)
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
@@ -63,13 +68,15 @@ Commander.configure do
|
|
63
68
|
c.description = 'Add new source'
|
64
69
|
c.action do |args, options|
|
65
70
|
lines = File.readlines(args.first, chomp: true)
|
71
|
+
redis.set(:source, args.first)
|
66
72
|
redis.set(:lines, lines.to_json)
|
73
|
+
Kukushka.store(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
|
redis.set('enabled', true)
|
75
82
|
end
|
@@ -77,9 +84,27 @@ Commander.configure do
|
|
77
84
|
|
78
85
|
command :off do |c|
|
79
86
|
c.syntax = 'kuku off'
|
80
|
-
c.description = 'disable'
|
87
|
+
# c.description = 'disable'
|
81
88
|
c.action do |args, options|
|
82
89
|
redis.set('enabled', false)
|
83
90
|
end
|
84
91
|
end
|
92
|
+
|
93
|
+
command :status do |c|
|
94
|
+
c.syntax = 'kuku status'
|
95
|
+
c.description = 'disable'
|
96
|
+
c.action do |args, options|
|
97
|
+
%i(source enabled annoying output counter from circle).each do |key|
|
98
|
+
puts "#{key}: #{redis.get(key.to_s)}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
command :reset do |c|
|
104
|
+
c.syntax = 'kuku reset'
|
105
|
+
c.description = 'reset config'
|
106
|
+
c.action do |args, options|
|
107
|
+
Kukushka.reset(redis)
|
108
|
+
end
|
109
|
+
end
|
85
110
|
end
|
data/lib/kukushka/version.rb
CHANGED
data/lib/kukushka.rb
CHANGED
@@ -12,6 +12,76 @@ module Kukushka
|
|
12
12
|
Kukushka.kuku(redis)
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.store(redis)
|
16
|
+
Config.store(redis)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.restore(redis)
|
20
|
+
Config.restore(redis)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.reset(redis)
|
24
|
+
Config.reset(redis)
|
25
|
+
end
|
26
|
+
|
27
|
+
class Config
|
28
|
+
CONFIG_FILE = File.dirname(__FILE__) + '/../tmp/config/kuku.yaml'
|
29
|
+
SOURCE = File.dirname(__FILE__) + '/../spec/fixtures/pl_001.txt'
|
30
|
+
|
31
|
+
CONFIG_DIR = File.dirname(CONFIG_FILE)
|
32
|
+
dir = File.dirname(CONFIG_FILE)
|
33
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
34
|
+
|
35
|
+
def self.store(redis)
|
36
|
+
new.store(redis)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.restore(redis)
|
40
|
+
new.restore(redis)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.reset(redis)
|
44
|
+
config = new
|
45
|
+
config.reset
|
46
|
+
config.restore(redis)
|
47
|
+
end
|
48
|
+
|
49
|
+
def reset
|
50
|
+
config = {
|
51
|
+
source: SOURCE,
|
52
|
+
enabled: true,
|
53
|
+
counter: 0,
|
54
|
+
from: 0,
|
55
|
+
circle: 0,
|
56
|
+
annoying: 0,
|
57
|
+
output: nil,
|
58
|
+
}
|
59
|
+
|
60
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
61
|
+
end
|
62
|
+
|
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
|
68
|
+
|
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
|
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.11
|
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
|