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 +4 -4
- data/Gemfile.lock +1 -1
- data/exe/kuku +15 -13
- data/lib/kukushka/version.rb +1 -1
- data/lib/kukushka.rb +11 -11
- metadata +1 -1
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
@@ -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
|
-
|
52
|
-
Kukushka.
|
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 = '
|
59
|
+
c.description = 'format output'
|
60
60
|
c.action do |args, options|
|
61
|
-
|
62
|
-
Kukushka.
|
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(:
|
72
|
-
|
73
|
-
Kukushka.
|
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
|
-
|
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
|
-
|
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
|
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
|
data/lib/kukushka/version.rb
CHANGED
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(
|
16
|
-
Config.store(
|
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(
|
36
|
-
new.store(
|
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
|
-
|
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(
|
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(:
|
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
|
|