pot_of_coffee 0.1.0 → 0.4.0

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
- SHA1:
3
- metadata.gz: 59a334e469e37a0e133e778526d8a8b38ef395da
4
- data.tar.gz: 461e37e68c299d442826130f84d1079f9577184c
2
+ SHA256:
3
+ metadata.gz: 0f76f3500acf845dc3d764c0ca309465cf863190353538bfa9b5fd7f4c73f7a3
4
+ data.tar.gz: dc9203c6694d4b3b1cc80084be5041ccbdf61d792b2c3c2b5a49b4cc4f4e6b1b
5
5
  SHA512:
6
- metadata.gz: 84cb6d8a8e2a5559369f59d06a4b92c9d804f3219bcc117c8c89d8cec5aac4acfba105f7a251dc28aa86cb83ce2b471e7b033d2625be205169086f06af66821f
7
- data.tar.gz: c89fe94927ddce0d9604b44a427dc45be34c10c4dcaa521760e5b86dd75e2caadee92291822ad65b1854a6d0d4f43512d935ef4ff66df0d6768b1bed2e466640
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
@@ -1,14 +1,14 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
- /spec/reports/
7
+ /spec/examples.txt
9
8
  /tmp/
10
9
  *.bundle
11
10
  *.so
12
11
  *.o
13
12
  *.a
14
13
  mkmf.log
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -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
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in pot_of_coffee.gemspec
4
6
  gemspec
@@ -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
@@ -1,13 +1,17 @@
1
1
  # PotOfCoffee
2
2
 
3
- This is a command line coffee brew calculator. Enter the number of cups you want and the strength. I use it to maintain intra-office harmony.
3
+ This is a command line coffee brew calculator.
4
+ Enter the number of cups you want and the strength.
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
+ I use it to maintain intra-office harmony.
7
+ Imperial and metric units are provided.
4
8
 
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
8
12
 
9
13
  ```ruby
10
- gem 'pot_of_coffee'
14
+ gem "pot_of_coffee"
11
15
  ```
12
16
 
13
17
  And then execute:
@@ -21,25 +25,106 @@ Or install it yourself as:
21
25
  ## Usage
22
26
 
23
27
  ### CLI
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
+
48
+ ```
49
+
50
+ ### Ruby
51
+
24
52
  ```ruby
25
- pot_of_coffee 12 normal # "Number of scoops needed: 8.1"
26
- pot_of_coffee 12 blagg # "I don't know how to make 'blagg' strength coffee, sorry. Available options are weak, normal, extra, turbo, starbucks, wtf"
53
+ require "pot_of_coffee"
54
+
55
+ pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 12, strength: "mild")
56
+ pot_of_coffee.amount # 6.0
57
+ pot_of_coffee.instructions
58
+ #=> Cups desired: 12
59
+ #=> Brew strength: mild
60
+ #=> Grounds needed: 6.0 tbsp
61
+
62
+
63
+ # Metric units
64
+
65
+ pot_of_coffee = PotOfCoffee::Brewer.new(units: PotOfCoffee::Units::Metric)
66
+ pot_of_coffee.amount # 63.6
67
+ pot_of_coffee.instructions
68
+ #=> Cups desired: 12
69
+ #=> Brew strength: medium
70
+ #=> Grounds needed: 63.6 g
27
71
  ```
28
72
 
29
- ### Rails
73
+ ## Using your own units
74
+ You can use a different set of units or different ratios if you want.
75
+ Just supply an object that responds to `name`, `abbreviation`, and `table`.
76
+ `name` and `abbreviation` must be strings.
77
+ `name` is not used at the moment, but it may be in the future.
78
+ `table` must be a hash.
79
+ I chose to provide three keys: `:strong`, `:medium`, and `:mild`, but you can use whatever you'd like.
80
+
81
+ ### Example
82
+
30
83
  ```ruby
