bread_calculator 0.0.0 → 0.0.1

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
2
  SHA1:
3
- metadata.gz: a454bc456276e0bac262c1f2bca15af7fb9c2687
4
- data.tar.gz: 2c7578cc8609953f1391bede4fa2b9ca864013c2
3
+ metadata.gz: a1a94b93c70bcc5cc6d2527d32c73487a40614d2
4
+ data.tar.gz: 614044422ed75b82b707b695e889fd244ca675b6
5
5
  SHA512:
6
- metadata.gz: acce0ad69d786710cb19cccb1f152615e1ba2605ee354d9a825678b4bdbf12a85e2ff967edc9b10529887b34bc2fc800d3212c329716c109014d351e16df7f2e
7
- data.tar.gz: 20fcd4a6426ae2091cfae4b77aa545247258b0669faf8710542500475ee954d67cef348e7af29c7504c7640a5973f37962f5699802da96b84c35621a330f1700
6
+ metadata.gz: 7b0afb98a7cf337b2e1d58e3069c9da30e9ca3b79fd2fb76f54a88b10abd7064a122b79b3b17c067e0424166fd0d199b94623f7a6ae973fc5167e5455f63b10c
7
+ data.tar.gz: b003b87d6afdd589d4e1e026f2262d9ffd0be0fcff4c29d5b894833d9385cf070db9e875dc5d94135f10ec8be4f8f88236a3df8a75f1e26dbe07987b4301ac0b
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  bread-calculator
2
2
  ---------
3
-
4
3
  A ruby gem to calculate baker's percentages
5
4
 
6
5
  Installation
7
6
  ---------
8
-
7
+ gem install bakers_percentage
9
8
 
10
9
  Inspiration and History
11
10
  ---------
@@ -13,10 +12,4 @@ Inspiration and History
13
12
  License
14
13
  ---------
15
14
  © 2014 Noah Birnel
16
- BSD license
17
-
18
-
19
-
20
-
21
-
22
-
15
+ MIT license
data/bin/bread-calc ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bread_calculator'
4
+
5
+ @get = 'r'
6
+ @help = nil
7
+
8
+ def help
9
+ puts <<EOF
10
+ NAME
11
+ bread-calc
12
+ SYNOPSIS
13
+ bread-calc [OPTIONS] FILE
14
+ DESCRIPTION
15
+ bread-calc parses a nearly free-form bread recipe in file FILE. By default
16
+ the canonical representation of the recipe is printed to standard out.
17
+ Optionally, the weight, or bakers percentage formula can be generated, or the
18
+ recipe can by scaled up or down.
19
+ OPTIONS:
20
+ --help
21
+ print this help
22
+ --summary
23
+ print a baker's percentage summary
24
+ --weight
25
+ print the weight
26
+ --scale-by FACTOR
27
+ regenerate the recipe, scaling up or down by FACTOR
28
+ FORMATS
29
+ The recipe format starts with a free-form prelude. Any line starting with a
30
+ hyphen ends the prelude and starts the first step.
31
+
32
+ Each step is delimited by one or more blank lines.
33
+
34
+ Any line in a step starting with a space or a blank is an ingredient,
35
+ consisting of quantity, units, and the ingredient itself. bread-calc will
36
+ attempt to guess at the type of ingredient, but you can always force it by
37
+ including one of the words 'flour', 'liquid', or 'additive' in the line.
38
+ BUGS
39
+ It is cheerfully assumed that all units are grams.
40
+
41
+ Output is rather ugly.
42
+
43
+ It is undefined how 'liquid flour additive' is parsed, but don't expect
44
+ anything good.
45
+ EOF
46
+
47
+ exit
48
+ end
49
+
50
+ loop { case ARGV[0]
51
+ when /--help/ then @help = 'help' ; ARGV.shift; break
52
+ when /--summary/ then @get = 'r.summary'; ARGV.shift; break
53
+ when /--weight/ then @get = 'r.weight'; ARGV.shift; break
54
+ when /--scale-by/ then ARGV.shift; @get = "r.scale_by #{ARGV.shift}"; break
55
+ when /--/ then ARGV.shift; break
56
+ when /^-/ then usage("Unknown option: #{ARGV[0].inspect}")
57
+ else break
58
+ end; }
59
+
60
+ help if @help
61
+
62
+ ARGV.each do |arg|
63
+ parser = BreadCalculator::Parser.new arg
64
+ r = parser.parse(arg)
65
+ puts eval("#{@get}")
66
+ end
@@ -1,15 +1,15 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bread_calculator'
3
- s.version = '0.0.0'
4
- s.date = '2014-02-28'
3
+ s.version = '0.0.1'
4
+ s.date = '2014-03-07'
5
5
  s.summary = "calculate baker's percentages"
