kukushka 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66d264251fe933fa94b41f2a5d03dfdfd8b6399ff50bc935f749a684c2358035
4
- data.tar.gz: 94ee6283f8c806ed6409aaeffd500596639253fa150f5eee50987c1c15fa2681
3
+ metadata.gz: 30a1613964deb7120d6663f0cc0dbfca664640b68de9511012e5f0bdcc13e9ff
4
+ data.tar.gz: d37e3e7eefda5dcbf082bf011d0ea68775127e74516d9525516fcac23455ea30
5
5
  SHA512:
6
- metadata.gz: 247002d1bbbbfc1b47d1d780b1725c617f925d419fb0c2137ecf63ff461d7a3f9bf617ce968616dc1a3a3098c77c9fb7b938bc917d97233d351a37a2a66c7a5c
7
- data.tar.gz: d977be1460bc41f5cf0fd80de3e55847dcea4975a6abe49cedd800d0d5f36c85af19c3361356c264bfde4e1025f5dc7aed62997a01ed1c5ead603fe03abf47fb
6
+ metadata.gz: a8454edb8c7e97df51c7ce9c88d6ded8bf5d2f6c8bdb6421e012b04dc3e2a6014d13712ea128c5c52cbadeb3b08b2452f2f085b52cfd45e1a39a4254d0cd2d03
7
+ data.tar.gz: fdd2c8014bcee1ee4889ee762a8e9775d9d1bd1b5471bdc006a3bb49362b9e2343c61416a48674c9ee58f6a989366ac5af9dd35e883f08d8204a6a33a2f49c8e
data/Gemfile CHANGED
@@ -6,7 +6,8 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
-
10
9
  gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
10
+ gem 'rainbow', '~> 3.0'
11
+ gem 'rubocop'
12
+ gem 'reek'
13
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kukushka (0.1.1)
5
+ rainbow (~> 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.3)
11
+ diff-lcs (1.2.5)
12
+ method_source (1.1.0)
13
+ pry (0.15.0)
14
+ coderay (~> 1.1)
15
+ method_source (~> 1.0)
16
+ racc (1.8.1)
17
+ rainbow (3.1.1)
18
+ rake (13.2.1)
19
+ reek (1.3.7)
20
+ rainbow
21
+ ruby2ruby (~> 2.0.8)
22
+ ruby_parser (~> 3.3)
23
+ sexp_processor
24
+ rspec (3.13.0)
25
+ rspec-core (~> 3.13.0)
26
+ rspec-expectations (~> 3.13.0)
27
+ rspec-mocks (~> 3.13.0)
28
+ rspec-core (3.13.2)
29
+ rspec-support (~> 3.13.0)
30
+ rspec-expectations (3.13.3)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.13.0)
33
+ rspec-mocks (3.13.2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-support (3.13.2)
37
+ rubocop (0.7.2)
38
+ rainbow (>= 1.1.4)
39
+ ruby2ruby (2.0.8)
40
+ ruby_parser (~> 3.1)
41
+ sexp_processor (~> 4.0)
42
+ ruby_parser (3.21.1)
43
+ racc (~> 1.5)
44
+ sexp_processor (~> 4.16)
45
+ sexp_processor (4.17.3)
46
+
47
+ PLATFORMS
48
+ arm64-darwin-22
49
+
50
+ DEPENDENCIES
51
+ kukushka!
52
+ pry
53
+ rainbow (~> 3.0)
54
+ rake (~> 13.0)
55
+ reek
56
+ rspec (~> 3.0)
57
+ rubocop
58
+
59
+ BUNDLED WITH
60
+ 2.3.26
data/exe/kuku CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'yaml'
2
3
  require 'kukushka'
3
- puts Kukushka.kuku
4
+
5
+ puts Kukushka.kuku(ARGV)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kukushka
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/kukushka.rb CHANGED
@@ -1,11 +1,93 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require_relative "kukushka/version"
3
+ require 'fileutils'
4
+ require 'rainbow'
5
+ require 'yaml'
4
6
 
5
7
  module Kukushka
6
- class Error < StandardError; end
8
+ CONFIG_FILE = File.dirname(__FILE__) + '/../tmp/config/kuku.yaml'
9
+ CONFIG_DIR = File.dirname(CONFIG_FILE)
10
+ INIT_CTA = "TODO: kuku init source_file"
11
+ PROVIDE_SOURCE_CTA = "TODO: provide valid source_file path"
12
+
13
+ def self.kuku(args)
14
+ Kukushka.kuku(args)
15
+ end
16
+
17
+ class Kukushka
18
+ def self.kuku(args)
19
+ new(args).kuku
20
+ end
21
+
22
+ def initialize(args)
23
+ @command = args[0]
24
+ @param1 = args[1]
25
+ end
26
+
27
+ attr_reader :command, :param1
28
+
29
+ def kuku
30
+ init if command == 'init'
31
+
32
+ return INIT_CTA unless config_exists?
33
+
34
+ return config if command == 'config'
35
+ return cleanup if command == 'cleanup'
36
+ return sample if command == 'sample'
37
+ return punchline if command.nil?
38
+ end
39
+
40
+ private
41
+ def init
42
+ source_file = param1
43
+
44
+ return INIT_CTA if source_file.nil?
45
+
46
+ return PROVIDE_SOURCE_CTA unless File.exist?(source_file)
47
+
48
+ dir = File.dirname(CONFIG_FILE)
49
+ FileUtils.mkdir_p(dir) unless File.exists?(dir)
50
+ config = { source: source_file }
51
+ File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
52
+ end
53
+
54
+ def config
55
+ @config ||= YAML::load_file(CONFIG_FILE)
56
+ end
57
+
58
+ def cleanup
59
+ FileUtils.rm_rf(CONFIG_DIR) if config_exists?
60
+ end
61
+
62
+ def config_exists?
63
+ File.exists?(CONFIG_DIR)
64
+ end
65
+
66
+ # if ARGV[0] == 'config'
67
+ # # source
68
+ # # range_number
69
+ # # range_size
70
+ # # annoying_factor
71
+ # # with feedback_loop
72
+ # # statistics
73
+ # end
74
+ #
75
+ # if ARGV[0] == 'statistics'
76
+ # end
77
+
78
+ def punchline
79
+ @punchline ||= Rainbow(sample).color(color).bright
80
+ end
81
+
82
+ def source
83
+ @source ||= YAML::load_file(CONFIG_FILE)[:source]
84
+ end
85
+ def color
86
+ @color ||= Rainbow::X11ColorNames::NAMES.keys.sample
87
+ end
7
88
 
8
- def self.kuku
9
- "Hello from Kukushka!"
89
+ def sample
90
+ @sample ||= File.readlines(source, chomp: true).sample
91
+ end
10
92
  end
11
93
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kukushka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serge Kislak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rainbow
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  description: Learning tool for interval repetition
14
28
  email:
15
29
  - kislak7@gmail.com
@@ -21,11 +35,11 @@ files:
21
35
  - ".rspec"
22
36
  - ".rubocop.yml"
23
37
  - Gemfile
38
+ - Gemfile.lock
24
39
  - LICENSE.txt
25
40
  - README.md
26
41
  - Rakefile
27
42
  - exe/kuku
28
- - kukushka-0.1.0.gem
29
43
  - lib/kukushka.rb
30
44
  - lib/kukushka/version.rb
31
45
  - sig/kukushka.rbs
data/kukushka-0.1.0.gem DELETED
Binary file