kukushka 0.1.4 → 0.1.5
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/kukushka-0.1.4.gem +0 -0
- data/lib/kukushka/version.rb +1 -1
- data/lib/kukushka.rb +72 -5
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d030697e9f1111877140f181beeeea09d6167a2a4bd4aeab2d17cf6d4c355c2c
|
4
|
+
data.tar.gz: a12340d1ec1a48292e0b3e22b2ffac82fa7e5273f7b286f1fc3da940a378e79d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f25df4940db25abd1a34b886adf32dd34d412cdffb8082b48da325d75b8dd1265f4358f3cc7b23c012347040e0c975146d4be8ba5cc4557106ccf221248c27b9
|
7
|
+
data.tar.gz: c98bd1748f07f2fb26e7336a31b5f939ea48f3d3efc5d7aa55a75141f5b697f4fd01261fa026e9eebe55988173744351f9684f3ed8ce7d6e6a1384a1b8bd5fa6
|
data/kukushka-0.1.4.gem
ADDED
Binary file
|
data/lib/kukushka/version.rb
CHANGED
data/lib/kukushka.rb
CHANGED
@@ -7,6 +7,7 @@ require 'yaml'
|
|
7
7
|
module Kukushka
|
8
8
|
INIT_CTA = "TODO: kuku init source_file"
|
9
9
|
PROVIDE_SOURCE_CTA = "TODO: provide valid source_file path"
|
10
|
+
DEFAULT_CIRCLE = 5
|
10
11
|
|
11
12
|
def self.kuku(args)
|
12
13
|
Kukushka.kuku(args)
|
@@ -42,7 +43,10 @@ module Kukushka
|
|
42
43
|
FileUtils.mkdir_p(dir) unless File.exists?(dir)
|
43
44
|
config = {
|
44
45
|
source: source_file,
|
45
|
-
enabled: true
|
46
|
+
enabled: true,
|
47
|
+
counter: 0,
|
48
|
+
from: 0,
|
49
|
+
circle: DEFAULT_CIRCLE,
|
46
50
|
}
|
47
51
|
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
48
52
|
end
|
@@ -64,10 +68,36 @@ module Kukushka
|
|
64
68
|
end
|
65
69
|
|
66
70
|
def source
|
67
|
-
@source ||=
|
71
|
+
@source ||= config[:source]
|
72
|
+
end
|
73
|
+
|
74
|
+
def counter
|
75
|
+
@counter ||= config[:counter]
|
76
|
+
end
|
77
|
+
|
78
|
+
def from
|
79
|
+
@from ||= config[:from]
|
80
|
+
end
|
81
|
+
|
82
|
+
def circle
|
83
|
+
@circle ||= config[:circle]
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_counter(new_counter)
|
87
|
+
config.merge!(counter: new_counter)
|
88
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
89
|
+
end
|
90
|
+
|
91
|
+
def set_circle(new_circle)
|
92
|
+
config.merge!(circle: new_circle)
|
93
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
94
|
+
end
|
95
|
+
|
96
|
+
def set_from(new_from)
|
97
|
+
config.merge!(from: new_from)
|
98
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
68
99
|
end
|
69
100
|
|
70
|
-
private
|
71
101
|
def config
|
72
102
|
@config ||= YAML::load_file(CONFIG_FILE)
|
73
103
|
end
|
@@ -94,10 +124,28 @@ module Kukushka
|
|
94
124
|
return config.enable if command == 'on'
|
95
125
|
return config.disable if command == 'off'
|
96
126
|
|
127
|
+
if command == 'counter'
|
128
|
+
return config.set_counter(0) if param1.nil?
|
129
|
+
return config.set_counter(nil) if param1 == 'no' || param1 == 'off' || param1 == 'nil'
|
130
|
+
return config.set_counter(param1.to_i)
|
131
|
+
end
|
132
|
+
|
133
|
+
if command == 'from'
|
134
|
+
config.set_from(0) if param1.nil?
|
135
|
+
config.set_from(param1.to_i)
|
136
|
+
config.set_counter(config.from)
|
137
|
+
end
|
138
|
+
|
139
|
+
if command == 'circle'
|
140
|
+
config.set_circle(DEFAULT_CIRCLE) if param1.nil?
|
141
|
+
config.set_circle(param1.to_i)
|
142
|
+
config.set_counter(config.from)
|
143
|
+
end
|
144
|
+
|
97
145
|
return config.cleanup if command == 'cleanup'
|
98
146
|
# return show if command == 'show'
|
99
147
|
return sample if command == 'sample'
|
100
|
-
return punchline
|
148
|
+
return punchline
|
101
149
|
end
|
102
150
|
|
103
151
|
private
|
@@ -115,7 +163,26 @@ module Kukushka
|
|
115
163
|
# end
|
116
164
|
|
117
165
|
def sample
|
118
|
-
|
166
|
+
if config.counter
|
167
|
+
config.set_counter(config.counter + 1)
|
168
|
+
config.set_counter(0) if config.counter > lines.size
|
169
|
+
|
170
|
+
if config.counter < config.from
|
171
|
+
config.set_counter(config.from)
|
172
|
+
end
|
173
|
+
|
174
|
+
if config.counter >= config.from + config.circle - 1
|
175
|
+
config.set_counter(config.from)
|
176
|
+
end
|
177
|
+
|
178
|
+
return "#{config.counter}. #{lines[config.counter]}"
|
179
|
+
end
|
180
|
+
|
181
|
+
lines.sample
|
182
|
+
end
|
183
|
+
|
184
|
+
def lines
|
185
|
+
@lines ||= File.readlines(config.source, chomp: true)
|
119
186
|
end
|
120
187
|
|
121
188
|
def punchline
|
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.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serge Kislak
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
42
|
- exe/kuku
|
43
|
+
- kukushka-0.1.4.gem
|
43
44
|
- lib/kukushka.rb
|
44
45
|
- lib/kukushka/version.rb
|
45
46
|
- sig/kukushka.rbs
|