6
6
  s.description = "a gem and command-line wrapper to generate baker's
7
7
  percentages from a bread recipe"
8
8
  s.authors = ['Noah Birnel']
9
9
  s.email = 'nbirnel@gmail.com'
10
10
  s.homepage = 'http://github.com/nbirnel/bread-calculator'
11
- s.files = ['README.md', 'bread_calculator.gemspec', 'lib/bread_calculator.rb', 'spec/bread_calculator_spec.rb', 'bin/bread-calculator']
11
+ s.files = ['README.md', 'bread_calculator.gemspec', 'lib/bread_calculator.rb', 'spec/bread_calculator_spec.rb', 'bin/bread-calc']
12
12
  s.has_rdoc = true
13
- s.executables = ['bread-calculator']
14
- s.license = 'DWTFYW'
13
+ s.executables = ['bread-calc']
14
+ s.license = 'MIT'
15
15
  end
@@ -267,9 +267,7 @@ module BreadCalculator
267
267
 
268
268
  #FIXME refactor
269
269
  h[:type] = :additives #if it doesn't match anything else
270
- h[:type] = :flours if ingredient =~ /flour/
271
270
  h[:type] = :flours if ingredient =~ /meal/
272
- h[:type] = :liquids if ingredient =~ /liquid/
273
271
  h[:type] = :liquids if ingredient =~ /water/
274
272
  h[:type] = :liquids if ingredient =~ /egg/
275
273
  h[:type] = :liquids if ingredient =~ /mashed/
@@ -277,6 +275,10 @@ module BreadCalculator
277
275
  h[:type] = :additives if ingredient =~ /dry/
278
276
  h[:type] = :additives if ingredient =~ /powdered/
279
277
 
278
+ h[:type] = :flours if ingredient =~ /flour/
279
+ h[:type] = :liquids if ingredient =~ /liquid/
280
+ h[:type] = :liquids if ingredient =~ /additive/
281
+
280
282
  ing = BreadCalculator::Ingredient.new ingredient, h
281
283
  else
282
284
  line.strip
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bread_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Birnel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-28 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  a gem and command-line wrapper to generate baker's
15
15
  percentages from a bread recipe
16
16
  email: nbirnel@gmail.com
17
17
  executables:
18
- - bread-calculator
18
+ - bread-calc
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
@@ -23,10 +23,10 @@ files:
23
23
  - bread_calculator.gemspec
24
24
  - lib/bread_calculator.rb
25
25
  - spec/bread_calculator_spec.rb
26
- - bin/bread-calculator
26
+ - bin/bread-calc
27
27
  homepage: http://github.com/nbirnel/bread-calculator
28
28
  licenses:
29
- - DWTFYW
29
+ - MIT
30
30
  metadata: {}
31
31
  post_install_message:
32
32
  rdoc_options: []
data/bin/bread-calculator DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bread_calculator'
4
-
5
- @format = 'r'
6
-
7
- loop { case ARGV[0]
8
- when /-summary/ then @format = 'r.summary'; ARGV.shift; break
9
- when /-weight/ then @format = 'r.weight'; ARGV.shift; break
10
- when /-scale-by/ then ARGV.shift; @format = "r.scale_by #{ARGV.shift}"; break
11
- when /--/ then ARGV.shift; break
12
- when /^-/ then usage("Unknown option: #{ARGV[0].inspect}")
13
- else break
14
- end; }
15
-
16
- ARGV.each do |arg|
17
- parser = BreadCalculator::Parser.new arg
18
- r = parser.parse(arg)
19
- puts eval("#{@format}")
20
- end