freshmind 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a7e7cae6496631e5812ceda01ef77a8916eb15e0ebc4960cf00025cbdbe498a9
4
+ data.tar.gz: fe5ce693f8c2fd2f478ce9f1daf4570da8748fad0b288b0b3ccd149505f73a36
5
+ SHA512:
6
+ metadata.gz: 0b086c16f6f4a4b824626e15f21ec05d65cac3177ba2d664053355a8d017dd2cde549922a8a5478bdd91fd38dabe76479e0f8db31a0431c5f2d7d396cb248f8b
7
+ data.tar.gz: ba287694dc3d2bdea6dba587ebabcc68605b2e6e689c9cb1b24884a5ad481069e8cc5b2afe9028e53a0029d284bdaa3cf9adf87ba44add3eaa6511a123988528
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Alfabet
2
+ Generate alfabet letters along with commands in terminal to refresh your mind.
3
+
4
+ # Instructions:
5
+ Read out lod letters and do commands in the same time.
6
+ Commnads:
7
+ о - lift up both hands and rise a bit on toes of feet
8
+ п - lift RIGHT hand and LEFT lift leg a bit
9
+ л - lift LEFT hand and lift RIGHT leg a bit
10
+
11
+ # Usage
12
+ ```
13
+ > bundle install
14
+ or
15
+ > gem install freshmind
16
+ ...
17
+ > freshmind
18
+ ```
19
+
20
+ Output will be like this with small red letters.
21
+ ```
22
+ ┌────────────────┐
23
+ │ Ar Br Cl Dr El │
24
+ │ Fl Hl Hl Ib Jr │
25
+ │ Kr Lb Ml Nr Ol │
26
+ │ Pb Ql Rl Sr Tl │
27
+ │ Ul Vb Wl Zl Yr │
28
+ │ Zr Ab Bl Cl Dl │
29
+ └────────────────┘
30
+ ```
data/bin/freshmind ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/freshmind'
data/lib/freshmind.rb ADDED
@@ -0,0 +1,99 @@
1
+ require "colorize"
2
+ require_relative 'freshmind/alfabet'
3
+
4
+ class Command
5
+ attr_reader :lang
6
+ def initialize(lang=:en)
7
+ @lang = lang
8
+ end
9
+
10
+ def list
11
+ (commands*100).split("").sample(300)
12
+ end
13
+
14
+ def commands
15
+ return "оплопл" if lang == :ru
16
+ return "brlbrl" if lang == :en
17
+ end
18
+ end
19
+
20
+ class Options
21
+ attr_reader :options, :argv
22
+ def initialize( argv, options={})
23
+ @argv = argv
24
+ @options = options
25
+ end
26
+
27
+ def args
28
+ res = {}
29
+ options.each do |opt_key, opt_value|
30
+ opt_value[:variants].each do |variant|
31
+ arg_index = argv.index(variant.to_s)
32
+ res[opt_key] = arg_index.nil? ? opt_value[:default] : argv[arg_index].to_sym
33
+ end
34
+ end
35
+ res
36
+ end
37
+ end
38
+
39
+ class Main
40
+ attr_reader :row_size, :commands, :alfabet
41
+ LEFT_UP_CORNER = "\u250c"
42
+ RIGHT_UP_CORNER = "\u2510"
43
+ LEFT_DOWN_CORNER = "\u2514"
44
+ RIGHT_DOWN_CORNER = "\u2518"
45
+ VERTICAL_BORDER = "\u2502"
46
+ HORIZONTAL_BORDER = "\u2500"
47
+
48
+ def initialize(row_size, commands, alfabet)
49
+ @row_size = row_size
50
+ @commands = commands
51
+ @alfabet = alfabet
52
+ end
53
+
54
+ def result
55
+ alfabet.map do |l|
56
+ l + commands[rand(300)].red
57
+ end
58
+ end
59
+
60
+ def out
61
+ puts top_border
62
+ result.each_slice(row_size) do |row|
63
+ puts VERTICAL_BORDER + " " + row.join(" ") + " " + VERTICAL_BORDER
64
+ end
65
+ puts bottom_border
66
+ end
67
+
68
+ private
69
+
70
+ def line
71
+ HORIZONTAL_BORDER * (row_size * 3 + 1)
72
+ end
73
+
74
+ def top_border
75
+ LEFT_UP_CORNER + line + RIGHT_UP_CORNER
76
+ end
77
+ def bottom_border
78
+ LEFT_DOWN_CORNER + line + RIGHT_DOWN_CORNER
79
+ end
80
+ end
81
+
82
+ options_conf = {
83
+ lang: {
84
+ variants: [:en, :ru],
85
+ default: :en,
86
+ optional: true },
87
+ order: { variants: [:ordered, :random],
88
+ default: :ordered,
89
+ optional: true }
90
+ }
91
+
92
+
93
+ args = Options.new(ARGV, options_conf).args
94
+
95
+ Main.new(
96
+ 5,
97
+ Command.new(args[:lang]).list,
98
+ Alfabet.new(lang: args[:lang], order: args[:order]).list
99
+ ).out
@@ -0,0 +1,18 @@
1
+ class Alfabet
2
+ attr_reader :lang, :order
3
+ LETTERS = {
4
+ ru: ('А'..'Я').to_a,
5
+ en: ('A'..'Z').to_a
6
+ }
7
+
8
+ def initialize(options = {})
9
+ @lang = options.fetch(:lang) { :en }
10
+ @order = options.fetch(:order){ :ordered }
11
+ end
12
+
13
+ def list
14
+ res = (LETTERS[lang] * 2)[0, 40]
15
+ res = res.sample(res.size) if order.to_sym == :random
16
+ res
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Freshmind
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freshmind
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrey Eremeev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple exercises to refresh your mind
14
+ email:
15
+ - andrey.eremeyev@gmail.com
16
+ executables:
17
+ - freshmind
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - bin/freshmind
23
+ - lib/freshmind.rb
24
+ - lib/freshmind/alfabet.rb
25
+ - lib/freshmind/version.rb
26
+ homepage: https://github.com/eremeyev/freshmind
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ allowed_push_host: https://rubygems.org
31
+ homepage_uri: https://github.com/eremeyev/freshmind
32
+ source_code_uri: https://rubygems.org
33
+ changelog_uri: https://rubygems.org
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.6.2
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.0.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Simple exercises to refresh your mind
53
+ test_files: []