pot_of_coffee 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2965ddf1855b70dfef81fef85011fb6fe8708254
4
- data.tar.gz: b9473aa3e867606b624238975d91174282cdb688
3
+ metadata.gz: 6dae6851d3f6b176c848021118ba99f6f0a6a341
4
+ data.tar.gz: 7da04121b0e181498651568d567938ea43bc054a
5
5
  SHA512:
6
- metadata.gz: 839c853825208c76183555682bf19ddb10739ee52cd5fc383e72d3fec769d2f076e76d263adc7e6bfa70131d71bc76a19523886e10152ec14e6aa746e7a9a7e0
7
- data.tar.gz: 3a4ea38cec9c59373db2c20a06e67869786314e1a28aadd4d7a39561e0480a94a4afce60986bcbe94ba037e4747de584914a75cefce8edbe3b553f3eba82ecdb
6
+ metadata.gz: ccf5fe51ce999c03091ea604c5760f4ee0a083e1fcde1d2ca8e1fca428c37723267baab63e494394b110e5b648b4f2d98d452351e52cc850c98363ddc8c79c64
7
+ data.tar.gz: ee37badbcdabaaa07f3b1e96a67e9c8f4281e786f5a6e878ebea3f44bb74e77c160fdad0eeeda652a69d7dffd40489d1ecc7f3b10d420d66ff53315835b7150d
data/bin/pot_of_coffee CHANGED
@@ -1,15 +1,42 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
+ require 'optparse'
3
4
  require 'pot_of_coffee'
4
5
 
5
- unless ARGV[0] && ARGV[1]
6
- puts 'Please provide the number of cups you want and the strength. Example: `pot_of_coffee 12 normal`'
7
- exit 1
8
- end
6
+ options = {
7
+ quantity: 12,
8
+ strength: :normal,
9
+ units: PotOfCoffee::ImperialUnit.new
10
+ }
9
11
 
10
- quantity = ARGV[0].to_i
11
- strength = ARGV[1].to_sym
12
- units = PotOfCoffee::MetricUnit.new
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
13
14
 
14
- pot_of_coffee = PotOfCoffee::Brewer.new(quantity: quantity, strength: strength, units: units)
15
+ opts.on('-q', '--quantity [QUANTITY]', Integer, "Number of cups of coffee you'd like") do |v|
16
+ options[:quantity] = v
17
+ end
18
+
19
+ opts.on('-s', '--strength [STRENGTH]', String, 'Strength of your coffee (normal, strong, weak)') do |v|
20
+ options[:strength] = v.to_sym
21
+ end
22
+
23
+ opts.on('-u', '--units [UNITS]', 'Units for your coffee brew (imperial, metric)') do |v|
24
+ options[:units] = case v
25
+ when 'metric'
26
+ PotOfCoffee::MetricUnit.new
27
+ when 'imperial'
28
+ PotOfCoffee::ImperialUnit.new
29
+ else
30
+ puts "#{v} is not 'imperial' or 'metric'"
31
+ exit
32
+ end
33
+ end
34
+
35
+ opts.on( '-h', '--help', 'Display this screen' ) do
36
+ puts opts
37
+ exit
38
+ end
39
+ end.parse!
40
+
41
+ pot_of_coffee = PotOfCoffee::Brewer.new(options)
15
42
  puts pot_of_coffee.instructions
@@ -1,3 +1,3 @@
1
1
  module PotOfCoffee
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pot_of_coffee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler