beerdb 0.9.13 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,159 +1,124 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beerdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.13
5
- prerelease:
4
+ version: 0.10.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gerald Bauer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-11-09 00:00:00.000000000 Z
11
+ date: 2014-12-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: props
16
- requirement: &82424030 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: beerdb-models
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 0.10.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *82424030
25
- - !ruby/object:Gem::Dependency
26
- name: logutils
27
- requirement: &82423660 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - ! '>='
24
+ - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *82423660
26
+ version: 0.10.0
36
27
  - !ruby/object:Gem::Dependency
37
- name: textutils
38
- requirement: &82746400 !ruby/object:Gem::Requirement
39
- none: false
28
+ name: datafile
29
+ requirement: !ruby/object:Gem::Requirement
40
30
  requirements:
41
- - - ! '>='
31
+ - - ">="
42
32
  - !ruby/object:Gem::Version
43
- version: '0'
33
+ version: 0.1.1
44
34
  type: :runtime
45
35
  prerelease: false
46
- version_requirements: *82746400
47
- - !ruby/object:Gem::Dependency
48
- name: worlddb
49
- requirement: &82746080 !ruby/object:Gem::Requirement
50
- none: false
36
+ version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ! '>='
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: 2.0.2
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: *82746080
40
+ version: 0.1.1
58
41
  - !ruby/object:Gem::Dependency
59
- name: tagutils
60
- requirement: &82745850 !ruby/object:Gem::Requirement
61
- none: false
42
+ name: fetcher
43
+ requirement: !ruby/object:Gem::Requirement
62
44
  requirements:
63
- - - ! '>='
45
+ - - ">="
64
46
  - !ruby/object:Gem::Version
65
- version: '0'
47
+ version: 0.4.4
66
48
  type: :runtime
67
49
  prerelease: false
68
- version_requirements: *82745850
69
- - !ruby/object:Gem::Dependency
70
- name: activerecord-utils
71
- requirement: &82745500 !ruby/object:Gem::Requirement
72
- none: false
50
+ version_requirements: !ruby/object:Gem::Requirement
73
51
  requirements:
74
- - - ! '>='
52
+ - - ">="
75
53
  - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: *82745500
54
+ version: 0.4.4
80
55
  - !ruby/object:Gem::Dependency
81
- name: fetcher
82
- requirement: &82745060 !ruby/object:Gem::Requirement
83
- none: false
56
+ name: gli
57
+ requirement: !ruby/object:Gem::Requirement
84
58
  requirements:
85
- - - ! '>='
59
+ - - ">="
86
60
  - !ruby/object:Gem::Version
87
- version: '0.3'
61
+ version: 2.12.2
88
62
  type: :runtime
89
63
  prerelease: false
90
- version_requirements: *82745060
91
- - !ruby/object:Gem::Dependency
92
- name: gli
93
- requirement: &82744620 !ruby/object:Gem::Requirement
94
- none: false
64
+ version_requirements: !ruby/object:Gem::Requirement
95
65
  requirements:
96
- - - ! '>='
66
+ - - ">="
97
67
  - !ruby/object:Gem::Version
98
- version: 2.5.6
99
- type: :runtime
100
- prerelease: false
101
- version_requirements: *82744620
68
+ version: 2.12.2
102
69
  - !ruby/object:Gem::Dependency
103
- name: rubyzip
104
- requirement: &82743920 !ruby/object:Gem::Requirement
105
- none: false
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
106
72
  requirements:
107
- - - ! '>='
73
+ - - ">="
108
74
  - !ruby/object:Gem::Version
109
75
  version: '0'
110
76
  type: :runtime
111
77
  prerelease: false
112
- version_requirements: *82743920
113
- - !ruby/object:Gem::Dependency
114
- name: activerecord
115
- requirement: &82743610 !ruby/object:Gem::Requirement
116
- none: false
78
+ version_requirements: !ruby/object:Gem::Requirement
117
79
  requirements:
