usda-nutrient-database 2.1.0 → 2.1.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 +4 -4
- data/lib/usda-nutrient-database.rb +1 -0
- data/lib/usda_nutrient_database/food.rb +6 -0
- data/lib/usda_nutrient_database/foods_nutrient.rb +1 -0
- data/lib/usda_nutrient_database/footnote.rb +5 -0
- data/lib/usda_nutrient_database/version.rb +1 -1
- data/lib/usda_nutrient_database/weight.rb +1 -0
- data/usda-nutrient-database.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9fac9ef436246590f59dc2719c028959c9c81fc7
|
|
4
|
+
data.tar.gz: 315c836faed4a4de15416ad32a277db245dca755
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad4c52cd1647742d73fd2a1a73d2d5c70d484807c73bdd191ac233a0d135261610efb20ac36ae4ec20e2e92176f3b8854f97b84cceca579bb73d2866243c391c
|
|
7
|
+
data.tar.gz: 5abb1d5df808e868d2b43dad2f593983898883f898578bca716019dafc452c8ba66d685192c3dc68d3691fdc7cb6822be90c85621382d0a75a3087003f4c12aa
|
|
@@ -29,5 +29,11 @@ module UsdaNutrientDatabase
|
|
|
29
29
|
scope :by_food_group_code, ->(food_group_code) {
|
|
30
30
|
where(food_group_code: food_group_code)
|
|
31
31
|
}
|
|
32
|
+
scope :search, ->(text) {
|
|
33
|
+
where(
|
|
34
|
+
arel_table[:long_description].matches("%#{text.gsub(' ', '%')}%")
|
|
35
|
+
.or(arel_table[:long_description].matches("%#{text.split(' ').reverse.join('%')}%"))
|
|
36
|
+
)
|
|
37
|
+
}
|
|
32
38
|
end
|
|
33
39
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module UsdaNutrientDatabase
|
|
2
2
|
class FoodsNutrient < ActiveRecord::Base
|
|
3
3
|
self.table_name = 'usda_foods_nutrients'
|
|
4
|
+
self.primary_keys = %i(nutrient_databank_number nutrient_number)
|
|
4
5
|
|
|
5
6
|
validates :nutrient_databank_number, presence: true,
|
|
6
7
|
uniqueness: { scope: :nutrient_number, allow_blank: true }
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
module UsdaNutrientDatabase
|
|
2
2
|
class Footnote < ActiveRecord::Base
|
|
3
3
|
self.table_name = 'usda_footnotes'
|
|
4
|
+
self.primary_keys = [
|
|
5
|
+
:nutrient_databank_number,
|
|
6
|
+
:footnote_number,
|
|
7
|
+
:nutrient_number
|
|
8
|
+
]
|
|
4
9
|
|
|
5
10
|
validates :nutrient_databank_number,
|
|
6
11
|
presence: true,
|
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
21
|
spec.add_runtime_dependency 'activerecord', '>= 3.0.0'
|
|
22
|
+
spec.add_runtime_dependency 'composite_primary_keys'
|
|
22
23
|
spec.add_runtime_dependency 'faraday'
|
|
23
24
|
spec.add_runtime_dependency 'rubyzip'
|
|
24
25
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usda-nutrient-database
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Beedle
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-04-
|
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 3.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: composite_primary_keys
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
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: faraday
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|