rubiks-cli 1.4.0 → 1.4.3
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/README.md +10 -9
- data/bin/rubiks +12 -6
- data/lib/rubiks_cli/loop/engine.rb +2 -14
- data/lib/rubiks_cli/version.rb +1 -1
- 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: 1f9ab82b63263d5febf97737189ced411fcbe595f86b026a6958e06d2686181c
|
|
4
|
+
data.tar.gz: cc757c2d7ef1c4d357412d9df39b51b434b3ac1ae5869e4097e48486b5b25e19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87e01d0d4866e8200b81ad89daddf084bd8c629282b7acf517feaa08cf1045919587a66d2f4e7eae20c0bb8da155dc7c51440a0a34fea7b383235b1b77ff66a7
|
|
7
|
+
data.tar.gz: a8627c4c8ba178fed6340105404446d432d1cda295a96fc15d586ba4274a4cc337899b209258af77220a3173f7065070a1ba9001ec98648f1a568a7df37c7daf
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rubiks CLI
|
|
2
2
|
|
|
3
|
-
A command-line Rubik's Cube timer
|
|
3
|
+
A command-line Rubik's Cube timer
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -10,12 +10,13 @@ gem install rubiks-cli
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
```bash
|
|
14
|
-
rubiks
|
|
15
13
|
```
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
14
|
+
rubiks [options]
|
|
15
|
+
-c, --clear Clear the screen before starting
|
|
16
|
+
-i, --inspection Include inspection time
|
|
17
|
+
-l, --loop Loop forever
|
|
18
|
+
-s, --scramble Generate scramble
|
|
19
|
+
-t, --time Start timer
|
|
20
|
+
-h, --help Show this help message
|
|
21
|
+
```
|
|
22
|
+
Defaults: `--scramble, --time`
|
data/bin/rubiks
CHANGED
|
@@ -27,6 +27,15 @@ OptionParser.new do |opts|
|
|
|
27
27
|
options[:time] = true
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# opts.on("-o", "--overwrite", "Overwrite loop output") do
|
|
31
|
+
# options[:time] = true
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
opts.on("-h", "--help", "Show this help message") do
|
|
35
|
+
puts opts
|
|
36
|
+
puts "\nDefaults: --scramble, --time"
|
|
37
|
+
exit
|
|
38
|
+
end
|
|
30
39
|
end.parse!
|
|
31
40
|
|
|
32
41
|
if options.values.none?
|
|
@@ -46,23 +55,20 @@ start_timer_then_output_scramble = lambda {
|
|
|
46
55
|
if options[:loop]
|
|
47
56
|
|
|
48
57
|
if options[:time] && options[:scramble]
|
|
49
|
-
RubiksCli::Clear.screen
|
|
50
58
|
RubiksCli::Loop.build(
|
|
51
|
-
|
|
59
|
+
start_timer_then_output_scramble,
|
|
52
60
|
[ RubiksCli::Loop.create_action('n', output_scramble, "generate new scramble"), ]
|
|
53
61
|
).start
|
|
54
62
|
|
|
55
63
|
elsif options[:scramble]
|
|
56
|
-
RubiksCli::Clear.screen
|
|
57
64
|
RubiksCli::Loop.build(
|
|
58
|
-
|
|
65
|
+
output_scramble,
|
|
59
66
|
[ RubiksCli::Loop.create_action('t', start_timer_then_output_scramble, "start timer"), ]
|
|
60
67
|
).start
|
|
61
68
|
|
|
62
69
|
elsif options[:time]
|
|
63
|
-
RubiksCli::Clear.screen
|
|
64
70
|
RubiksCli::Loop.build(
|
|
65
|
-
|
|
71
|
+
start_timer,
|
|
66
72
|
[ RubiksCli::Loop.create_action('n', output_scramble, "generate a scramble"), ]
|
|
67
73
|
).start
|
|
68
74
|
|
|
@@ -5,13 +5,13 @@ module RubiksCli
|
|
|
5
5
|
class Engine
|
|
6
6
|
private_class_method :new
|
|
7
7
|
|
|
8
|
-
def initialize(
|
|
8
|
+
def initialize(on_enter, other_actions)
|
|
9
9
|
commands = other_actions.map { |action| action.command }
|
|
10
10
|
if commands.uniq.size != commands.size
|
|
11
11
|
raise ArgumentError, "Duplicate command"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
@actions = Hash.new(
|
|
14
|
+
@actions = Hash.new(on_enter)
|
|
15
15
|
other_actions.each { |action| @actions[action.command] = action.function }
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -26,15 +26,3 @@ module RubiksCli
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
-
|
|
30
|
-
if __FILE__ == $0
|
|
31
|
-
require_relative 'builder'
|
|
32
|
-
|
|
33
|
-
on_enter = lambda { puts "You pressed Enter!" }
|
|
34
|
-
actions = [
|
|
35
|
-
RubiksCli::Loop.build_action('x', -> { puts "Action X executed" }, "execute action X"),
|
|
36
|
-
RubiksCli::Loop.build_action('y', -> { puts "Action Y executed" }, "execute action Y"),
|
|
37
|
-
]
|
|
38
|
-
loop_instance = RubiksCli::Loop.build_loop(on_enter, actions)
|
|
39
|
-
loop_instance.start
|
|
40
|
-
end
|
data/lib/rubiks_cli/version.rb
CHANGED