pot_of_coffee 0.3.0 → 0.4.0
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 +65 -0
- data/README.md +23 -9
- data/Rakefile +7 -5
- data/bin/console +3 -2
- data/bin/pot_of_coffee +12 -12
- data/lib/pot_of_coffee.rb +6 -6
- data/lib/pot_of_coffee/brewer.rb +6 -4
- 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 +3 -1
- data/pot_of_coffee.gemspec +21 -16
- data/spec/pot_of_coffee/brewer_spec.rb +16 -27
- data/spec/pot_of_coffee/units_spec.rb +13 -11
- data/spec/spec_helper.rb +3 -1
- metadata +55 -27
- 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: 0f76f3500acf845dc3d764c0ca309465cf863190353538bfa9b5fd7f4c73f7a3
|
4
|
+
data.tar.gz: dc9203c6694d4b3b1cc80084be5041ccbdf61d792b2c3c2b5a49b4cc4f4e6b1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5899e7cbc4d848e37691235662761c3fbd55b27b0ff1a42268285b351fc89c8516c510473eedd0ed0da17ff53b89d27b1de252b73dbddb29a59648343eae4807
|
7
|
+
data.tar.gz: 553f20918532710b2a09c02a3ab61066e72499ea22145516ab91af1892498e88a5925ed99f20cad7499e90c74e6b997629f3e6f8ceec9eb23dd47d9ebcd7abc1
|
@@ -0,0 +1,25 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@1.1.0
|
4
|
+
slack: circleci/slack@3.4.2
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
docker:
|
8
|
+
- image: circleci/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,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pot_of_coffee (0.3.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.1)
|
10
|
+
coderay (1.1.3)
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
method_source (1.0.0)
|
13
|
+
parallel (1.19.2)
|
14
|
+
parser (2.7.1.4)
|
15
|
+
ast (~> 2.4.1)
|
16
|
+
pry (0.13.1)
|
17
|
+
coderay (~> 1.1)
|
18
|
+
method_source (~> 1.0)
|
19
|
+
rainbow (3.0.0)
|
20
|
+
rake (13.0.1)
|
21
|
+
regexp_parser (1.7.1)
|
22
|
+
rexml (3.2.4)
|
23
|
+
rspec (3.9.0)
|
24
|
+
rspec-core (~> 3.9.0)
|
25
|
+
rspec-expectations (~> 3.9.0)
|
26
|
+
rspec-mocks (~> 3.9.0)
|
27
|
+
rspec-core (3.9.2)
|
28
|
+
rspec-support (~> 3.9.3)
|
29
|
+
rspec-expectations (3.9.2)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.9.0)
|
32
|
+
rspec-mocks (3.9.1)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.9.0)
|
35
|
+
rspec-support (3.9.3)
|
36
|
+
rspec_junit_formatter (0.4.1)
|
37
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
38
|
+
rubocop (0.89.1)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 2.7.1.1)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.7)
|
43
|
+
rexml
|
44
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
45
|
+
ruby-progressbar (~> 1.7)
|
46
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
47
|
+
rubocop-ast (0.3.0)
|
48
|
+
parser (>= 2.7.1.4)
|
49
|
+
ruby-progressbar (1.10.1)
|
50
|
+
unicode-display_width (1.7.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler
|
57
|
+
pot_of_coffee!
|
58
|
+
pry
|
59
|
+
rake
|
60
|
+
rspec
|
61
|
+
rspec_junit_formatter
|
62
|
+
rubocop
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.1.4
|
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,6 +25,7 @@ Or install it yourself as:
|
|
24
25
|
## Usage
|
25
26
|
|
26
27
|
### CLI
|
28
|
+
|
27
29
|
```bash
|
28
30
|
$ pot_of_coffee
|
29
31
|
Cups desired: 12
|
@@ -46,10 +48,11 @@ Grounds needed: 63.6 g
|
|
46
48
|
```
|
47
49
|
|
48
50
|
### Ruby
|
51
|
+
|
49
52
|
```ruby
|
50
|
-
require
|
53
|
+
require "pot_of_coffee"
|
51
54
|
|
52
|
-
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 12, strength:
|
55
|
+
pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 12, strength: "mild")
|
53
56
|
pot_of_coffee.amount # 6.0
|
54
57
|
pot_of_coffee.instructions
|
55
58
|
#=> Cups desired: 12
|
@@ -59,7 +62,7 @@ pot_of_coffee.instructions
|
|
59
62
|
|
60
63
|
# Metric units
|
61
64
|
|
62
|
-
pot_of_coffee = PotOfCoffee::Brewer.new(units: PotOfCoffee::Units::Metric
|
65
|
+
pot_of_coffee = PotOfCoffee::Brewer.new(units: PotOfCoffee::Units::Metric)
|
63
66
|
pot_of_coffee.amount # 63.6
|
64
67
|
pot_of_coffee.instructions
|
65
68
|
#=> Cups desired: 12
|
@@ -68,7 +71,7 @@ pot_of_coffee.instructions
|
|
68
71
|
```
|
69
72
|
|
70
73
|
## Using your own units
|
71
|
-
|
74
|
+
You can use a different set of units or different ratios if you want.
|
72
75
|
Just supply an object that responds to `name`, `abbreviation`, and `table`.
|
73
76
|
`name` and `abbreviation` must be strings.
|
74
77
|
`name` is not used at the moment, but it may be in the future.
|
@@ -76,16 +79,17 @@ Just supply an object that responds to `name`, `abbreviation`, and `table`.
|
|
76
79
|
I chose to provide three keys: `:strong`, `:medium`, and `:mild`, but you can use whatever you'd like.
|
77
80
|
|
78
81
|
### Example
|
82
|
+
|
79
83
|
```ruby
|
80
|
-
require
|
84
|
+
require "pot_of_coffee"
|
81
85
|
|
82
86
|
class CorgeUnit
|
83
87
|
def name
|
84
|
-
|
88
|
+
"corge"
|
85
89
|
end
|
86
90
|
|
87
91
|
def abbreviation
|
88
|
-
|
92
|
+
"cg"
|
89
93
|
end
|
90
94
|
|
91
95
|
def table
|
@@ -101,16 +105,26 @@ pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 3, strength: :mild, units: Cor
|
|
101
105
|
pot_of_coffee.amount # 300
|
102
106
|
```
|
103
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
|
+
|
104
117
|
## Tests
|
105
118
|
|
106
119
|
* Fork/clone the repo
|
107
120
|
* `bundle install`
|
108
121
|
* `bundle exec rspec`
|
122
|
+
* `bundle exec rubocop`
|
109
123
|
|
110
124
|
## Contributing
|
111
125
|
|
112
126
|
1. Fork it ( https://github.com/[my-github-username]/pot_of_coffee/fork )
|
113
127
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
114
|
-
3. Commit your changes (`git commit -am
|
128
|
+
3. Commit your changes (`git commit -am "Add some feature"`)
|
115
129
|
4. Push to the branch (`git push origin my-new-feature`)
|
116
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
CHANGED
data/bin/pot_of_coffee
CHANGED
@@ -1,38 +1,38 @@
|
|
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
8
|
strength: :medium,
|
9
|
-
units: PotOfCoffee::Units::Imperial
|
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
|
-
when
|
26
|
-
PotOfCoffee::Units::Metric
|
27
|
-
when
|
28
|
-
PotOfCoffee::Units::Imperial
|
25
|
+
when "metric"
|
26
|
+
PotOfCoffee::Units::Metric
|
27
|
+
when "imperial"
|
28
|
+
PotOfCoffee::Units::Imperial
|
29
29
|
else
|
30
30
|
puts "#{v} is not 'imperial' or 'metric'"
|
31
31
|
exit
|
32
|
-
|
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
|
data/lib/pot_of_coffee.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'pot_of_coffee/version'
|
3
|
-
require 'pot_of_coffee/units'
|
4
|
-
require 'pot_of_coffee/errors'
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
3
|
module PotOfCoffee
|
7
|
-
|
8
|
-
|
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/lib/pot_of_coffee/brewer.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PotOfCoffee
|
2
4
|
class Brewer
|
3
5
|
attr_reader :units, :quantity, :strength
|
4
6
|
|
5
|
-
def initialize(quantity: 12, strength: :medium, units: Units::Imperial
|
6
|
-
fail
|
7
|
-
fail
|
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)
|
8
10
|
|
9
11
|
@quantity = quantity
|
10
12
|
@strength = strength
|
@@ -23,4 +25,4 @@ module PotOfCoffee
|
|
23
25
|
INSTRUCTIONS
|
24
26
|
end
|
25
27
|
end
|
26
|
-
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/pot_of_coffee.gemspec
CHANGED
@@ -1,25 +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 = "http://daveshaffer.co/coffee"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.required_ruby_version = ">= 2.6.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
|
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"
|
25
30
|
end
|
@@ -1,49 +1,38 @@
|
|
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
|
7
|
+
it "has correct properties and gives instructions" do
|
6
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
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
|
-
medium: 279.10,
|
39
|
-
mild: 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
|
-
it 'can provide your own units' do
|
35
|
+
it "can provide your own units" do
|
47
36
|
expect(pot_of_coffee.instructions).to eq("Cups desired: 12\nBrew strength: medium\nGrounds needed: 3349.2 gb\n")
|
48
37
|
end
|
49
38
|
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,71 +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.0
|
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: 2020-08-30 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
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: rspec_junit_formatter
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description: This is a small CLI app for calculating the brew strength for an automatic
|
70
98
|
drip coffee maker. It can help keep coffee brews consistent.
|
71
99
|
email:
|
@@ -75,9 +103,12 @@ executables:
|
|
75
103
|
extensions: []
|
76
104
|
extra_rdoc_files: []
|
77
105
|
files:
|
106
|
+
- ".circleci/config.yml"
|
78
107
|
- ".gitignore"
|
79
108
|
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
80
110
|
- Gemfile
|
111
|
+
- Gemfile.lock
|
81
112
|
- LICENSE.txt
|
82
113
|
- README.md
|
83
114
|
- Rakefile
|
@@ -87,8 +118,6 @@ files:
|
|
87
118
|
- lib/pot_of_coffee/brewer.rb
|
88
119
|
- lib/pot_of_coffee/errors.rb
|
89
120
|
- lib/pot_of_coffee/units.rb
|
90
|
-
- lib/pot_of_coffee/units/imperial.rb
|
91
|
-
- lib/pot_of_coffee/units/metric.rb
|
92
121
|
- lib/pot_of_coffee/version.rb
|
93
122
|
- pot_of_coffee.gemspec
|
94
123
|
- spec/pot_of_coffee/brewer_spec.rb
|
@@ -98,7 +127,7 @@ homepage: http://daveshaffer.co/coffee
|
|
98
127
|
licenses:
|
99
128
|
- MIT
|
100
129
|
metadata: {}
|
101
|
-
post_install_message:
|
130
|
+
post_install_message:
|
102
131
|
rdoc_options: []
|
103
132
|
require_paths:
|
104
133
|
- lib
|
@@ -106,16 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
135
|
requirements:
|
107
136
|
- - ">="
|
108
137
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
138
|
+
version: 2.6.0
|
110
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
140
|
requirements:
|
112
141
|
- - ">="
|
113
142
|
- !ruby/object:Gem::Version
|
114
143
|
version: '0'
|
115
144
|
requirements: []
|
116
|
-
|
117
|
-
|
118
|
-
signing_key:
|
145
|
+
rubygems_version: 3.1.4
|
146
|
+
signing_key:
|
119
147
|
specification_version: 4
|
120
148
|
summary: Coffee brew strength calculator
|
121
149
|
test_files:
|