118
- - - ! '>='
80
+ - - ">="
119
81
  - !ruby/object:Gem::Version
120
82
  version: '0'
121
- type: :runtime
122
- prerelease: false
123
- version_requirements: *82743610
124
83
  - !ruby/object:Gem::Dependency
125
84
  name: rdoc
126
- requirement: &82743270 !ruby/object:Gem::Requirement
127
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
128
86
  requirements:
129
- - - ~>
87
+ - - "~>"
130
88
  - !ruby/object:Gem::Version
131
89
  version: '4.0'
132
90
  type: :development
133
91
  prerelease: false
134
- version_requirements: *82743270
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
135
97
  - !ruby/object:Gem::Dependency
136
98
  name: hoe
137
- requirement: &82742500 !ruby/object:Gem::Requirement
138
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
139
100
  requirements:
140
- - - ~>
101
+ - - "~>"
141
102
  - !ruby/object:Gem::Version
142
103
  version: '3.13'
143
104
  type: :development
144
105
  prerelease: false
145
- version_requirements: *82742500
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.13'
146
111
  description: beerdb - beer.db command line tool
147
112
  email: beerdb@googlegroups.com
148
113
  executables:
149
114
  - beerdb
150
115
  extensions: []
151
116
  extra_rdoc_files:
152
- - History.md
117
+ - HISTORY.md
153
118
  - Manifest.txt
154
119
  - README.md
155
120
  files:
156
- - History.md
121
+ - HISTORY.md
157
122
  - Manifest.txt
158
123
  - README.md
159
124
  - Rakefile
@@ -161,55 +126,32 @@ files:
161
126
  - lib/beerdb.rb
162
127
  - lib/beerdb/cli/main.rb
163
128
  - lib/beerdb/cli/opts.rb
129
+ - lib/beerdb/cli/version.rb
164
130
  - lib/beerdb/console.rb
165
- - lib/beerdb/deleter.rb
166
- - lib/beerdb/models/beer.rb
167
- - lib/beerdb/models/brand.rb
168
- - lib/beerdb/models/brewery.rb
169
- - lib/beerdb/models/forward.rb
170
- - lib/beerdb/models/tag.rb
171
- - lib/beerdb/models/world/city.rb
172
- - lib/beerdb/models/world/country.rb
173
- - lib/beerdb/models/world/region.rb
174
- - lib/beerdb/reader.rb
175
- - lib/beerdb/reader_file.rb
176
- - lib/beerdb/reader_zip.rb
177
- - lib/beerdb/schema.rb
178
- - lib/beerdb/serializers/beer.rb
179
- - lib/beerdb/serializers/brewery.rb
180
- - lib/beerdb/stats.rb
181
- - lib/beerdb/version.rb
182
- - test/helper.rb
183
- - test/test_fixture_matchers.rb
184
- - test/test_values.rb
185
- - .gemtest
186
131
  homepage: https://github.com/beerkit/beer.db.ruby
187
132
  licenses:
188
133
  - Public Domain
134
+ metadata: {}
189
135
  post_install_message:
190
136
  rdoc_options:
191
- - --main
137
+ - "--main"
192
138
  - README.md
193
139
  require_paths:
194
140
  - lib
195
141
  required_ruby_version: !ruby/object:Gem::Requirement
196
- none: false
197
142
  requirements:
198
- - - ! '>='
143
+ - - ">="
199
144
  - !ruby/object:Gem::Version
200
145
  version: 1.9.2
201
146
  required_rubygems_version: !ruby/object:Gem::Requirement
202
- none: false
203
147
  requirements:
204
- - - ! '>='
148
+ - - ">="
205
149
  - !ruby/object:Gem::Version
206
150
  version: '0'
207
151
  requirements: []
208
152
  rubyforge_project:
209
- rubygems_version: 1.8.17
153
+ rubygems_version: 2.4.2
210
154
  signing_key:
211
- specification_version: 3
155
+ specification_version: 4
212
156
  summary: beerdb - beer.db command line tool
