beerdb-models 0.10.0 → 1.0.0

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: 81cbea581c2fdb972632982aa387c16ad9c8120c
4
- data.tar.gz: 8865a095da2b63a7e11447452226d29af752d8d3
3
+ metadata.gz: fb9be2add651cb418cd11f1fcded05d8bfb4b571
4
+ data.tar.gz: 6f3ea6a6df8dbe92638db7993448693d766edaaf
5
5
  SHA512:
6
- metadata.gz: 541a57ed981411438c18a0e40f9d276c84e9922d3dbe084aec5c4b807ec425e72b502cd5d15598278200fd1e514b8d1574b08094a440a7dad67f69dbf3a650f1
7
- data.tar.gz: e9cc5b27bb0e342ca75e70b052743b5fe23b9b5fff12c77081028476d59fd5d7433f25d6b07273375aae9dc414863ecaa5eebdefdce5501e4bee0f25417ce479
6
+ metadata.gz: fc605a8fdbd6a1b32000da48925e37cdac5efaf60b55fe74e4fc83e3908c5c0efb6e7752003d590e24464c84c82c250e08ce47bf2604631235896b6bcd05d090
7
+ data.tar.gz: 0c87ea1a5a0610f0198b7612319821ea547ab611dc7b5da5f72d97f7477d1841bd63816a12d30b1c8486b4f62e9eeb3db8ee62e4c6a0a8bdd6485b818ae71768
@@ -15,11 +15,16 @@ lib/beerdb/models/world/region.rb
15
15
  lib/beerdb/reader.rb
16
16
  lib/beerdb/reader_file.rb
17
17
  lib/beerdb/reader_zip.rb
18
+ lib/beerdb/readers/beer.rb
19
+ lib/beerdb/readers/brewery.rb
20
+ lib/beerdb/readers/quick.rb
18
21
  lib/beerdb/schema.rb
19
22
  lib/beerdb/serializers/beer.rb
20
23
  lib/beerdb/serializers/brewery.rb
21
24
  lib/beerdb/stats.rb
22
25
  lib/beerdb/version.rb
26
+ test/data/great-beers-europe.txt
23
27
  test/helper.rb
24
28
  test/test_fixture_matchers.rb
29
+ test/test_reader_quick.rb
25
30
  test/test_values.rb
