rubiks-cli 1.4.1 → 1.4.4

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: 7f41af5a9687e0f977719e8e7caf798d8de975ad9c601df389bc8224a3b48d29
4
- data.tar.gz: 8bafea416886b9f1d4025f327e6120e159af25ffd333fef53426ec7bc2c5ac4f
3
+ metadata.gz: 0ceaacd6955da01007e67211b267f1ba59c18a9dfb0f4dbd1de7e3605094970c
4
+ data.tar.gz: 77475704b630f2b0a4b4fb46e22fc886a448c2b7f69688b272aee3f8f88a9dd7
5
5
  SHA512:
6
- metadata.gz: bca1184b5817581fff9d9d0f38b1b0409f6f46bc9f81d91b286d2ada09ed4d0cf6e06cb5ec174fd4a8c73f1ec00a335a9c92c176570a8a0e682043e13877cc12
7
- data.tar.gz: 7a741690d3d96c8878fc03d341b5b63855761ec34c0e127fb1c81bd4c22c1263ea515811834e5bea0816d9714bb74282201fad5a04ca86470a6fa488665748b8
6
+ metadata.gz: bf1164df262f77e08377a2959b73b0e0d160bb25c72dc1f5e15f522a89a1e310f57268d5cd0bbcb8a5798a190a4be468a804bc131faa992c6ebd35d2820ec8d3
7
+ data.tar.gz: 5157e6e885f6f293a21e37426e7ee8e110859c6897aac8fbb35b8bb18918ecfa5c0c3913e07bfbe9727288e21a03ea14470f36c088cbcc0dbeff081933e7a45c
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
- - Press Enter to start timing
18
- - Press any key to stop timing
19
- - Type 'n' for a new scramble
20
- - Type 'q' to quit
21
- - Type 'h' or '?' for help (this message)
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,18 @@ 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
+ opts.on("-v", "--version", "Print version") do
34
+ puts "rubiks-cli #{RubiksCli::VERSION}"
35
+ exit
36
+ end
37
+ opts.on("-h", "--help", "Show this help message") do
38
+ puts opts
39
+ puts "\nDefaults: --scramble, --time"
40
+ exit
41
+ end
30
42
  end.parse!
31
43
 
32
44
  if options.values.none?
@@ -47,19 +59,19 @@ if options[:loop]
47
59
 
48
60
  if options[:time] && options[:scramble]
49
61
  RubiksCli::Loop.build(
50
- RubiksCli::Loop.create_action('', start_timer_then_output_scramble, "start solve"),
62
+ start_timer_then_output_scramble,
51
63
  [ RubiksCli::Loop.create_action('n', output_scramble, "generate new scramble"), ]
52
64
  ).start
53
65
 
54
66
  elsif options[:scramble]
55
67
  RubiksCli::Loop.build(
56
- RubiksCli::Loop.create_action('', output_scramble, "generate a scramble"),
68
+ output_scramble,
57
69
  [ RubiksCli::Loop.create_action('t', start_timer_then_output_scramble, "start timer"), ]
58
70
  ).start
59
71
 
60
72
  elsif options[:time]
61
73
  RubiksCli::Loop.build(
62
- RubiksCli::Loop.create_action('', start_timer, "start timer"),
74
+ start_timer,
63
75
  [ RubiksCli::Loop.create_action('n', output_scramble, "generate a scramble"), ]
64
76
  ).start
65
77
 
@@ -5,13 +5,13 @@ module RubiksCli
5
5
  class Engine
6
6
  private_class_method :new
7
7
 
8
- def initialize(action_on_enter, other_actions)
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(action_on_enter.function)
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
@@ -3,7 +3,7 @@ require_relative 'clear'
3
3
 
4
4
  module RubiksCli
5
5
  module Timer
6
- INSPECTION_TIME = 15
6
+ INSPECTION_TIME = 5
7
7
 
8
8
  def self.start(inspection)
9
9
  if inspection
@@ -34,12 +34,14 @@ module RubiksCli
34
34
  return if STDIN.wait_readable(1)
35
35
  end
36
36
 
37
- print "\r+2"
37
+ Clear.current_line
38
+ print "+2"
38
39
  2.times do
39
40
  return if STDIN.wait_readable(1)
40
41
  end
41
42
 
42
- print "\rDNF"
43
+ Clear.current_line
44
+ print "DNF"
43
45
  ensure
44
46
  STDIN.getch rescue nil
45
47
  end
@@ -1,3 +1,3 @@
1
1
  module RubiksCli
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubiks-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Scott