213
- test_files:
214
- - test/test_values.rb
215
- - test/test_fixture_matchers.rb
157
+ test_files: []
data/.gemtest DELETED
File without changes
data/History.md DELETED
@@ -1,3 +0,0 @@
1
- ### 0.0.1 / 2012-10-17
2
-
3
- * Everything is new. First release
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module BeerDb
4
-
5
- class Deleter
6
-
7
- include Models
8
-
9
- def run
10
- # for now delete all tables
11
-
12
- ### fix: use if defined? BeerDbNote or similar or/and check if table exist ??
13
- ### or move to beerdb-note ??
14
-
15
- ## Bookmark.delete_all # db model extension - move to its own addon?
16
- ## Drink.delete_all # db model extension - move to its own addon?
17
- ## Note.delete_all # db model extension - move to its own addon?
18
- ## User.delete_all # db model extension - move to its own addon?
19
-
20
- Beer.delete_all
21
- Brand.delete_all
22
- Brewery.delete_all
23
- end
24
-
25
- end # class Deleter
26
-
27
- end # module BeerDb
@@ -1,201 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module BeerDb
4
- module Model
5
-
6
- class Beer < ActiveRecord::Base
7
-
8
- extend TextUtils::TagHelper # will add self.find_tags, self.find_tags_in_attribs!, etc.
9
-
10
- # NB: use extend - is_<type>? become class methods e.g. self.is_<type>? for use in
11
- # self.create_or_update_from_values
12
- extend TextUtils::ValueHelper # e.g. self.is_year?, self.is_region?, self.is_address?, is_taglist? etc.
13
-
14
- belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
15
- belongs_to :region, :class_name => 'WorldDb::Model::Region', :foreign_key => 'region_id'
16
- belongs_to :city, :class_name => 'WorldDb::Model::City', :foreign_key => 'city_id'
17
-
18
- belongs_to :brand, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'brand_id'
19
- belongs_to :brewery, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'brewery_id'
20
-
21
-
22
- has_many :taggings, class_name: 'TagDb::Model::Tagging', :as => :taggable
23
- has_many :tags, class_name: 'TagDb::Model::Tag', :through => :taggings
24
-
25
-
26
- ## fix/todo: move to regex to patterns; see worlddb
27
- validates :key, :format => { :with => /\A[a-z][a-z0-9]+\z/, :message => 'expected two or more lowercase letters a-z or 0-9 digits' }
28
-
29
-
30
- ########################
31
- # begin extras/extension drink/bookmar/user
32
-
33
- has_many :drinks ## :class_name => 'Drink'
34
- has_many :notes ## :class_name => 'Note'
35
- has_many :bookmarks, :as => :bookmarkable
36
-
37
- # end extensions
38
- ########
39
-
40
-
41
- ### support old names (read-only) for now (remove later)
42
-
43
- def color() puts "*** depreceated fn api - use srm"; srm; end
44
- def plato() puts "*** depreceated fn api - use og"; og; end
45
-
46
- def color=(value)
47
- puts "*** depreceated fn api - use srm="
48
- self.srm = value
49
- end
50
-
51
- def plato=(value)
52
- puts "*** depreceated fn api - use og="
53
- self.og = value
54
- end
55
-
56
-
57
- def as_json_v2( opts={} )
58
- # NB: do NOT overwrite "default" / builtin as_json, thus, lets use as_json_v2
59
- BeerSerializer.new( self ).as_json
60
- end
61
-
62
-
63
- def self.create_or_update_from_values( values, more_attribs={} )
64
-
65
- attribs, more_values = find_key_n_title( values )
66
- attribs = attribs.merge( more_attribs )
67
-
68
- # check for optional values
69
- Beer.create_or_update_from_attribs( attribs, more_values )
70
- end
71
-
72
-
73
- def self.create_or_update_from_attribs( attribs, values )
74
-
75
- # fix: add/configure logger for ActiveRecord!!!
76
- logger = LogKernel::Logger.root
77
-
78
- value_tag_keys = []
79
-
80
- ## check for grades (e.g. ***/**/*) in titles (will add attribs[:grade] to hash)
81
- ## if grade missing; set default to 4; lets us update overwrite 1,2,3 values on update
82
- attribs[ :grade ] ||= 4
83
-
84
- ### check for "default" tags - that is, if present attribs[:tags] remove from hash
85
- value_tag_keys += find_tags_in_attribs!( attribs )
86
-
87
- ## check for optional values
88
- values.each_with_index do |value,index|
89
- if match_country(value) do |country|
90
- attribs[ :country_id ] = country.id
91
- end
92
- elsif match_region_for_country(value, attribs[:country_id]) do |region|
93
- attribs[ :region_id ] = region.id
94
- end
95
- elsif match_city(value) do |city|
96
- if city.present?
97
- attribs[ :city_id ] = city.id
98
- else
99
- ## todo/fix: add strict mode flag - fail w/ exit 1 in strict mode
100
- logger.warn "city with key #{value[5..-1]} missing for beer #{attribs[:key]}"
101
- end
102
- end
103
- elsif match_brewery(value) do |brewery|
104
- attribs[ :brewery_id ] = brewery.id
105
-
106
- # for easy queries cache city and region ids
107
-
108
- # 1) check if brewery has city - if yes, use it for beer too
109
- if brewery.city.present?
110
- attribs[ :city_id ] = brewery.city.id
111
- end
112
-
113
- # 2) check if brewery has city w/ region if yes, use it for beer to
114
- # if not check for region for brewery
115
- if brewery.city.present? && brewery.city.region.present?
116
- attribs[ :region_id ] = brewery.city.region.id
117
- elsif brewery.region.present?
118
- attribs[ :region_id ] = brewery.region.id
119
- end
120
- end
121
- elsif match_year( value ) do |num| # founded/established year e.g. 1776
122
- attribs[ :since ] = num
123
- end
124
- elsif match_website( value ) do |website| # check for url/internet address e.g. www.ottakringer.at
125
- attribs[ :web ] = website
126
- end
127
- elsif match_abv( value ) do |num| # abv (alcohol by volume)
128
- # nb: also allows leading < e.g. <0.5%
129
- attribs[ :abv ] = num
130
- end
131
- elsif match_og( value ) do |num| # plato (stammwuerze/gravity?) e.g. 11.2°
132
- # nb: no whitespace allowed between ° and number e.g. 11.2°
133
- attribs[ :og ] = num
134
- end
135
- elsif match_kcal( value ) do |num| # kcal
136
- # nb: allow 44.4 kcal/100ml or 44.4 kcal or 44.4kcal
137
- attribs[ :kcal ] = num
138
- end
139
- elsif (values.size==(index+1)) && is_taglist?( value ) # tags must be last entry
140
- logger.debug " found tags: >>#{value}<<"
141
- value_tag_keys += find_tags( value )
142
- else
143
- # issue warning: unknown type for value
144
- logger.warn "unknown type for value >#{value}< - key #{attribs[:key]}"
145
- end
146
- end # each value
147
-
148
- # rec = Beer.find_by_key_and_country_id( attribs[ :key ], attribs[ :country_id] )
149
- rec = Beer.find_by_key( attribs[ :key ] )
150
-
151
- if rec.present?
152
- logger.debug "update Beer #{rec.id}-#{rec.key}:"
153
- else
154
- logger.debug "create Beer:"
155
- rec = Beer.new
156
- end
157
-
158
- logger.debug attribs.to_json
159
-
160
- rec.update_attributes!( attribs )
161
-
162
- ##################
163
- # add taggings
164
-
165
- ##
166
- ## fix: delete all tags first or only add diff?
167
- ## fix e.g.
168
- ##
169
- ## [debug] update Beer 1340-opatsvetlevycepni:
170
- ## [debug] {"title":"Opat Světlé Výčepní","key":"opatsvetlevycepni","country_id":130,"txt":"cz-czech-republic!/beers","grade":4,"brewery_id":839,"city_id":1154,"region_id":241,"abv":4.2,"og":11.0}
171
- ## [debug] adding 1 taggings: >>pale lager<<...
172
- ## rake aborted!
173
- ## ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: columns taggable_id, taggable_type, tag_id are not unique: INSERT INTO "taggings" ("created_at", "tag_id", "taggable_id", "taggable_type", "updated_at") VALUES (?, ?, ?, ?, ?)
174
-
175
- =begin
176
- if value_tag_keys.size > 0
177
-
178
- value_tag_keys.uniq! # remove duplicates
179
- logger.debug " adding #{value_tag_keys.size} taggings: >>#{value_tag_keys.join('|')}<<..."
180
-
181
- ### fix/todo: check tag_ids and only update diff (add/remove ids)
182
-
183
- value_tag_keys.each do |key|
184
- tag = Tag.find_by_key( key )
185
- if tag.nil? # create tag if it doesn't exit
186
- logger.debug " creating tag >#{key}<"
187
- tag = Tag.create!( key: key )
188
- end
189
- rec.tags << tag
190
- end
191
- end
192
- =end
193
-
194
- rec # NB: return created or updated obj
195
-
196
- end # method create_or_update_from_values
197
-
198
- end # class Beer
199
-
200
- end # module Model
201
- end # module BeerDb
@@ -1,62 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module BeerDb
4
- module Model
5
-
6
- class Brand < ActiveRecord::Base
7
-
8
- # NB: use extend - is_<type>? become class methods e.g. self.is_<type>?
9
- extend TextUtils::ValueHelper # e.g. self.find_key_n_title, self.is_year?, self.is_region?, is_address?, is_taglist? etc.
10
-
11
- belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
12
- belongs_to :region, :class_name => 'WorldDb::Model::Region', :foreign_key => 'region_id'
13
- belongs_to :city, :class_name => 'WorldDb::Model::City', :foreign_key => 'city_id'
14
-
15
- belongs_to :brewery, :class_name => 'BeerDb::Model::Brewery', :foreign_key => 'brewery_id'
16
-
17
- has_many :beers, :class_name => 'BeerDb::Model::Beer', :foreign_key => 'brand_id'
18
-
19
- validates :key, :format => { :with => /\A[a-z][a-z0-9]+\z/, :message => 'expected two or more lowercase letters a-z or 0-9 digits' }
20
-
21
-
22
- def self.create_or_update_from_values( values, more_attribs = {} )
23
- attribs, more_values = find_key_n_title( values )
24
- attribs = attribs.merge( more_attribs )
25
-
26
- Brand.create_or_update_from_attribs( attribs, more_values )
27
- end
28
-
29
- # convenience helper Brand.create_or_update_from_title
30
- def self.create_or_update_from_title( title, more_attribs = {} )
31
- values = [title]
32
- Brand.create_or_update_from_values( values, more_attribs )
33
- end
34
-
35
-
36
- def self.create_or_update_from_attribs( attribs, values )
37
-
38
- ## fix: add/configure logger for ActiveRecord!!!
39
- logger = LogKernel::Logger.root
40
-
41
- ## check for grades (e.g. ***/**/*) in titles (will add attribs[:grade] to hash)
42
- ## if grade missing; set default to 4; lets us update overwrite 1,2,3 values on update
43
- attribs[:grade] ||= 4
44
-
45
- rec = Brand.find_by_key( attribs[:key] )
46
-
47
- if rec.present?
48
- logger.debug "update Brand #{rec.id}-#{rec.key}:"
49
- else
50
- logger.debug "create Brand:"
51
- rec = Brand.new
52
- end
53
-
54
- logger.debug attribs.to_json
55
-
56
- rec.update_attributes!( attribs )
57
- end
58
-
59
- end # class Brand
60
-
61
- end # module Model
62
- end # module BeerDb