data/README.md CHANGED
@@ -8,8 +8,13 @@
8
8
  * forum :: [groups.google.com/group/beerdb](https://groups.google.com/group/beerdb)
9
9
 
10
10
 
11
+
11
12
  ## Usage Models
12
13
 
14
+ Class Model Diagram
15
+
16
+ ![](beerdb-models.png)
17
+
13
18
  Brewery Model
14
19
 
15
20
  ```
@@ -17,10 +17,14 @@ require 'beerdb/models/beer'
17
17
  require 'beerdb/models/brand'
18
18
  require 'beerdb/models/brewery'
19
19
 
20
-
21
20
  require 'beerdb/serializers/beer'
22
21
  require 'beerdb/serializers/brewery'
23
22
 
23
+ require 'beerdb/readers/beer'
24
+ require 'beerdb/readers/brewery'
25
+ require 'beerdb/readers/quick'
26
+
27
+
24
28
  require 'beerdb/schema'
25
29
  require 'beerdb/reader'
26
30
  require 'beerdb/reader_file'
@@ -112,50 +112,6 @@ class ReaderBase
112
112
  end
113
113
 
114
114
 
115
- def load_beers_worker( name, more_attribs={} )
116
-
117
- reader = create_beers_reader( name, more_attribs ) ### "virtual" method - required by concrete class
118
-
119
- ### todo: cleanup - check if [] works for build_title...
120
- # better cleaner way ???
121
- if more_attribs[:region_id].present?
122
- known_breweries_source = Brewery.where( region_id: more_attribs[:region_id] )
123
- elsif more_attribs[:country_id].present?
124
- known_breweries_source = Brewery.where( country_id: more_attribs[:country_id] )
125
- else
126
- logger.warn "no region or country specified; use empty brewery ary for header mapper"
127
- known_breweries_source = []
128
- end
129
-
130
- known_breweries = TextUtils.build_title_table_for( known_breweries_source )
131
-
132
-
133
- reader.each_line do |new_attributes, values|
134
-
135
- ## note: check for header attrib; if present remove
136
- ### todo: cleanup code later
137
- ## fix: add to new_attributes hash instead of values ary
138
- ## - fix: match_brewery() move region,city code out of values loop for reuse at the end
139
- if new_attributes[:header].present?
140
- brewery_line = new_attributes[:header].dup # note: make sure we make a copy; will use in-place string ops
141
- new_attributes.delete(:header) ## note: do NOT forget to remove from hash!
142
-
143
- logger.debug " trying to find brewery in line >#{brewery_line}<"
144
- ## todo: check what map_titles_for! returns (nothing ???)
145
- TextUtils.map_titles_for!( 'brewery', brewery_line, known_breweries )
146
- brewery_key = TextUtils.find_key_for!( 'brewery', brewery_line )
147
- logger.debug " brewery_key = >#{brewery_key}<"
148
- unless brewery_key.nil?
149
- ## bingo! add brewery_id upfront, that is, as first value in ary
150
- values = values.unshift "by:#{brewery_key}"
151
- end
152
- end
153
-
154
- Beer.create_or_update_from_attribs( new_attributes, values )
155
- end # each_line
156
- end
157
-
158
-
159
115
  def load_breweries_for_country_n_region( country_key, region_key, name, more_attribs={} )
160
116
  country = Country.find_by_key!( country_key )
161
117
  logger.debug "Country #{country.key} >#{country.title} (#{country.code})<"
@@ -188,32 +144,5 @@ class ReaderBase
188
144
  load_breweries_worker( name, more_attribs )
189
145
  end
190
146
 
191
- def load_breweries_worker( name, more_attribs={} )
192
-
193
- if name =~ /\(m\)/ # check for (m) mid-size/medium marker -todo- use $?? must be last?
194
- more_attribs[ :prod_m ] = true
195
- elsif name =~ /\(l\)/ # check for (l) large marker - todo - use $?? must be last?
196
- more_attribs[ :prod_l ] = true
197
- else
198
- ## no marker; do nothing
199
- end
200
-
201
- reader = create_breweries_reader( name, more_attribs ) ### "virtual" method - required by concrete class
202
-
203
- reader.each_line do |new_attributes, values|
204
-
205
- #######
206
- # fix: move to (inside)
207
- # Brewery.create_or_update_from_attribs ||||
208
- ## note: group header not used for now; do NOT forget to remove from hash!
209
- if new_attributes[:header].present?
210
- logger.warn "removing unused group header #{new_attributes[:header]}"
211
- new_attributes.delete(:header) ## note: do NOT forget to remove from hash!
212
- end
213
-
214
- Brewery.create_or_update_from_attribs( new_attributes, values )
215
- end # each_line
216
- end
217
-
218
147
  end # class ReaderBase
219
148
  end # module BeerDb
@@ -25,8 +25,7 @@ class Reader < ReaderBase
25
25
 
26
26
  logger.info "parsing data (beers) '#{name}' (#{path})..."
27
27
 
28
- ValuesReader.from_file( path, more_attribs )
29
- ## ValuesReaderV2.new( name, @include_path, more_attribs )
28
+ BeerReader.from_file( path, more_attribs )
30
29
  end
31
30
 
32
31
  def create_breweries_reader( name, more_attribs={} )
@@ -36,8 +35,15 @@ class Reader < ReaderBase
36
35
 
37
36
  logger.info "parsing data (breweries) '#{name}' (#{path})..."
38
37
 
39
- ValuesReader.from_file( path, more_attribs )
40
- ## ValuesReaderV2.new( name, @include_path, more_attribs )
38
+ if name =~ /\(m\)/ # check for (m) mid-size/medium marker -todo- use $?? must be last?
39
+ more_attribs[ :prod_m ] = true
40
+ elsif name =~ /\(l\)/ # check for (l) large marker - todo - use $?? must be last?
41
+ more_attribs[ :prod_l ] = true
42
+ else
43
+ ## no marker; do nothing
44
+ end
45
+
46
+ BreweryReader.from_file( path, more_attribs )
41
47
  end
42
48
 
43
49
  private
@@ -68,15 +68,24 @@ class ZipReader < ReaderBase
68
68
 
69
69
  logger.debug "parsing data (beers) in zip '#{name}' (#{path})..."
70
70
 
71
- ValuesReader.from_zip( @zip_file, path, more_attribs )
71
+ BeerReader.from_zip( @zip_file, path, more_attribs )
72
72
  end
73
73
 
74
+
74
75
  def create_breweries_reader( name, more_attribs={} )
75
76
  path = name_to_zip_entry_path( name )
76
77
 
77
78
  logger.debug "parsing data (breweries) in zip '#{name}' (#{path})..."
78
79
 
79
- ValuesReader.from_zip( @zip_file, path, more_attribs )
80
+ if name =~ /\(m\)/ # check for (m) mid-size/medium marker -todo- use $?? must be last?
81
+ more_attribs[ :prod_m ] = true
82
+ elsif name =~ /\(l\)/ # check for (l) large marker - todo - use $?? must be last?
83
+ more_attribs[ :prod_l ] = true
84
+ else
85
+ ## no marker; do nothing
86
+ end
87
+
88
+ BreweryReader.from_zip( @zip_file, path, more_attribs )
80
89
  end
81
90
 
82
91
  private
@@ -0,0 +1,86 @@
1
+ # encoding: utf-8
2
+
3
+ module BeerDb
4
+
5
+ class BeerReader
6
+
7
+ include LogUtils::Logging
8
+
9
+ ## make models available by default with namespace
10
+ # e.g. lets you use Usage instead of Model::Usage
11
+ include Models
12
+
13
+ def self.from_zip( zip_file, entry_path, more_attribs={} )
14
+ ## get text content from zip
15
+ entry = zip_file.find_entry( entry_path )
16
+
17
+ text = entry.get_input_stream().read()
18
+ text = text.force_encoding( Encoding::UTF_8 )
19
+
20
+ self.from_string( text, more_attribs )
21
+ end
22
+
23
+ def self.from_file( path, more_attribs={} )
24
+ ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
25
+ ## - see textutils/utils.rb
26
+ text = File.read_utf8( path )
27
+ self.from_string( text, more_attribs )
28
+ end
29
+
30
+ def self.from_string( text, more_attribs={} )
31
+ BeerReader.new( text, more_attribs )
32
+ end
33
+
34
+ def initialize( text, more_attribs={} )
35
+ ## todo/fix: how to add opts={} ???
36
+ @text = text
37
+ @more_attribs = more_attribs
38
+ end
39
+
40
+
41
+ def read()
42
+
43
+ reader = ValuesReader.from_string( @text, @more_attribs )
44
+
45
+ ### todo: cleanup - check if [] works for build_title...
46
+ # better cleaner way ???
47
+ if @more_attribs[:region_id].present?
48
+ known_breweries_source = Brewery.where( region_id: @more_attribs[:region_id] )
49
+ elsif @more_attribs[:country_id].present?
50
+ known_breweries_source = Brewery.where( country_id: @more_attribs[:country_id] )
51
+ else
52
+ logger.warn "no region or country specified; use empty brewery ary for header mapper"
53
+ known_breweries_source = []
54
+ end
55
+
56
+ known_breweries = TextUtils.build_title_table_for( known_breweries_source )
57
+
58
+
59
+ reader.each_line do |new_attributes, values|
60
+
61
+ ## note: check for header attrib; if present remove
62
+ ### todo: cleanup code later
63
+ ## fix: add to new_attributes hash instead of values ary
64
+ ## - fix: match_brewery() move region,city code out of values loop for reuse at the end
65
+ if new_attributes[:header].present?
66
+ brewery_line = new_attributes[:header].dup # note: make sure we make a copy; will use in-place string ops
67
+ new_attributes.delete(:header) ## note: do NOT forget to remove from hash!
68
+
69
+ logger.debug " trying to find brewery in line >#{brewery_line}<"
70
+ ## todo: check what map_titles_for! returns (nothing ???)
71
+ TextUtils.map_titles_for!( 'brewery', brewery_line, known_breweries )
72
+ brewery_key = TextUtils.find_key_for!( 'brewery', brewery_line )
73
+ logger.debug " brewery_key = >#{brewery_key}<"
74
+ unless brewery_key.nil?
75
+ ## bingo! add brewery_id upfront, that is, as first value in ary
76
+ values = values.unshift "by:#{brewery_key}"
77
+ end
78
+ end
79
+
80
+ Beer.create_or_update_from_attribs( new_attributes, values )
81
+ end # each_line
82
+ end
83
+
84
+
85
+ end # class BeerReader
86
+ end # module BeerDb
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ module BeerDb
4
+
5
+ class BreweryReader
6
+
7
+ include LogUtils::Logging
8
+
9
+ ## make models available by default with namespace
10
+ # e.g. lets you use Usage instead of Model::Usage
11
+ include Models
12
+
13
+ def self.from_zip( zip_file, entry_path, more_attribs={} )
14
+ ## get text content from zip
15
+ entry = zip_file.find_entry( entry_path )
16
+
17
+ text = entry.get_input_stream().read()
18
+ text = text.force_encoding( Encoding::UTF_8 )
19
+
20
+ self.from_string( text, more_attribs )
21
+ end
22
+
23
+ def self.from_file( path, more_attribs={} )
24
+ ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
25
+ ## - see textutils/utils.rb
26
+ text = File.read_utf8( path )
27
+ self.from_string( text, more_attribs )
28
+ end
29
+
30
+ def self.from_string( text, more_attribs={} )
31
+ BreweryReader.new( text, more_attribs )
32
+ end
33
+
34
+ def initialize( text, more_attribs={} )
35
+ ## todo/fix: how to add opts={} ???
36
+ @text = text
37
+ @more_attribs = more_attribs
38
+ end
39
+
40
+
41
+
42
+
43
+ def read()
44
+
45
+ =begin
46
+ if name =~ /\(m\)/ # check for (m) mid-size/medium marker -todo- use $?? must be last?
47
+ more_attribs[ :prod_m ] = true
48
+ elsif name =~ /\(l\)/ # check for (l) large marker - todo - use $?? must be last?
49
+ more_attribs[ :prod_l ] = true
50
+ else
51
+ ## no marker; do nothing
52
+ end
53
+ =end
54
+
55
+ reader = ValuesReader.from_string( @text, @more_attribs )
56
+
57
+ reader.each_line do |new_attributes, values|
58
+
59
+ #######
60
+ # fix: move to (inside)
61
+ # Brewery.create_or_update_from_attribs ||||
62
+ ## note: group header not used for now; do NOT forget to remove from hash!
63
+ if new_attributes[:header].present?
64
+ logger.warn "removing unused group header #{new_attributes[:header]}"
65
+ new_attributes.delete(:header) ## note: do NOT forget to remove from hash!
66
+ end
67
+
68
+ Brewery.create_or_update_from_attribs( new_attributes, values )
69
+ end # each_line
70
+ end
71
+
72
+ end # class BreweryReader
73
+ end # module BeerDb
@@ -0,0 +1,127 @@
1
+ # encoding: utf-8
2
+
3
+ #####################################
4
+ # quick (all-in-one-file) reader
5
+ #
6
+ # reads breweries n beers "mixed-up" in a single-file
7
+
8
+
9
+ module BeerDb
10
+
11
+ class QuickReader
12
+
13
+ include LogUtils::Logging
14
+
15
+ ## make models available by default with namespace
16
+ # e.g. lets you use Usage instead of Model::Usage
17
+ include Models
18
+
19
+ def self.from_zip( zip_file, entry_path, more_attribs={} )
20
+ ## get text content from zip
21
+ entry = zip_file.find_entry( entry_path )
22
+
23
+ text = entry.get_input_stream().read()
24
+ text = text.force_encoding( Encoding::UTF_8 )
25
+
26
+ self.from_string( text, more_attribs )
27
+ end
28
+
29
+ def self.from_file( path, more_attribs={} )
30
+ ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
31
+ ## - see textutils/utils.rb
32
+ text = File.read_utf8( path )
33
+ self.from_string( text, more_attribs )
34
+ end
35
+
36
+ def self.from_string( text, more_attribs={} )
37
+ QuickReader.new( text, more_attribs )
38
+ end
39
+
40
+ def initialize( text, more_attribs={} )
41
+ ## todo/fix: how to add opts={} ???
42
+ @text = text
43
+ @more_attribs = more_attribs
44
+ end
45
+
46
+
47
+ def read()
48
+
49
+ ########
50
+ # note:
51
+ # assume meta.format == multiline => brewery
52
+ # == line => beer
53
+
54
+ last_brewery = nil
55
+
56
+ reader = ValuesReader.from_string( @text, @more_attribs )
57
+
58
+ reader.each_line_with_meta do |attributes|
59
+
60
+ ## note: group header not used for now; do NOT forget to remove from hash!
61
+ if attributes[:header].present?
62
+ logger.warn "removing unused group header #{attributes[:header]}"
63
+ attributes.delete(:header) ## note: do NOT forget to remove from hash!
64
+ end
65
+
66
+ if attributes[:meta][:format] == :multiline
67
+ ### assume new brewery
68
+ puts
69
+ puts "new brewery w/ attributes: #{attributes.inspect}"
70
+ else
71
+ ### assume new beer
72
+ puts
73
+ puts "new beer w/ attributes: #{attributes.inspect}"
74
+ end
75
+
76
+ meta = attributes[:meta]
77
+ values = attributes[:values]
78
+
79
+ attributes.delete(:meta)
80
+ attributes.delete(:values)
81
+
82
+ if meta[:format] == :multiline
83
+ ## assume new brewery
84
+ ### check values for worldtree entry w/ › e.g. Hainaut › Belgium
85
+
86
+ worldtree = values.find {|val| val.index('›') }
87
+ if worldtree
88
+ puts " worldtree: #{worldtree}"
89
+ worldtree_ary = worldtree.split( /\s*›\s*/ ) ## note: remove leading n trailing spaces
90
+ pp worldtree_ary
91
+ ## assume last entry is country
92
+ country_name = worldtree_ary[-1]
93
+ puts " country: #{country_name}"
94
+
95
+ country = Country.find_by_name( country_name )
96
+ if country.nil?
97
+ puts " auto-add country #{country_name}"
98
+ ## hack: fix use worldlite to get proper key,code,area,pop etc.
99
+ country = Country.create!( key: country_name[0..2].downcase,
100
+ name: country_name,
101
+ code: country_name[0..2].upcase,
102
+ area: 0,
103
+ pop: 0 )
104
+ end
105
+
106
+ attributes[:country_id] = country.id
107
+
108
+ last_brewery = Brewery.create_or_update_from_attribs( attributes, values )
109
+ else
110
+ puts " worldtree missing (no country etc.) !!!!!"
111
+ exit
112
+ end
113
+ else
114
+ ## assume new beer
115
+ attributes[:brewery_id] = last_brewery.id
116
+ attributes[:country_id] = last_brewery.country_id
117
+
118
+ Beer.create_or_update_from_attribs( attributes, values )
119
+ end
120
+
121
+ end # each_line
122
+ end
123
+
124
+
125
+ end # class QuickReader
126
+ end # module BeerDb
127
+
@@ -8,8 +8,8 @@ class CreateDb < ActiveRecord::Migration
8
8
  def up
9
9
 
10
10
  create_table :beers do |t|
11
- t.string :key, :null => false # import/export key
12
- t.string :title, :null => false
11
+ t.string :key, null: false # import/export key
12
+ t.string :title, null: false
13
13
  t.string :synonyms # comma separated list of synonyms
14
14
 
15
15
  t.string :web # optional url link (e.g. )
@@ -18,17 +18,17 @@ create_table :beers do |t|
18
18
  # t.boolean :bottle, :null => false, :default => false # Flaschenbier
19
19
  # t.boolean :draft, :null => false, :default => false # Fassbier
20
20
  ## todo: check seasonal is it proper english?
21
- t.boolean :seasonal, :null => false, :default => false # all year or just eg. Festbier/Oktoberfest Special
22
- t.boolean :limited, :null => false, :default => false # one year or season only
21
+ t.boolean :seasonal, null: false, default: false # all year or just eg. Festbier/Oktoberfest Special
22
+ t.boolean :limited, null: false, default: false # one year or season only
23
23
  ## todo: add microbrew/brewpub flag?
24
24
  #### t.boolean :brewpub, :null => false, :default => false
25
-
25
+
26
26
  ## add t.boolean :lite flag ??
27
- t.decimal :kcal # kcal/100ml e.g. 45.0 kcal/100ml
27
+ t.decimal :kcal, precision: 10, scale: 2 # kcal/100ml e.g. 45.0 kcal/100ml
28
28
 
29
29
  ## check: why decimal and not float?
30
- t.decimal :abv # Alcohol by volume (abbreviated as ABV, abv, or alc/vol) e.g. 4.9 %
31
- t.decimal :og # malt extract (original gravity) in plato
30
+ t.decimal :abv, precision: 10, scale: 2 # Alcohol by volume (abbreviated as ABV, abv, or alc/vol) e.g. 4.9 %
31
+ t.decimal :og, precision: 10, scale: 2 # malt extract (original gravity) in plato
32
32
  t.integer :srm # color in srm
33
33
  t.integer :ibu # bitterness in ibu
34
34
 
@@ -66,13 +66,13 @@ create_table :beers do |t|
66
66
  # - C-grade /3nd class/ tier3/ / speciality, minor ?
67
67
 
68
68
  # use stars in .txt e.g. # ***/**/*/- => 1/2/3/4
69
- t.integer :grade, :null => false, :default => 4
69
+ t.integer :grade, null: false, default: 4
70
70
 
71
71
  t.string :txt # source ref
72
- t.boolean :txt_auto, :null => false, :default => false # inline? got auto-added?
72
+ t.boolean :txt_auto, null: false, default: false # inline? got auto-added?
73
73
 
74
74
 
75
- t.references :country, :null => false
75
+ t.references :country, null: false
76
76
  t.references :region # optional
77
77
  t.references :city # optional
78
78
 
@@ -81,33 +81,33 @@ end
81
81
 
82
82
 
83
83
  create_table :brands do |t| # beer families (sharing same name e.g. brand)
84
- t.string :key, :null => false # import/export key
85
- t.string :title, :null => false
84
+ t.string :key, null: false # import/export key
85
+ t.string :title, null: false
86
86
  t.string :synonyms # comma separated list of synonyms
87
87
  t.string :web # optional web page (e.g. www.ottakringer.at)
88
88
  t.string :wiki # optional wiki(pedia page)
89
89
  t.integer :since
90
90
 
91
91
  ## scope of brand (global/intern'l/national/regional/local) ??
92
- t.boolean :global, :null => false, :default => false
93
- t.boolean :internl, :null => false, :default => false
94
- t.boolean :national, :null => false, :default => false
95
- t.boolean :regional, :null => false, :default => false
96
- t.boolean :local, :null => false, :default => false
92
+ t.boolean :global, null: false, default: false
93
+ t.boolean :internl, null: false, default: false
94
+ t.boolean :national, null: false, default: false
95
+ t.boolean :regional, null: false, default: false
96
+ t.boolean :local, null: false, default: false
97
97
 
98
98
  # t.integer :brand_grade # 1/2/3/4/5 (global/intern'l/national/regional/local)
99
99
 
100
100
  # use stars in .txt e.g. # ***/**/*/- => 1/2/3/4
101
- t.integer :grade, :null => false, :default => 4
101
+ t.integer :grade, null: false, default: 4
102
102
  # -- todo: add plus 1 for brewery w/ *** ??
103
103
 
104
104
  t.string :txt # source ref
105
- t.boolean :txt_auto, :null => false, :default => false # inline? got auto-added?
105
+ t.boolean :txt_auto, null: false, default: false # inline? got auto-added?
106
106
 
107
107
 
108
108
  t.references :brewery # optional (for now)
109
109
 
110
- t.references :country, :null => false
110
+ t.references :country, null: false
111
111
  t.references :region # optional
112
112
  t.references :city # optional
113
113
 
@@ -115,8 +115,8 @@ create_table :brands do |t| # beer families (sharing same name e.g. brand)
115
115
  end
116
116
 
117
117
  create_table :breweries do |t|
118
- t.string :key, :null => false # import/export key
119
- t.string :title, :null => false
118
+ t.string :key, null: false # import/export key
119
+ t.string :title, null: false
120
120
  t.string :synonyms # comma separated list of synonyms
121
121
  t.string :address
122
122
  t.integer :since
@@ -129,10 +129,10 @@ create_table :breweries do |t|
129
129
 
130
130
  ## todo: add optional parent brewery (owned_by) ???
131
131
 
132
- t.boolean :brewpub, :null => false, :default => false
133
- t.boolean :prod_m, :null => false, :default => false # prod medium (mid-size/regional brewery)
132
+ t.boolean :brewpub, null: false, default: false
133
+ t.boolean :prod_m, null: false, default: false # prod medium (mid-size/regional brewery)
134
134
  # e.g. > 15_000 barrels (us)
135
- t.boolean :prod_l, :null => false, :default => false # prod large
135
+ t.boolean :prod_l, null: false, default: false # prod large
136
136
  # e.g. > 500_000 hl (at), > 6_000_000 barrels (us)
137
137
 
138
138
  t.integer :prod # (estimated) annual production/capacity in hl (1hl=100l) e.g. megabrewery 2_000_000, microbrewery 1_000 hl; brewbup 500 hl etc.
@@ -153,11 +153,11 @@ create_table :breweries do |t|
153
153
 
154
154
 
155
155
  # use stars in .txt e.g. # ***/**/*/- => 1/2/3/4
156
- t.integer :grade, :null => false, :default => 4
156
+ t.integer :grade, null: false, default: 4
157
157
 
158
158
 
159
159
  t.string :txt # source ref
160
- t.boolean :txt_auto, :null => false, :default => false # inline? got auto-added?
160
+ t.boolean :txt_auto, null: false, default: false # inline? got auto-added?
161
161
 
162
162
  t.string :web # optional web page (e.g. www.ottakringer.at)
163
163
  t.string :wikipedia # optional wiki(pedia page)
@@ -176,7 +176,7 @@ create_table :breweries do |t|
176
176
  # todo: add t.references :parent # for parent brewery
177
177
  # (or better use has many parents w/ percentage of ownership; might not be 100%)
178
178
 
179
- t.references :country, :null => false
179
+ t.references :country, null: false
180
180
  t.references :region # optional
181
181
  t.references :city # optional
182
182
 
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module BeerDb
4
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5
- MINOR = 10
4
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
5
+ MINOR = 0
6
6
  PATCH = 0
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
@@ -0,0 +1,155 @@
1
+ ###############################
2
+ # Great Beers from Europe
3
+
4
+
5
+ [Aass Bryggeri]
6
+ Ole Steens Gate 10 // 3007 Drammen
7
+ Buskerud › Østlandet › Norway
8
+ www.aass.no
9
+
10
+ # Norways's oldest brewery, 1834
11
+ # Bryggeri -- is norwegian for brewery
12
+ # Østlandet -- is norwegian for eastern norway (region)
13
+
14
+ Aass Bock, 6.5%, dunkler_bock
15
+ Aass Juleøl, 6.2%, dunkler_bock
16
+
17
+
18
+ [Abbaye des Rocs] ## Brasserie des Rocs (formerly known as Brasserie de l'Abbaye des Rocs
19
+ Chaussée Brunehault 37 // 7387 Montignies-sur-Roc
20
+ Hainaut › Wallonie › Belgium
21
+ www.abbaye-des-rocs.com
22
+
23
+ Blanche des Honnelles, 6%, belgian_witbier
24
+ Abbaye des Rocs Brune, 9%, dunkles_starkbier
25
+
26
+
27
+ [Achelse Kluis]
28
+ De Kluis 1 // De Sint-Benedictusabdij // 3930 Hamont-Achel
29
+ Limburg › Vlaanderen › Belgium
30
+ www.achelsekluis.org
31
+
32
+ # De Sint-Benedictusabdij -- in dutch is Saint-Benedictus Abbey
33
+
34
+ Achel 8 Bruin, 8%, trappist
35
+ Achel Extra Bruin, 9.5%, trappist
36
+
37
+
38
+ [Airbräu]
39
+ Terminalstraße Mitte 18 // München Airport Center // 85356 München
40
+ Oberbayern › Bayern › Germany
41
+ www.airbraeu.de
42
+
43
+ Fliegerquell (Helles), 5.2%, lager|unfiltriert
44
+ Kumulus (Weißbier), 5.4%, weissbier
45
+
46
+
47
+ [Aktienbrauerei] ## Aktienbrauerei Kaufbeuren (ABK)
48
+ Hohe Buchleuthe 3 // 87600 Kaufbeuren
49
+ Schwaben › Bayern › Germany
50
+ www.aktienbrauerei.de
51
+
52
+ Kellerbier Naturtrüb, 5.1%, kellerbier
53
+ Fendt Dieselrossöl, 5.9%, maerzen
54
+
55
+
56
+ [A. Le Coq]
57
+ Laulupeo Pst 15 // 50050 Tartu
58
+ Tartu › Estonia
59
+ www.alecoq.ee
60
+
61
+ A. Le Coq Porter, 6.5%, porter
62
+ A. Le Coq Double Bock, 7%, bock
63
+
64
+
65
+ [Alhambra]
66
+ Avenida de Murcia 1 // 18012 Granada
67
+ www.cervezasalhambra.es
68
+ Andalucía › Spain
69
+
70
+ Alhambra Premium Lager, 4.6%, lager
71
+ Mezquita, 7.2%, weizenbier
72
+
73
+
74
+ [Allersheim]
75
+ Allersheim 6 // 37603 Holzminden
76
+ Niedersachsen › Germany
77
+ www.brauerei-allersheim.de
78
+
79
+ Allersheimer Landbier, 5%, pilsner
80
+ ## Allersheimer Blue Moon, 1.9%, colabiermix ## Cola-Bier-Mix
81
+
82
+
83
+ [Almond 22] ## Birra Almond '22
84
+ Contrada Remartello 47/H // 65014 Loreto Aprutino
85
+ www.birraalmond.com
86
+ Pescara › Abruzzo › Italy
87
+
88
+ ## old address (until 2014?): Via Colle di Mezzo 25 // 65010 Spoltore
89
+
90
+ Torbata, 8.7%, barleywine
91
+ Farrotta, 5.7%, dinkelbier
92
+
93
+
94
+ [Alpirsbach] ## Alpirsbacher Klosterbräu
95
+ Marktplatz 1 // 72275 Alpirsbach
96
+ Baden-Württemberg › Germany
97
+ www.alpirsbacher.de
98
+
99
+ Alpirsbacher Klosterbräu Kleiner Mönch, 5.2%, lager
100
+ Alpirsbacher Klosterbräu Schwarzes Pils, 4.9%, pilsner ## note: no longer available
101
+
102
+
103
+ [Altöttinger] ## Altöttinger Hell-Bräu
104
+ Herrenmühlstraße 15 // 84503 Altötting
105
+ Oberbayern › Bayern › Germany
106
+ www.hellbraeu.de
107
+
108
+ Altöttinger Bayrisch Dunkel, 5.2%, dunkel
109
+ Altöttinger Fein-Herb, 5%, lager
110
+
111
+
112
+ [Amber] ## Browar Amber
113
+ Bielkówko // ul. Gregorkiewicza 1 // 83-050 Kolbudy
114
+ Gdańsk › Pomorskie [Pomeranian] › Poland
115
+ www.browar-amber.pl
116
+
117
+ Koźlak, 6.5%, dunkler_bock
118
+ Żywe, 6.2%, pilsner
119
+
120
+
121
+ [Andechs] ## Klosterbrauerei Andechs
122
+ Bergstr. 2 // 82346 Andechs
123
+ Oberbayern › Bayern › Germany
124
+ www.andechs.de
125
+
126
+ Andechser Bergbock Hell, 7%, bock
127
+ Andechser Doppelbock Dunkel, 7%, dunkler_bock
128
+
129
+
130
+ [Anker] ## Brouwerij Het Anker
131
+ Guido Gezellelaan 49 // 2800 Mechelen
132
+ Antwerpen › Vlaanderen › Belgium
133
+ www.hetanker.be
134
+
135
+ Gouden Carolus Classic, 8.5%, strong_dark_ale
136
+ Gouden Carolus Christmas, 10.5%, strong_dark_ale
137
+
138
+
139
+ [Ankerbrauerei Nördlingen] ## Ankerbräu
140
+ Ankergasse 4 // 86720 Nördlingen
141
+ www.ankerbrauerei.de
142
+ Schwaben › Bayern › Germany
143
+
144
+ Ankerbräu Lager Hell, 5%, lager
145
+ Nördlinger Premium Pils, 4.7%, pilsner
146
+
147
+
148
+ [Apatinska Pivara]
149
+ Trg oslobodjenja 5 // 25260 Apatin
150
+ www.jelenpivo.com
151
+ West Bačka › Vojvodina › Serbia
152
+
153
+ Jelen Pivo, 5%, lager
154
+ Apatinsko Pivo, 5%, lager
155
+
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_reader_quick.rb
6
+ # or better
7
+ # rake test
8
+
9
+ require 'helper'
10
+
11
+
12
+ class TestReaderQuick < MiniTest::Test
13
+
14
+ def setup
15
+ # delete all beers, brands, breweries in in-memory only db
16
+ BeerDb.delete!
17
+ end
18
+
19
+ def test_reader
20
+
21
+ reader = BeerDb::QuickReader.from_file( "#{BeerDb.root}/test/data/great-beers-europe.txt")
22
+ reader.read()
23
+
24
+ assert true
25
+ end
26
+
27
+ end # class TestReaderQuick
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beerdb-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-07 00:00:00.000000000 Z
11
+ date: 2015-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: worlddb-models
@@ -79,13 +79,18 @@ files:
79
79
  - lib/beerdb/reader.rb
80
80
  - lib/beerdb/reader_file.rb
81
81
  - lib/beerdb/reader_zip.rb
82
+ - lib/beerdb/readers/beer.rb
83
+ - lib/beerdb/readers/brewery.rb
84
+ - lib/beerdb/readers/quick.rb
82
85
  - lib/beerdb/schema.rb
83
86
  - lib/beerdb/serializers/beer.rb
84
87
  - lib/beerdb/serializers/brewery.rb
85
88
  - lib/beerdb/stats.rb
86
89
  - lib/beerdb/version.rb
90
+ - test/data/great-beers-europe.txt
87
91
  - test/helper.rb
88
92
  - test/test_fixture_matchers.rb
93
+ - test/test_reader_quick.rb
89
94
  - test/test_values.rb
90
95
  homepage: https://github.com/beerkit/beer.db.models
91
96
  licenses:
@@ -115,4 +120,5 @@ specification_version: 4
115
120
  summary: beerdb-models - beer.db schema 'n' models for easy (re)use
116
121
  test_files:
117
122
  - test/test_values.rb
123
+ - test/test_reader_quick.rb
118
124
  - test/test_fixture_matchers.rb