kukushka 0.1.5 → 0.1.8
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile.lock +77 -16
- data/README.md +10 -1
- data/exe/kuku +57 -6
- data/lib/kukushka/version.rb +1 -1
- data/lib/kukushka.rb +45 -142
- metadata +47 -4
- data/kukushka-0.1.4.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92ab7d9dc8513ea956f2e2f4a0351fc568deeee3f372cc0d888b56e1eb8fb0f6
|
4
|
+
data.tar.gz: b2cae314f91fdbd8af055b6377632188e7591ceb7f8c5941c7d7201b7687c4bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab7efa3e67b77a343a702d0adcfab9449bfc4ed8823f0e1f9883b22ea11e78266bfb15e0a683e8ce2873ba72a78328ee4ff5efe1f3fc2a0b61889376cdb94877
|
7
|
+
data.tar.gz: 6a2fd3c7fce07d40a054ad89b0e9a9ed17390d028110ecb2f85cf0224d6206d362de8acf05822aa206eff0556123ce84a77bfe6601283b2fe3179cf40342fb59
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
kukushka
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.4
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,79 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kukushka (0.1.
|
4
|
+
kukushka (0.1.8)
|
5
|
+
commander (~> 4.4)
|
5
6
|
rainbow (~> 3.0)
|
7
|
+
redis (~> 5.3)
|
8
|
+
redis-namespace (~> 1.11)
|
6
9
|
|
7
10
|
GEM
|
8
11
|
remote: https://rubygems.org/
|
9
12
|
specs:
|
13
|
+
ast (2.4.2)
|
14
|
+
bigdecimal (3.1.8)
|
10
15
|
coderay (1.1.3)
|
11
|
-
|
16
|
+
commander (4.6.0)
|
17
|
+
highline (~> 2.0.0)
|
18
|
+
concurrent-ruby (1.3.4)
|
19
|
+
connection_pool (2.4.1)
|
20
|
+
diff-lcs (1.5.1)
|
21
|
+
dry-configurable (1.2.0)
|
22
|
+
dry-core (~> 1.0, < 2)
|
23
|
+
zeitwerk (~> 2.6)
|
24
|
+
dry-core (1.0.2)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
logger
|
27
|
+
zeitwerk (~> 2.6)
|
28
|
+
dry-inflector (1.1.0)
|
29
|
+
dry-initializer (3.1.1)
|
30
|
+
dry-logic (1.5.0)
|
31
|
+
concurrent-ruby (~> 1.0)
|
32
|
+
dry-core (~> 1.0, < 2)
|
33
|
+
zeitwerk (~> 2.6)
|
34
|
+
dry-schema (1.13.4)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
dry-configurable (~> 1.0, >= 1.0.1)
|
37
|
+
dry-core (~> 1.0, < 2)
|
38
|
+
dry-initializer (~> 3.0)
|
39
|
+
dry-logic (>= 1.4, < 2)
|
40
|
+
dry-types (>= 1.7, < 2)
|
41
|
+
zeitwerk (~> 2.6)
|
42
|
+
dry-types (1.7.2)
|
43
|
+
bigdecimal (~> 3.0)
|
44
|
+
concurrent-ruby (~> 1.0)
|
45
|
+
dry-core (~> 1.0)
|
46
|
+
dry-inflector (~> 1.0)
|
47
|
+
dry-logic (~> 1.4)
|
48
|
+
zeitwerk (~> 2.6)
|
49
|
+
highline (2.0.3)
|
50
|
+
json (2.9.0)
|
51
|
+
language_server-protocol (3.17.0.3)
|
52
|
+
logger (1.6.3)
|
12
53
|
method_source (1.1.0)
|
54
|
+
parallel (1.26.3)
|
55
|
+
parser (3.3.6.0)
|
56
|
+
ast (~> 2.4.1)
|
57
|
+
racc
|
13
58
|
pry (0.15.0)
|
14
59
|
coderay (~> 1.1)
|
15
60
|
method_source (~> 1.0)
|
16
61
|
racc (1.8.1)
|
17
62
|
rainbow (3.1.1)
|
18
63
|
rake (13.2.1)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
64
|
+
redis (5.3.0)
|
65
|
+
redis-client (>= 0.22.0)
|
66
|
+
redis-client (0.23.0)
|
67
|
+
connection_pool
|
68
|
+
redis-namespace (1.11.0)
|
69
|
+
redis (>= 4)
|
70
|
+
reek (6.3.0)
|
71
|
+
dry-schema (~> 1.13.0)
|
72
|
+
parser (~> 3.3.0)
|
73
|
+
rainbow (>= 2.0, < 4.0)
|
74
|
+
rexml (~> 3.1)
|
75
|
+
regexp_parser (2.9.3)
|
76
|
+
rexml (3.3.9)
|
24
77
|
rspec (3.13.0)
|
25
78
|
rspec-core (~> 3.13.0)
|
26
79
|
rspec-expectations (~> 3.13.0)
|
@@ -34,15 +87,23 @@ GEM
|
|
34
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
88
|
rspec-support (~> 3.13.0)
|
36
89
|
rspec-support (3.13.2)
|
37
|
-
rubocop (
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
90
|
+
rubocop (1.69.2)
|
91
|
+
json (~> 2.3)
|
92
|
+
language_server-protocol (>= 3.17.0)
|
93
|
+
parallel (~> 1.10)
|
94
|
+
parser (>= 3.3.0.2)
|
95
|
+
rainbow (>= 2.2.2, < 4.0)
|
96
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
97
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
98
|
+
ruby-progressbar (~> 1.7)
|
99
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
100
|
+
rubocop-ast (1.37.0)
|
101
|
+
parser (>= 3.3.1.0)
|
102
|
+
ruby-progressbar (1.13.0)
|
103
|
+
unicode-display_width (3.1.2)
|
104
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
105
|
+
unicode-emoji (4.0.4)
|
106
|
+
zeitwerk (2.6.18)
|
46
107
|
|
47
108
|
PLATFORMS
|
48
109
|
arm64-darwin-22
|
data/README.md
CHANGED
@@ -45,4 +45,13 @@ bundle init
|
|
45
45
|
|
46
46
|
gem 'pry'
|
47
47
|
gem 'kukushka', path: '/Users/Siarhei/laboratory/kukushka'
|
48
|
-
```
|
48
|
+
```
|
49
|
+
|
50
|
+
```bash
|
51
|
+
gem build kukushka.gemspec
|
52
|
+
gem push kukushka-0.x.y.gem
|
53
|
+
```
|
54
|
+
|
55
|
+
dependencies
|
56
|
+
https://github.com/redis/redis-rb
|
57
|
+
https://github.com/commander-rb/commander
|
data/exe/kuku
CHANGED
@@ -2,12 +2,63 @@
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'kukushka'
|
4
4
|
require 'pry'
|
5
|
+
require 'commander'
|
6
|
+
require 'redis'
|
7
|
+
require 'redis-namespace'
|
8
|
+
require 'json'
|
5
9
|
|
6
|
-
if ARGV.join('') == 'on'
|
7
|
-
Kukushka.on!
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
+
redis_connection = Redis.new
|
12
|
+
redis = Redis::Namespace.new(:kukushka, redis: redis_connection)
|
13
|
+
|
14
|
+
Commander.configure do
|
15
|
+
program :name, 'kuku'
|
16
|
+
program :version, '1.0.0'
|
17
|
+
program :description, 'learn list'
|
18
|
+
default_command :sample
|
19
|
+
|
20
|
+
command :sample do |c|
|
21
|
+
c.syntax = 'kuku sample'
|
22
|
+
c.description = 'Show next sample'
|
23
|
+
c.action do |args, options|
|
24
|
+
next unless redis.get('enabled') == 'true'
|
25
|
+
|
26
|
+
res = Kukushka.kuku(redis)
|
27
|
+
puts res if res
|
28
|
+
end
|
29
|
+
end
|
11
30
|
|
12
|
-
|
13
|
-
|
31
|
+
command :init do |c|
|
32
|
+
c.syntax = 'kuku init'
|
33
|
+
c.description = 'Default initiation'
|
34
|
+
c.action do |args, options|
|
35
|
+
# res = Kukushka.kuku(ARGV)
|
36
|
+
# puts res if res
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
command :source do |c|
|
41
|
+
c.syntax = 'kuku source file_path'
|
42
|
+
c.description = 'Add new source'
|
43
|
+
c.action do |args, options|
|
44
|
+
lines = File.readlines(args.first, chomp: true)
|
45
|
+
redis.set(:lines, lines.to_json)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
command :on do |c|
|
50
|
+
c.syntax = 'kuku on'
|
51
|
+
c.description = 'Disable'
|
52
|
+
c.action do |args, options|
|
53
|
+
redis.set('enabled', true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
command :off do |c|
|
58
|
+
c.syntax = 'kuku off'
|
59
|
+
c.description = 'disable'
|
60
|
+
c.action do |args, options|
|
61
|
+
redis.set('enabled', false)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/kukushka/version.rb
CHANGED
data/lib/kukushka.rb
CHANGED
@@ -5,147 +5,26 @@ require 'rainbow'
|
|
5
5
|
require 'yaml'
|
6
6
|
|
7
7
|
module Kukushka
|
8
|
-
|
9
|
-
|
10
|
-
DEFAULT_CIRCLE = 5
|
8
|
+
EXAMPLE_SOURCE ||= File.dirname(__FILE__) + '/../spec/fixtures/pl_001.txt'
|
9
|
+
DEFULAT_LINES = File.readlines(EXAMPLE_SOURCE, chomp: true)
|
11
10
|
|
12
|
-
def self.kuku(
|
13
|
-
Kukushka.kuku(
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.on?
|
17
|
-
Config.new.on?
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.on!
|
21
|
-
Config.new.enable
|
22
|
-
end
|
23
|
-
|
24
|
-
class Config
|
25
|
-
CONFIG_FILE = File.dirname(__FILE__) + '/../tmp/config/kuku.yaml'
|
26
|
-
CONFIG_DIR = File.dirname(CONFIG_FILE)
|
27
|
-
|
28
|
-
def on?
|
29
|
-
return true unless exists?
|
30
|
-
exists? && config[:enabled]
|
31
|
-
end
|
32
|
-
|
33
|
-
def exists?
|
34
|
-
File.exists?(CONFIG_DIR)
|
35
|
-
end
|
36
|
-
|
37
|
-
def init(source_file)
|
38
|
-
source_file ||= File.dirname(__FILE__) + '/../spec/fixtures/pl_001.txt'
|
39
|
-
return INIT_CTA if source_file.nil?
|
40
|
-
return PROVIDE_SOURCE_CTA unless File.exist?(source_file)
|
41
|
-
|
42
|
-
dir = File.dirname(CONFIG_FILE)
|
43
|
-
FileUtils.mkdir_p(dir) unless File.exists?(dir)
|
44
|
-
config = {
|
45
|
-
source: source_file,
|
46
|
-
enabled: true,
|
47
|
-
counter: 0,
|
48
|
-
from: 0,
|
49
|
-
circle: DEFAULT_CIRCLE,
|
50
|
-
}
|
51
|
-
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
52
|
-
end
|
53
|
-
|
54
|
-
def enable
|
55
|
-
config.merge!(enabled: true)
|
56
|
-
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
57
|
-
'enabled'
|
58
|
-
end
|
59
|
-
|
60
|
-
def disable
|
61
|
-
config.merge!(enabled: false)
|
62
|
-
File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
|
63
|
-
'disabled'
|
64
|
-
end
|
65
|
-
|
66
|
-
def cleanup
|
67
|
-
FileUtils.rm_rf(CONFIG_DIR) if config_exists?
|
68
|
-
end
|
69
|
-
|
70
|
-
def 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 }
|
99
|
-
end
|
100
|
-
|
101
|
-
def config
|
102
|
-
@config ||= YAML::load_file(CONFIG_FILE)
|
103
|
-
end
|
11
|
+
def self.kuku(redis)
|
12
|
+
Kukushka.kuku(redis)
|
104
13
|
end
|
105
14
|
|
106
15
|
class Kukushka
|
107
|
-
def self.kuku(
|
108
|
-
new(
|
16
|
+
def self.kuku(redis)
|
17
|
+
new(redis).kuku
|
109
18
|
end
|
110
19
|
|
111
|
-
def initialize(
|
112
|
-
@
|
113
|
-
@param1 = args[1]
|
114
|
-
@config = Config.new
|
20
|
+
def initialize(redis)
|
21
|
+
@redis = redis
|
115
22
|
end
|
116
23
|
|
117
|
-
attr_reader :
|
24
|
+
attr_reader :redis
|
118
25
|
|
119
26
|
def kuku
|
120
|
-
|
121
|
-
|
122
|
-
return INIT_CTA unless config.exists?
|
123
|
-
|
124
|
-
return config.enable if command == 'on'
|
125
|
-
return config.disable if command == 'off'
|
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
|
-
|
145
|
-
return config.cleanup if command == 'cleanup'
|
146
|
-
# return show if command == 'show'
|
147
|
-
return sample if command == 'sample'
|
148
|
-
return punchline
|
27
|
+
Rainbow(sample).color(color).bright
|
149
28
|
end
|
150
29
|
|
151
30
|
private
|
@@ -163,30 +42,54 @@ module Kukushka
|
|
163
42
|
# end
|
164
43
|
|
165
44
|
def sample
|
166
|
-
if
|
167
|
-
|
168
|
-
|
45
|
+
if counter
|
46
|
+
set_counter(counter + 1)
|
47
|
+
set_counter(0) if counter > lines.size
|
169
48
|
|
170
|
-
if
|
171
|
-
|
49
|
+
if counter < from
|
50
|
+
set_counter(from)
|
172
51
|
end
|
173
52
|
|
174
|
-
if
|
175
|
-
|
53
|
+
if counter > to
|
54
|
+
set_counter(from)
|
176
55
|
end
|
177
56
|
|
178
|
-
return "#{
|
57
|
+
return "#{lines[counter]} #{counter} [#{from}-#{to}/#{lines.size - 1}]"
|
179
58
|
end
|
180
59
|
|
181
60
|
lines.sample
|
182
61
|
end
|
183
62
|
|
63
|
+
def counter
|
64
|
+
@counter ||= redis.get(:counter).to_i
|
65
|
+
end
|
66
|
+
|
67
|
+
def to
|
68
|
+
@to ||= from + circle - 1
|
69
|
+
end
|
70
|
+
|
71
|
+
def set_counter(new_counter)
|
72
|
+
redis.set(:counter, new_counter)
|
73
|
+
@counter = new_counter
|
74
|
+
end
|
75
|
+
|
184
76
|
def lines
|
185
|
-
|
77
|
+
# binding.pry
|
78
|
+
redis_lines = redis.get(:lines)
|
79
|
+
if redis_lines
|
80
|
+
@lines = JSON.parse(redis.get(:lines))
|
81
|
+
end
|
82
|
+
@lines ||= DEFULAT_LINES
|
186
83
|
end
|
187
84
|
|
188
|
-
def
|
189
|
-
@
|
85
|
+
def from
|
86
|
+
@from ||= redis.get(:from).to_i
|
87
|
+
end
|
88
|
+
|
89
|
+
def circle
|
90
|
+
@circle ||= redis.get(:circle).to_i
|
91
|
+
@circle = lines.size if @circle == 0
|
92
|
+
@circle
|
190
93
|
end
|
191
94
|
|
192
95
|
def color
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serge Kislak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -24,6 +24,48 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: commander
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redis
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: redis-namespace
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
27
69
|
description: Learning tool for interval repetition
|
28
70
|
email:
|
29
71
|
- kislak7@gmail.com
|
@@ -34,13 +76,14 @@ extra_rdoc_files: []
|
|
34
76
|
files:
|
35
77
|
- ".rspec"
|
36
78
|
- ".rubocop.yml"
|
79
|
+
- ".ruby-gemset"
|
80
|
+
- ".ruby-version"
|
37
81
|
- Gemfile
|
38
82
|
- Gemfile.lock
|
39
83
|
- LICENSE.txt
|
40
84
|
- README.md
|
41
85
|
- Rakefile
|
42
86
|
- exe/kuku
|
43
|
-
- kukushka-0.1.4.gem
|
44
87
|
- lib/kukushka.rb
|
45
88
|
- lib/kukushka/version.rb
|
46
89
|
- sig/kukushka.rbs
|
@@ -63,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
106
|
- !ruby/object:Gem::Version
|
64
107
|
version: '0'
|
65
108
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.5.11
|
67
110
|
signing_key:
|
68
111
|
specification_version: 4
|
69
112
|
summary: interval repetition
|
data/kukushka-0.1.4.gem
DELETED
Binary file
|