pot_of_coffee 0.2.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +25 -0
- data/.gitignore +1 -2
- data/.rubocop.yml +48 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +66 -0
- data/README.md +58 -21
- data/Rakefile +7 -5
- data/bin/console +7 -0
- data/bin/pot_of_coffee +17 -17
- data/lib/pot_of_coffee/brewer.rb +28 -0
- data/lib/pot_of_coffee/errors.rb +14 -10
- data/lib/pot_of_coffee/units.rb +6 -3
- data/lib/pot_of_coffee/version.rb +8 -1
- data/lib/pot_of_coffee.rb +6 -26
- data/pot_of_coffee.gemspec +21 -15
- data/spec/pot_of_coffee/brewer_spec.rb +19 -31
- data/spec/pot_of_coffee/units_spec.rb +13 -11
- data/spec/spec_helper.rb +3 -1
- metadata +67 -23
- data/lib/pot_of_coffee/units/imperial.rb +0 -21
- data/lib/pot_of_coffee/units/metric.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7441c4f0ba5a6791e9925193bb36f7078f1182555d7117361b9195d623e1d047
|
4
|
+
data.tar.gz: 15ca36a14021290adae10e6b16f1e13fb90258e6ea30b5bf0a9e5e3e59a776db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a953c88186a204c192b77daf29bf621b65bdcfebe3c234019e4ff59abde8de779f3abbbc43035a07770482bf2f2d5b48d52c3c5eb092d71b420cb03400aeaa
|
7
|
+
data.tar.gz: 98b1079a7deacd2e1afdc477a99c8f6a1a1f2235979d666088502caab896ca22516bd407d185299baff97490cbb3efc70cf41ef1a2a87e0e6e89dd1e6b173b64
|
@@ -0,0 +1,25 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@1.4.0
|
4
|
+
slack: circleci/slack@3.4.2
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
docker:
|
8
|
+
- image: cimg/ruby:2.7.0
|
9
|
+
environment:
|
10
|
+
RAILS_ENV: test
|
11
|
+
executor: ruby/default
|
12
|
+
steps:
|
13
|
+
- checkout
|
14
|
+
- ruby/install-deps
|
15
|
+
- run:
|
16
|
+
name: Which bundler?
|
17
|
+
command: bundle -v
|
18
|
+
- ruby/rubocop-check
|
19
|
+
- ruby/rspec-test
|
20
|
+
- slack/status
|
21
|
+
workflows:
|
22
|
+
version: 2
|
23
|
+
make_it_so:
|
24
|
+
jobs:
|
25
|
+
- test
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisabledByDefault: true
|
3
|
+
TargetRubyVersion: 2.6
|
4
|
+
|
5
|
+
Layout/EndAlignment:
|
6
|
+
Enabled: true
|
7
|
+
|
8
|
+
Lint/AmbiguousBlockAssociation:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Layout/LineLength:
|
12
|
+
Max: 160
|
13
|
+
Exclude:
|
14
|
+
- "pot_of_coffee.gemspec"
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/ExpandPathArguments:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Style/FrozenStringLiteralComment:
|
23
|
+
EnforcedStyle: always
|
24
|
+
Exclude:
|
25
|
+
- "bin/**/*"
|
26
|
+
|
27
|
+
Style/HashSyntax:
|
28
|
+
EnforcedStyle: no_mixed_keys
|
29
|
+
|
30
|
+
Style/IfUnlessModifier:
|
31
|
+
Exclude:
|
32
|
+
- "spec/spec_helper.rb"
|
33
|
+
|
34
|
+
Style/NumericLiterals:
|
35
|
+
MinDigits: 7
|
36
|
+
|
37
|
+
Style/NumericPredicate:
|
38
|
+
EnforcedStyle: predicate
|
39
|
+
|
40
|
+
Style/SignalException:
|
41
|
+
EnforcedStyle: semantic
|
42
|
+
|
43
|
+
Style/StringLiterals:
|
44
|
+
EnforcedStyle: double_quotes
|
45
|
+
ConsistentQuotesInMultiline: true
|
46
|
+
|
47
|
+
Style/SymbolArray:
|
48
|
+
EnforcedStyle: percent
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pot_of_coffee (0.4.1)
|
5
|
+
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
coderay (1.1.3)
|
12
|
+
diff-lcs (1.5.0)
|
13
|
+
method_source (1.0.0)
|
14
|
+
parallel (1.22.1)
|
15
|
+
parser (3.1.1.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
pry (0.14.1)
|
18
|
+
coderay (~> 1.1)
|
19
|
+
method_source (~> 1.0)
|
20
|
+
rainbow (3.1.1)
|
21
|
+
rake (13.0.6)
|
22
|
+
regexp_parser (2.2.1)
|
23
|
+
rexml (3.2.5)
|
24
|
+
rspec (3.11.0)
|
25
|
+
rspec-core (~> 3.11.0)
|
26
|
+
rspec-expectations (~> 3.11.0)
|
27
|
+
rspec-mocks (~> 3.11.0)
|
28
|
+
rspec-core (3.11.0)
|
29
|
+
rspec-support (~> 3.11.0)
|
30
|
+
rspec-expectations (3.11.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.11.0)
|
33
|
+
rspec-mocks (3.11.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.11.0)
|
36
|
+
rspec-support (3.11.0)
|
37
|
+
rspec_junit_formatter (0.5.1)
|
38
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
39
|
+
rubocop (1.26.1)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 3.1.0.0)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.8, < 3.0)
|
44
|
+
rexml
|
45
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
48
|
+
rubocop-ast (1.16.0)
|
49
|
+
parser (>= 3.1.1.0)
|
50
|
+
ruby-progressbar (1.11.0)
|
51
|
+
unicode-display_width (2.1.0)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
bundler
|
58
|
+
pot_of_coffee!
|
59
|
+
pry
|
60
|
+
rake
|
61
|
+
rspec
|
62
|
+
rspec_junit_formatter
|
63
|
+
rubocop
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
2.3.6
|
data/README.md
CHANGED
@@ -4,13 +4,14 @@ This is a command line coffee brew calculator.
|
|
4
4
|
Enter the number of cups you want and the strength.
|
5
5
|
It can also be used in your own code, and you can supply your own units for grounds if you don't want to use tablespoons.
|
6
6
|
I use it to maintain intra-office harmony.
|
7
|
+
Imperial and metric units are provided.
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
10
11
|
Add this line to your application's Gemfile:
|
11
12
|
|
12
13
|
```ruby
|
13
|
-
gem
|
14
|
+
gem "pot_of_coffee"
|
14
15
|
```
|
15
16
|
|
16
17
|
And then execute:
|
@@ -24,70 +25,106 @@ Or install it yourself as:
|
|
24
25
|
## Usage
|
25
26
|
|
26
27
|
### CLI
|
27
|
-
|
28
|
-
|
29
|
-
pot_of_coffee
|
30
|
-
|
31
|
-
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ pot_of_coffee
|
31
|
+
Cups desired: 12
|
32
|
+
Brew strength: medium
|
33
|
+
Grounds needed: 8.1 tbsp
|
34
|
+
|
35
|
+
$ pot_of_coffee --strength=strong
|
36
|
+
Cups desired: 12
|
37
|
+
Brew strength: strong
|
38
|
+
Grounds needed: 10.5 tbsp
|
39
|
+
|
40
|
+
$ pot_of_coffee --strength=blagg
|
41
|
+
Sorry: coffee strength must be strong, medium, or mild
|
42
|
+
|
43
|
+
$ pot_of_coffee --units=metric
|
44
|
+
Cups desired: 12
|
45
|
+
Brew strength: medium
|
46
|
+
Grounds needed: 63.6 g
|
47
|
+
|
32
48
|
```
|
33
49
|
|
34
50
|
### Ruby
|
51
|
+
|
35
52
|
```ruby
|
36
|
-
require
|
53
|
+
require "pot_of_coffee"
|
37
54
|
|
38
|
-
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 12, strength:
|
55
|
+
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 12, strength: "mild")
|
39
56
|
pot_of_coffee.amount # 6.0
|
40
|
-
pot_of_coffee.instructions
|
57
|
+
pot_of_coffee.instructions
|
58
|
+
#=> Cups desired: 12
|
59
|
+
#=> Brew strength: mild
|
60
|
+
#=> Grounds needed: 6.0 tbsp
|
61
|
+
|
41
62
|
|
42
63
|
# Metric units
|
43
64
|
|
44
|
-
pot_of_coffee = PotOfCoffee::Brewer.new(units: PotOfCoffee::
|
65
|
+
pot_of_coffee = PotOfCoffee::Brewer.new(units: PotOfCoffee::Units::Metric)
|
45
66
|
pot_of_coffee.amount # 63.6
|
46
|
-
pot_of_coffee.instructions
|
67
|
+
pot_of_coffee.instructions
|
68
|
+
#=> Cups desired: 12
|
69
|
+
#=> Brew strength: medium
|
70
|
+
#=> Grounds needed: 63.6 g
|
47
71
|
```
|
48
72
|
|
49
73
|
## Using your own units
|
50
|
-
|
74
|
+
You can use a different set of units or different ratios if you want.
|
51
75
|
Just supply an object that responds to `name`, `abbreviation`, and `table`.
|
52
76
|
`name` and `abbreviation` must be strings.
|
53
77
|
`name` is not used at the moment, but it may be in the future.
|
54
78
|
`table` must be a hash.
|
55
|
-
I chose to provide three keys: `:strong`, `:
|
79
|
+
I chose to provide three keys: `:strong`, `:medium`, and `:mild`, but you can use whatever you'd like.
|
56
80
|
|
57
81
|
### Example
|
82
|
+
|
58
83
|
```ruby
|
59
|
-
require
|
84
|
+
require "pot_of_coffee"
|
60
85
|
|
61
86
|
class CorgeUnit
|
62
87
|
def name
|
63
|
-
|
88
|
+
"corge"
|
64
89
|
end
|
65
90
|
|
66
91
|
def abbreviation
|
67
|
-
|
92
|
+
"cg"
|
68
93
|
end
|
69
94
|
|
70
95
|
def table
|
71
96
|
{
|
72
97
|
strong: 3900,
|
73
|
-
|
74
|
-
|
98
|
+
medium: 200,
|
99
|
+
mild: 100
|
75
100
|
}
|
76
101
|
end
|
77
102
|
end
|
78
103
|
|
79
|
-
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 3, strength: :
|
104
|
+
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 3, strength: :mild, units: CorgeUnit.new)
|
80
105
|
pot_of_coffee.amount # 300
|
81
106
|
```
|
82
107
|
|
108
|
+
The same example can be accomplished easily by making new instance of `PotOfCoffee::Units::Unit`:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
corge = PotOfCoffee::Units::Unit.new("corge", "cg", { strong: 3900, medium: 200, mild: 100 })
|
112
|
+
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 3, strength: :mild, units: corge)
|
113
|
+
pot_of_coffee.amount # 300
|
114
|
+
```
|
115
|
+
|
116
|
+
|
83
117
|
## Tests
|
84
118
|
|
85
|
-
|
119
|
+
* Fork/clone the repo
|
120
|
+
* `bundle install`
|
121
|
+
* `bundle exec rspec`
|
122
|
+
* `bundle exec rubocop`
|
86
123
|
|
87
124
|
## Contributing
|
88
125
|
|
89
126
|
1. Fork it ( https://github.com/[my-github-username]/pot_of_coffee/fork )
|
90
127
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
|
-
3. Commit your changes (`git commit -am
|
128
|
+
3. Commit your changes (`git commit -am "Add some feature"`)
|
92
129
|
4. Push to the branch (`git push origin my-new-feature`)
|
93
130
|
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
3
5
|
|
4
6
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.test_files = FileList[
|
7
|
+
t.libs << "test"
|
8
|
+
t.test_files = FileList["test/test_*.rb"]
|
7
9
|
t.verbose = true
|
8
10
|
end
|
9
11
|
|
10
|
-
desc
|
12
|
+
desc "Run tests"
|
11
13
|
task :default => :test
|
data/bin/console
ADDED
data/bin/pot_of_coffee
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "optparse"
|
4
|
+
require "pot_of_coffee"
|
5
5
|
|
6
6
|
options = {
|
7
7
|
quantity: 12,
|
8
|
-
strength: :
|
9
|
-
units: PotOfCoffee::Units::Imperial
|
8
|
+
strength: :medium,
|
9
|
+
units: PotOfCoffee::Units::Imperial
|
10
10
|
}
|
11
11
|
|
12
12
|
OptionParser.new do |opts|
|
13
13
|
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
|
14
14
|
|
15
|
-
opts.on(
|
15
|
+
opts.on("-q", "--quantity [QUANTITY]", Integer, "Number of cups of coffee you'd like") do |v|
|
16
16
|
options[:quantity] = v
|
17
17
|
end
|
18
18
|
|
19
|
-
opts.on(
|
19
|
+
opts.on("-s", "--strength [STRENGTH]", String, "Strength of your coffee (medium, strong, mild)") do |v|
|
20
20
|
options[:strength] = v.to_sym
|
21
21
|
end
|
22
22
|
|
23
|
-
opts.on(
|
23
|
+
opts.on("-u", "--units [UNITS]", "Units for your coffee brew (imperial, metric)") do |v|
|
24
24
|
options[:units] = case v
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
when "metric"
|
26
|
+
PotOfCoffee::Units::Metric
|
27
|
+
when "imperial"
|
28
|
+
PotOfCoffee::Units::Imperial
|
29
|
+
else
|
30
|
+
puts "#{v} is not 'imperial' or 'metric'"
|
31
|
+
exit
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
|
-
opts.on(
|
35
|
+
opts.on("-h", "--help", "Display this screen") do
|
36
36
|
puts opts
|
37
37
|
exit
|
38
38
|
end
|
39
39
|
end.parse!
|
40
40
|
|
41
41
|
pot_of_coffee = PotOfCoffee::Brewer.new(**options)
|
42
|
-
puts pot_of_coffee.instructions
|
42
|
+
puts pot_of_coffee.instructions
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PotOfCoffee
|
4
|
+
class Brewer
|
5
|
+
attr_reader :units, :quantity, :strength
|
6
|
+
|
7
|
+
def initialize(quantity: 12, strength: :medium, units: Units::Imperial)
|
8
|
+
fail Errors::NegativeNumber unless quantity.positive?
|
9
|
+
fail Errors::WrongStrength unless units.table.keys.include?(strength)
|
10
|
+
|
11
|
+
@quantity = quantity
|
12
|
+
@strength = strength
|
13
|
+
@units = units
|
14
|
+
end
|
15
|
+
|
16
|
+
def grounds
|
17
|
+
(quantity * units.table.fetch(strength)).round(2)
|
18
|
+
end
|
19
|
+
|
20
|
+
def instructions
|
21
|
+
<<~INSTRUCTIONS
|
22
|
+
Cups desired: #{quantity}
|
23
|
+
Brew strength: #{strength}
|
24
|
+
Grounds needed: #{grounds} #{units.abbreviation}
|
25
|
+
INSTRUCTIONS
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/pot_of_coffee/errors.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PotOfCoffee
|
2
|
-
|
3
|
-
|
4
|
+
module Errors
|
5
|
+
class Error < StandardError
|
6
|
+
end
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
class NegativeNumber < Error
|
9
|
+
def message
|
10
|
+
"Sorry: coffee quantity must be greater than 0"
|
11
|
+
end
|
8
12
|
end
|
9
|
-
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
class WrongStrength < Error
|
15
|
+
def message
|
16
|
+
"Sorry: coffee strength must be strong, medium, or mild"
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
|
-
end
|
20
|
+
end
|
data/lib/pot_of_coffee/units.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'pot_of_coffee/units/metric'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module PotOfCoffee
|
5
4
|
module Units
|
5
|
+
Unit = Struct.new(:name, :abbreviation, :table)
|
6
|
+
|
7
|
+
Imperial = Unit.new("tablespoon", "tbsp", { mild: 0.5, medium: 0.675, strong: 0.875 })
|
8
|
+
Metric = Unit.new("gram", "g", { mild: 2, medium: 4.16, strong: 5.3 })
|
6
9
|
end
|
7
|
-
end
|
10
|
+
end
|
data/lib/pot_of_coffee.rb
CHANGED
@@ -1,28 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'pot_of_coffee/units'
|
3
|
-
require 'pot_of_coffee/errors'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
3
|
module PotOfCoffee
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
fail WrongStrengthError unless units.table.keys.include?(strength)
|
12
|
-
|
13
|
-
@quantity = quantity
|
14
|
-
@strength = strength
|
15
|
-
@units = units
|
16
|
-
# rescue NegativeNumberError, WrongStrengthError => e
|
17
|
-
# print e.message
|
18
|
-
end
|
19
|
-
|
20
|
-
def amount
|
21
|
-
(quantity * units.table.fetch(strength)).round(2)
|
22
|
-
end
|
23
|
-
|
24
|
-
def instructions
|
25
|
-
"To make #{quantity} cups of of #{strength} coffee, use #{amount} #{units.abbreviation} of grounds."
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
4
|
+
autoload :Brewer, "pot_of_coffee/brewer"
|
5
|
+
autoload :Version, "pot_of_coffee/version"
|
6
|
+
autoload :Units, "pot_of_coffee/units"
|
7
|
+
autoload :Errors, "pot_of_coffee/errors"
|
8
|
+
end
|
data/pot_of_coffee.gemspec
CHANGED
@@ -1,24 +1,30 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
+
require "pot_of_coffee/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = "pot_of_coffee"
|
8
9
|
spec.version = PotOfCoffee::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
10
|
+
spec.authors = ["Dave Shaffer"]
|
11
|
+
spec.email = ["dave.shaffer@gmail.com"]
|
12
|
+
spec.summary = "Coffee brew strength calculator"
|
13
|
+
spec.description = "This is a small CLI app for calculating the brew strength for an automatic drip coffee maker. It can help keep coffee brews consistent."
|
14
|
+
spec.homepage = "https://github.com/flanger001/pot_of_coffee"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.required_ruby_version = ">= 2.7.0"
|
15
18
|
|
16
19
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = [
|
20
|
+
spec.executables = ["pot_of_coffee"]
|
18
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
22
|
+
spec.require_paths = ["lib"]
|
20
23
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
29
|
+
spec.add_development_dependency "rubocop"
|
24
30
|
end
|
@@ -1,51 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe PotOfCoffee::Brewer do
|
2
|
-
context
|
4
|
+
context "with no arguments" do
|
3
5
|
let(:pot_of_coffee) { PotOfCoffee::Brewer.new }
|
4
6
|
|
5
|
-
it
|
6
|
-
expect(pot_of_coffee.instructions).to eq(
|
7
|
+
it "has correct properties and gives instructions" do
|
8
|
+
expect(pot_of_coffee.instructions).to eq("Cups desired: 12\nBrew strength: medium\nGrounds needed: 8.1 tbsp\n")
|
7
9
|
expect(pot_of_coffee.quantity).to eq(12)
|
8
|
-
expect(pot_of_coffee.strength).to eq(:
|
10
|
+
expect(pot_of_coffee.strength).to eq(:medium)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
|
-
context
|
13
|
-
it
|
14
|
-
expect { PotOfCoffee::Brewer.new(quantity: -1) }.to raise_error(PotOfCoffee::
|
14
|
+
context "with invalid quantity" do
|
15
|
+
it "raises PotOfCoffee::Errors::NegativeNumber" do
|
16
|
+
expect { PotOfCoffee::Brewer.new(quantity: -1) }.to raise_error(PotOfCoffee::Errors::NegativeNumber)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
context
|
19
|
-
it
|
20
|
-
expect { PotOfCoffee::Brewer.new(strength: :ultra) }.to raise_error(PotOfCoffee::
|
20
|
+
context "with invalid strength" do
|
21
|
+
it "raises PotOfCoffee::Errors::WrongStrength" do
|
22
|
+
expect { PotOfCoffee::Brewer.new(strength: :ultra) }.to raise_error(PotOfCoffee::Errors::WrongStrength)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
|
25
|
-
context
|
26
|
-
|
27
|
-
def name
|
28
|
-
'grably'
|
29
|
-
end
|
30
|
-
|
31
|
-
def abbreviation
|
32
|
-
'gb'
|
33
|
-
end
|
27
|
+
context "with own units" do
|
28
|
+
let(:pot_of_coffee) { PotOfCoffee::Brewer.new(units: Whatever) }
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
normal: 279.10,
|
39
|
-
weak: 100
|
40
|
-
}
|
41
|
-
end
|
30
|
+
before do
|
31
|
+
whatever = PotOfCoffee::Units::Unit.new("grably", "gb", { strong: 109109, medium: 279.10, mild: 100 })
|
32
|
+
stub_const("Whatever", whatever)
|
42
33
|
end
|
43
34
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
it 'can provide your own units' do
|
48
|
-
expect(pot_of_coffee.instructions).to eq('To make 12 cups of of normal coffee, use 3349.2 gb of grounds.')
|
35
|
+
it "can provide your own units" do
|
36
|
+
expect(pot_of_coffee.instructions).to eq("Cups desired: 12\nBrew strength: medium\nGrounds needed: 3349.2 gb\n")
|
49
37
|
end
|
50
38
|
end
|
51
39
|
end
|
@@ -1,30 +1,32 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.shared_examples "a correct unit" do
|
4
|
+
describe "#name" do
|
3
5
|
subject { units.name }
|
4
6
|
it { is_expected.to be_a(String) }
|
5
7
|
end
|
6
8
|
|
7
|
-
describe
|
9
|
+
describe "#abbreviation" do
|
8
10
|
subject { units.abbreviation }
|
9
11
|
it { is_expected.to be_a(String) }
|
10
12
|
end
|
11
13
|
|
12
|
-
describe
|
14
|
+
describe "#table" do
|
13
15
|
subject { units.table }
|
14
|
-
it { is_expected.to
|
16
|
+
it { is_expected.to(satisfy { |t| %i[weak medium strong].each { |key| t.keys.include?(key) } }) }
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
RSpec.describe PotOfCoffee::Units do
|
19
|
-
describe
|
20
|
-
let(:units) { PotOfCoffee::Units::Imperial
|
21
|
+
describe "Imperial" do
|
22
|
+
let(:units) { PotOfCoffee::Units::Imperial }
|
21
23
|
|
22
|
-
it_behaves_like
|
24
|
+
it_behaves_like "a correct unit"
|
23
25
|
end
|
24
26
|
|
25
|
-
describe
|
26
|
-
let(:units) { PotOfCoffee::Units::Metric
|
27
|
+
describe "Metric" do
|
28
|
+
let(:units) { PotOfCoffee::Units::Metric }
|
27
29
|
|
28
|
-
it_behaves_like
|
30
|
+
it_behaves_like "a correct unit"
|
29
31
|
end
|
30
32
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pot_of_coffee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Shaffer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec_junit_formatter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
46
88
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
89
|
+
version: '0'
|
48
90
|
type: :development
|
49
91
|
prerelease: false
|
50
92
|
version_requirements: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
|
-
- - "
|
94
|
+
- - ">="
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
96
|
+
version: '0'
|
55
97
|
description: This is a small CLI app for calculating the brew strength for an automatic
|
56
98
|
drip coffee maker. It can help keep coffee brews consistent.
|
57
99
|
email:
|
@@ -61,28 +103,31 @@ executables:
|
|
61
103
|
extensions: []
|
62
104
|
extra_rdoc_files: []
|
63
105
|
files:
|
106
|
+
- ".circleci/config.yml"
|
64
107
|
- ".gitignore"
|
65
108
|
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
66
110
|
- Gemfile
|
111
|
+
- Gemfile.lock
|
67
112
|
- LICENSE.txt
|
68
113
|
- README.md
|
69
114
|
- Rakefile
|
115
|
+
- bin/console
|
70
116
|
- bin/pot_of_coffee
|
71
117
|
- lib/pot_of_coffee.rb
|
118
|
+
- lib/pot_of_coffee/brewer.rb
|
72
119
|
- lib/pot_of_coffee/errors.rb
|
73
120
|
- lib/pot_of_coffee/units.rb
|
74
|
-
- lib/pot_of_coffee/units/imperial.rb
|
75
|
-
- lib/pot_of_coffee/units/metric.rb
|
76
121
|
- lib/pot_of_coffee/version.rb
|
77
122
|
- pot_of_coffee.gemspec
|
78
123
|
- spec/pot_of_coffee/brewer_spec.rb
|
79
124
|
- spec/pot_of_coffee/units_spec.rb
|
80
125
|
- spec/spec_helper.rb
|
81
|
-
homepage:
|
126
|
+
homepage: https://github.com/flanger001/pot_of_coffee
|
82
127
|
licenses:
|
83
128
|
- MIT
|
84
129
|
metadata: {}
|
85
|
-
post_install_message:
|
130
|
+
post_install_message:
|
86
131
|
rdoc_options: []
|
87
132
|
require_paths:
|
88
133
|
- lib
|
@@ -90,16 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
135
|
requirements:
|
91
136
|
- - ">="
|
92
137
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
138
|
+
version: 2.7.0
|
94
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
140
|
requirements:
|
96
141
|
- - ">="
|
97
142
|
- !ruby/object:Gem::Version
|
98
143
|
version: '0'
|
99
144
|
requirements: []
|
100
|
-
|
101
|
-
|
102
|
-
signing_key:
|
145
|
+
rubygems_version: 3.2.32
|
146
|
+
signing_key:
|
103
147
|
specification_version: 4
|
104
148
|
summary: Coffee brew strength calculator
|
105
149
|
test_files:
|