tg_fibonacci 1.0.1 → 1.0.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -1
  3. data/bin/tg_fib +54 -9
  4. metadata +73 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5ddeff9624bd5fd287f011faf30de755633d862057c8c45c74e755406506d6a
4
- data.tar.gz: 93bac635428de6de8de339ef7c2664a52ee1bcecd664eec23a586fff1634f3b3
3
+ metadata.gz: fb41fba4e37af5e674e9e738d31395c0239a364c4116e676ecb40fda27fb789c
4
+ data.tar.gz: d3b4034deef721d2d53c54a329d1b1e7b47fa34b178be1099643066a3dcd7751
5
5
  SHA512:
6
- metadata.gz: 6c9926e3d2221261fde13ddb05c4de6db888446ecc5bd4cbe0fc108ea2d838b810871618316ed4a6179648a6e39f6ca2793897a4b7dd5f35f2a18f7cbcac49da
7
- data.tar.gz: 31ad51784f7c88e154273554f1213980f18e87731571f531e39ebfc70a742864cc11bfda88d5478690bf0a1b002f78946092520e0a05f5553462ad504144be0a
6
+ metadata.gz: 64646f89cfee62e5e2b40b468e6df88746e6a363b599258b679d3c8f10af71e90575db454891c1ba88b3345b99152d2756a012d42cde374a273e847fa8b6ce41
7
+ data.tar.gz: d24c9ecb7056a9d8cc257a0e6190d6256fc4b248b01a079512275f807e401757889fcc1915a9817cdabc17ebd598b1c01edb5f1053ad84bcd990f444dc07798b
data/README.md CHANGED
@@ -1 +1,69 @@
1
- # TG Fibonacci
1
+ # TG Fibonacci
2
+
3
+ [![Build Status](https://travis-ci.com/tacoda/tg_fibonacci.svg?branch=master)](https://travis-ci.com/tacoda/tg_fibonacci)
4
+
5
+ ## Problem
6
+
7
+ Enter a number and have the program generate the Fibonacci sequence to that number or to the `n`th number.
8
+
9
+ ## Installation
10
+
11
+ Install using RubyGems.
12
+
13
+ ```sh
14
+ gem install tg_fibonacci
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Provide a `help` argument to get CLI program help.
20
+
21
+ ```sh
22
+ $ tg_fib help
23
+
24
+ tg_fib Compute fibonacci numbers
25
+
26
+ Usage:
27
+ tg_fib help Show this help menu
28
+ tg_fib [number] Compute the fibonacci number
29
+ tg_fib Enter interactive mode
30
+ ```
31
+
32
+ Provide a non-negative integer to compute the fibonacci sequence for that number.
33
+
34
+ ```sh
35
+ $ tg_fib 5
36
+
37
+ fib(5) = 1, 1, 2, 3, 5, 8
38
+ ```
39
+
40
+ Provide no arguments to enter interactive mode.
41
+
42
+ ```sh
43
+ $ tg_fib
44
+
45
+ Please enter a non-negative integer: (h)elp, (q)uit
46
+ > 5
47
+ fib(5) = 1, 1, 2, 3, 5, 8
48
+
49
+ Please enter a non-negative integer: (h)elp, (q)uit
50
+ > 3
51
+ fib(3) = 1, 1, 2, 3
52
+
53
+ > help
54
+ Interactive help:
55
+
56
+ Commands:
57
+ (h)elp Show this help menu
58
+ (q)uit Quit the program
59
+
60
+ Usage:
61
+ Enter a non-negative integer to compute that fibonacci number.
62
+
63
+ Example:
64
+ > 5
65
+ # => fib(5) = 1, 1, 2, 3, 5, 8
66
+
67
+ Please enter a non-negative integer: (h)elp, (q)uit
68
+ > quit
69
+ ```
data/bin/tg_fib CHANGED
@@ -2,21 +2,66 @@
2
2
 
3
3
  require_relative '../lib/fibonacci/fibonacci'
4
4
 
5
- number = ARGV.shift
5
+ def help_cli
6
+ <<-END_OF_STRING
7
+ tg_fib Compute fibonacci numbers
6
8
 
7
- if number
8
- puts Fibonacci::Fibonacci.seq_string(number.to_i)
9
- else
9
+ Usage:
10
+ tg_fib help Show this help menu
11
+ tg_fib [number] Compute the fibonacci number
12
+ tg_fib Enter interactive mode
13
+ END_OF_STRING
14
+ end
15
+
16
+ def help_interactive
17
+ <<-END_OF_STRING
18
+ Interactive help:
19
+
20
+ Commands:
21
+ (h)elp Show this help menu
22
+ (q)uit Quit the program
23
+
24
+ Usage:
25
+ Enter a non-negative integer to compute that fibonacci number.
26
+
27
+ Example:
28
+ > 5
29
+ # => fib(5) = 1, 1, 2, 3, 5, 8
30
+ END_OF_STRING
31
+ end
32
+
33
+ def repl
10
34
  loop do
11
- puts "\nPlease enter your n to get fib(n) ('quit' to exit)"
35
+ puts "\nPlease enter a non-negative integer: (h)elp, (q)uit"
36
+ print "> "
12
37
  command = gets.chomp.downcase
13
38
  case command
14
39
  when /^\d+$/
15
- puts Fibonacci::Fibonacci.seq_string(command.to_i)
16
- when 'quit', 'exit'
40
+ puts run(command)
41
+ when 'h', 'help'
42
+ puts help_interactive
43
+ when 'q', 'quit', 'exit'
17
44
  break
18
45
  else
19
- puts "Please enter a number or 'quit'"
46
+ puts "Please enter a number or a valid command"
20
47
  end
21
48
  end
22
- end
49
+ end
50
+
51
+ def run(number)
52
+ Fibonacci::Fibonacci.seq_string(Integer(number))
53
+ end
54
+
55
+ def start
56
+ argument = ARGV.shift
57
+ case argument
58
+ when 'help'
59
+ puts help_cli
60
+ when /^\d+$/
61
+ puts run(argument)
62
+ else
63
+ repl
64
+ end
65
+ end
66
+
67
+ start
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tg_fibonacci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Johnson
@@ -24,7 +24,76 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: "# TG Fibonacci"
27
+ description: |-
28
+ # TG Fibonacci
29
+
30
+ [![Build Status](https://travis-ci.com/tacoda/tg_fibonacci.svg?branch=master)](https://travis-ci.com/tacoda/tg_fibonacci)
31
+
32
+ ## Problem
33
+
34
+ Enter a number and have the program generate the Fibonacci sequence to that number or to the `n`th number.
35
+
36
+ ## Installation
37
+
38
+ Install using RubyGems.
39
+
40
+ ```sh
41
+ gem install tg_fibonacci
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ Provide a `help` argument to get CLI program help.
47
+
48
+ ```sh
49
+ $ tg_fib help
50
+
51
+ tg_fib Compute fibonacci numbers
52
+
53
+ Usage:
54
+ tg_fib help Show this help menu
55
+ tg_fib [number] Compute the fibonacci number
56
+ tg_fib Enter interactive mode
57
+ ```
58
+
59
+ Provide a non-negative integer to compute the fibonacci sequence for that number.
60
+
61
+ ```sh
62
+ $ tg_fib 5
63
+
64
+ fib(5) = 1, 1, 2, 3, 5, 8
65
+ ```
66
+
67
+ Provide no arguments to enter interactive mode.
68
+
69
+ ```sh
70
+ $ tg_fib
71
+
72
+ Please enter a non-negative integer: (h)elp, (q)uit
73
+ > 5
74
+ fib(5) = 1, 1, 2, 3, 5, 8
75
+
76
+ Please enter a non-negative integer: (h)elp, (q)uit
77
+ > 3
78
+ fib(3) = 1, 1, 2, 3
79
+
80
+ > help
81
+ Interactive help:
82
+
83
+ Commands:
84
+ (h)elp Show this help menu
85
+ (q)uit Quit the program
86
+
87
+ Usage:
88
+ Enter a non-negative integer to compute that fibonacci number.
89
+
90
+ Example:
91
+ > 5
92
+ # => fib(5) = 1, 1, 2, 3, 5, 8
93
+
94
+ Please enter a non-negative integer: (h)elp, (q)uit
95
+ > quit
96
+ ```
28
97
  email: tacoda@pm.me
29
98
  executables:
30
99
  - tg_fib
@@ -37,7 +106,8 @@ files:
37
106
  - lib/fibonacci/fibonacci.rb
38
107
  - spec/fibonacci/fibonacci_spec.rb
39
108
  homepage: https://github.com/tacoda/tg_fibonacci
40
- licenses: []
109
+ licenses:
110
+ - MIT
41
111
  metadata: {}
42
112
  post_install_message:
43
113
  rdoc_options: []