31
- pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 12, strength: 'weak')
32
- pot_of_coffee.scoops # 6.0
84
+ require "pot_of_coffee"
85
+
86
+ class CorgeUnit
87
+ def name
88
+ "corge"
89
+ end
90
+
91
+ def abbreviation
92
+ "cg"
93
+ end
94
+
95
+ def table
96
+ {
97
+ strong: 3900,
98
+ medium: 200,
99
+ mild: 100
100
+ }
101
+ end
102
+ end
103
+
104
+ pot_of_coffee = PotOfCoffee::Brewer.new(quantity: 3, strength: :mild, units: CorgeUnit.new)
105
+ pot_of_coffee.amount # 300
33
106
  ```
34
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
+
35
117
  ## Tests
36
118
 
37
- Clone the repo and run `rake test`. The test coverage is *very basic*.
119
+ * Fork/clone the repo
120
+ * `bundle install`
121
+ * `bundle exec rspec`
122
+ * `bundle exec rubocop`
38
123
 
39
124
  ## Contributing
40
125
 
41
126
  1. Fork it ( https://github.com/[my-github-username]/pot_of_coffee/fork )
42
127
  2. Create your feature branch (`git checkout -b my-new-feature`)
43
- 3. Commit your changes (`git commit -am 'Add some feature'`)
128
+ 3. Commit your changes (`git commit -am "Add some feature"`)
44
129
  4. Push to the branch (`git push origin my-new-feature`)
45
130
  5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
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 << 'test'
6
- t.test_files = FileList['test/test_*.rb']
7
+ t.libs << "test"
8
+ t.test_files = FileList["test/test_*.rb"]
7
9
  t.verbose = true
8
10
  end
9
11
 
10
- desc 'Run tests'
12
+ desc "Run tests"
11
13
  task :default => :test
@@ -0,0 +1,7 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require "pry"
4
+ require "bundler/setup"
5
+ require "pot_of_coffee"
6
+
7
+ Pry.start
@@ -1,15 +1,42 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require 'pot_of_coffee'
3
+ require "optparse"
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: :medium,
9
+ units: PotOfCoffee::Units::Imperial
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
- puts pot_of_coffee.instructions
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 (medium, strong, mild)") 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::Units::Metric
27
+ when "imperial"
28
+ PotOfCoffee::Units::Imperial
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)
42
+ puts pot_of_coffee.instructions
@@ -1,45 +1,8 @@
1
- require 'pot_of_coffee/version'
2
- require 'pot_of_coffee/units'
3
- require 'pot_of_coffee/errors'
4
- require 'forwardable'
1
+ # frozen_string_literal: true
5
2
 
6
3
  module PotOfCoffee
7
- class Brewer
8
- extend Forwardable
9
- attr_reader :units
10
-
11
- def_delegator :@units, :table, :ratios
12
-
13
- def initialize(args = {})
14
- @quantity = args[:quantity] || 12
15
- @strength = args[:strength] || :normal
16
- @units = args[:units] || ImperialUnit.new
17
- end
18
-
19
- def quantity
20
- if @quantity > 0
21
- @quantity
22
- else
23
- raise NegativeNumberError
24
- end
25
- end
26
-
27
- def strength
28
- if ratios.include?(@strength.to_sym)
29
- @strength
30
- else
31
- raise WrongStrengthError
32
- end
33
- end
34
-
35
- def amount
36
- (quantity * ratios.fetch(strength)).round(2)
37
- end
38
-
39
- def instructions
40
- "To make #{quantity} cups of of #{strength} coffee, use #{amount} #{units.abbreviation} of grounds."
41
- rescue NegativeNumberError, WrongStrengthError => e
42
- print e.message
43
- end
44
- end
45
- 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
@@ -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
@@ -1,16 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PotOfCoffee
2
- class CoffeeError < StandardError
3
- end
4
+ module Errors
5
+ class Error < StandardError
6
+ end
4
7
 
5
- class NegativeNumberError < CoffeeError
6
- def message
7
- 'Sorry: coffee quantity must be greater than 0'
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
- class WrongStrengthError < CoffeeError
12
- def message
13
- 'Sorry: coffee strength must be strong, normal, or weak'
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
@@ -1,43 +1,10 @@
1
- module PotOfCoffee
2
- class Unit
3
- def name; raise NotImplementedError; end
4
- def abbreviation; raise NotImplementedError; end
5
- def table; raise NotImplementedError; end
6
- end
7
-
8
- class ImperialUnit < Unit
9
- def name
10
- 'tablespoon'
11
- end
12
-
13
- def abbreviation
14
- 'tbsp'
15
- end
1
+ # frozen_string_literal: true
16
2
 
17
- def table
18
- {
19
- weak: 0.5,
20
- normal: 0.675,
21
- strong: 0.875,
22
- }
23
- end
24
- end
25
-
26
- class MetricUnit < Unit
27
- def name
28
- 'gram'
29
- end
30
-
31
- def abbreviation
32
- 'g'
33
- end
3
+ module PotOfCoffee
4
+ module Units
5
+ Unit = Struct.new(:name, :abbreviation, :table)
34
6
 
35
- def table
36
- {
37
- weak: 12,
38
- normal: 20,
39
- strong: 28,
40
- }
41
- end
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 })
42
9
  end
43
- end
10
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PotOfCoffee
2
- VERSION = '0.1.0'
4
+ VERSION = "0.4.0"
3
5
  end
@@ -1,24 +1,30 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 'pot_of_coffee/version'
5
+ require "pot_of_coffee/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "pot_of_coffee"
8
9
  spec.version = PotOfCoffee::VERSION
9
10
  spec.authors = ["Dave Shaffer"]
10
11
  spec.email = ["dave.shaffer@gmail.com"]
11
- spec.summary = %q{Coffee brew strength calculator}
12
- spec.description = %q{This is a small CLI app for calculating the brew strength for an automatic drip coffee maker. It can help keep coffee brews consistent.}
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."
13
14
  spec.homepage = "http://daveshaffer.co/coffee"
14
15
  spec.license = "MIT"
15
16
 
17
+ spec.required_ruby_version = ">= 2.6.0"
18
+
16
19
  spec.files = `git ls-files -z`.split("\x0")
17
20
  spec.executables = ["pot_of_coffee"]
18
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
22
  spec.require_paths = ["lib"]
20
23
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "minitest"
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
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe PotOfCoffee::Brewer do
4
+ context "with no arguments" do
5
+ let(:pot_of_coffee) { PotOfCoffee::Brewer.new }
6
+
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")
9
+ expect(pot_of_coffee.quantity).to eq(12)
10
+ expect(pot_of_coffee.strength).to eq(:medium)
11
+ end
12
+ end
13
+
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)
17
+ end
18
+ end
19
+
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)
23
+ end
24
+ end
25
+
26
+
27
+ context "with own units" do
28
+ let(:pot_of_coffee) { PotOfCoffee::Brewer.new(units: Whatever) }
29
+
30
+ before do
31
+ whatever = PotOfCoffee::Units::Unit.new("grably", "gb", { strong: 109109, medium: 279.10, mild: 100 })
32
+ stub_const("Whatever", whatever)
33
+ end
34
+
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")
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples "a correct unit" do
4
+ describe "#name" do
5
+ subject { units.name }
6
+ it { is_expected.to be_a(String) }
7
+ end
8
+
9
+ describe "#abbreviation" do
10
+ subject { units.abbreviation }
11
+ it { is_expected.to be_a(String) }
12
+ end
13
+
14
+ describe "#table" do
15
+ subject { units.table }
16
+ it { is_expected.to(satisfy { |t| %i[weak medium strong].each { |key| t.keys.include?(key) } }) }
17
+ end
18
+ end
19
+
20
+ RSpec.describe PotOfCoffee::Units do
21
+ describe "Imperial" do
22
+ let(:units) { PotOfCoffee::Units::Imperial }
23
+
24
+ it_behaves_like "a correct unit"
25
+ end
26
+
27
+ describe "Metric" do
28
+ let(:units) { PotOfCoffee::Units::Metric }
29
+
30
+ it_behaves_like "a correct unit"
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pot_of_coffee"
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with :rspec do |expectations|
7
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
8
+ end
9
+
10
+ config.mock_with :rspec do |mocks|
11
+ mocks.verify_partial_doubles = true
12
+ end
13
+
14
+ config.shared_context_metadata_behavior = :apply_to_host_groups
15
+ config.filter_run_when_matching :focus
16
+ config.example_status_persistence_file_path = "spec/examples.txt"
17
+ config.disable_monkey_patching!
18
+ config.warnings = true
19
+ if config.files_to_run.one?
20
+ config.default_formatter = "doc"
21
+ end
22
+
23
+ config.order = :random
24
+ Kernel.srand config.seed
25
+ end
metadata CHANGED
@@ -1,45 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pot_of_coffee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.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: 2016-02-05 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '1.7'
33
+ version: '0'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - "~>"
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: '1.7'
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
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
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
+ - - ">="
32
74
  - !ruby/object:Gem::Version
33
- version: '10.0'
75
+ version: '0'
34
76
  type: :development
35
77
  prerelease: false
36
78
  version_requirements: !ruby/object:Gem::Requirement
37
79
  requirements:
38
- - - "~>"
80
+ - - ">="
39
81
  - !ruby/object:Gem::Version
40
- version: '10.0'
82
+ version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
- name: minitest
84
+ name: rubocop
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - ">="
@@ -61,26 +103,31 @@ executables:
61
103
  extensions: []
62
104
  extra_rdoc_files: []
63
105
  files:
106
+ - ".circleci/config.yml"
64
107
  - ".gitignore"
108
+ - ".rspec"
109
+ - ".rubocop.yml"
65
110
  - Gemfile
111
+ - Gemfile.lock
66
112
  - LICENSE.txt
67
113
  - README.md
68
114
  - Rakefile
115
+ - bin/console
69
116
  - bin/pot_of_coffee
70
117
  - lib/pot_of_coffee.rb
118
+ - lib/pot_of_coffee/brewer.rb
71
119
  - lib/pot_of_coffee/errors.rb
72
120
  - lib/pot_of_coffee/units.rb
73
121
  - lib/pot_of_coffee/version.rb
74
122
  - pot_of_coffee.gemspec
75
- - test/helper.rb
76
- - test/test_brewer.rb
77
- - test/test_units.rb
78
- - test/whatever_unit.rb
123
+ - spec/pot_of_coffee/brewer_spec.rb
124
+ - spec/pot_of_coffee/units_spec.rb
125
+ - spec/spec_helper.rb
79
126
  homepage: http://daveshaffer.co/coffee
80
127
  licenses:
81
128
  - MIT
82
129
  metadata: {}
83
- post_install_message:
130
+ post_install_message:
84
131
  rdoc_options: []
85
132
  require_paths:
86
133
  - lib
@@ -88,20 +135,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
135
  requirements:
89
136
  - - ">="
90
137
  - !ruby/object:Gem::Version
91
- version: '0'
138
+ version: 2.6.0
92
139
  required_rubygems_version: !ruby/object:Gem::Requirement
93
140
  requirements:
94
141
  - - ">="
95
142
  - !ruby/object:Gem::Version
96
143
  version: '0'
97
144
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.4.5.1
100
- signing_key:
145
+ rubygems_version: 3.1.4
146
+ signing_key:
101
147
  specification_version: 4
102
148
  summary: Coffee brew strength calculator
103
149
  test_files:
104
- - test/helper.rb
105
- - test/test_brewer.rb
106
- - test/test_units.rb
107
- - test/whatever_unit.rb
150
+ - spec/pot_of_coffee/brewer_spec.rb
151
+ - spec/pot_of_coffee/units_spec.rb
152
+ - spec/spec_helper.rb
@@ -1,3 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minitest/pride'
3
- require 'pot_of_coffee'
@@ -1,28 +0,0 @@
1
- require 'helper'
2
-
3
- class TestBrewer < Minitest::Test
4
- def test_gives_instructions_with_no_arguments
5
- @pot_of_coffee = PotOfCoffee::Brewer.new
6
- assert_equal @pot_of_coffee.instructions, "To make 12 cups of of normal coffee, use 8.1 tbsp of grounds."
7
- end
8
-
9
- def test_has_correct_properties_when_created_with_no_arguments
10
- @pot_of_coffee = PotOfCoffee::Brewer.new
11
- assert_equal @pot_of_coffee.quantity, 12
12
- assert_equal @pot_of_coffee.strength, :normal
13
- end
14
-
15
- def test_quantity_must_be_positive
16
- @pot_of_coffee = PotOfCoffee::Brewer.new(quantity: -1)
17
- assert_raises PotOfCoffee::NegativeNumberError do
18
- @pot_of_coffee.quantity
19
- end
20
- end
21
-
22
- def test_strength_must_be_strong_normal_or_weak
23
- @pot_of_coffee = PotOfCoffee::Brewer.new(quantity: rand(24), strength: :ultra)
24
- assert_raises PotOfCoffee::WrongStrengthError do
25
- @pot_of_coffee.strength
26
- end
27
- end
28
- end
@@ -1,21 +0,0 @@
1
- require 'helper'
2
- require 'whatever_unit'
3
-
4
- class TestUnits < Minitest::Test
5
- def test_can_use_metric_units
6
- @pot_of_coffee = PotOfCoffee::Brewer.new(units: PotOfCoffee::MetricUnit.new)
7
- assert_equal @pot_of_coffee.instructions, 'To make 12 cups of of normal coffee, use 240.0 g of grounds.'
8
- end
9
-
10
- def test_can_provide_your_own_units
11
- @pot_of_coffee = PotOfCoffee::Brewer.new(units: WhateverUnit.new)
12
- assert_equal @pot_of_coffee.instructions, 'To make 12 cups of of normal coffee, use 3349.2 gb of grounds.'
13
- end
14
-
15
- def test_units_must_respond_to_correct_things
16
- @whatever_unit = WhateverUnit.new
17
- assert_respond_to @whatever_unit, :name
18
- assert_respond_to @whatever_unit, :abbreviation
19
- assert_respond_to @whatever_unit, :table
20
- end
21
- end
@@ -1,17 +0,0 @@
1
- class WhateverUnit
2
- def name
3
- 'grably'
4
- end
5
-
6
- def abbreviation
7
- 'gb'
8
- end
9
-
10
- def table
11
- {
12
- strong: 109109,
13
- normal: 279.10,
14
- weak: 100
15
- }
16
- end
17
- end