datapackage 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -1
- data/lib/datapackage/resource.rb +4 -0
- data/lib/datapackage/version.rb +1 -1
- data/lib/datapackage.rb +1 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce6f0ffb39c4ee1207b70385a35ae6ffdefac062
|
4
|
+
data.tar.gz: dc57cbe51b6546650c94b434f890292d7bf30513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941fd655c6abdb97df01b9de866b346f949d93d7496d5487691dcdf400d6eeacef5ed01eb1ae1dcf6ac69c8d3f7b6fb6b42ce228aad2af1a31d77ce04a4fadaf
|
7
|
+
data.tar.gz: a5a5418a64ba0feebd5dc1719546cca54460db1d7c8d8ad8b7b30aaa175316c1bf517130bc85a41f039959a7e12e0436e66669c749562878421853366fdb206a
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ gem install datapackage
|
|
33
33
|
Require the gem, if you need to:
|
34
34
|
|
35
35
|
```ruby
|
36
|
-
require 'datapackage
|
36
|
+
require 'datapackage'
|
37
37
|
```
|
38
38
|
|
39
39
|
Parsing a Data Package from a remote location:
|
@@ -66,6 +66,32 @@ package.homepage
|
|
66
66
|
package.license
|
67
67
|
```
|
68
68
|
|
69
|
+
## Reading a Data Package and its resources
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require 'datapackage'
|
73
|
+
|
74
|
+
dp = DataPackage::Package.new('http://data.okfn.org/data/core/gdp/datapackage.json')
|
75
|
+
|
76
|
+
data = CSV.parse(dp.resources[0].data, headers: true)
|
77
|
+
brazil_gdp = data.select { |r| r["Country Code"] == "BRA" }.
|
78
|
+
map { |row| { year: Integer(row["Year"]), value: Float(row['Value']) } }
|
79
|
+
|
80
|
+
max_gdp = brazil_gdp.max_by { |r| r[:value] }
|
81
|
+
min_gdp = brazil_gdp.min_by { |r| r[:value] }
|
82
|
+
|
83
|
+
percentual_increase = (max_gdp[:value] / min_gdp[:value]).round(2)
|
84
|
+
max_gdp_val = max_gdp[:value].to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
|
85
|
+
|
86
|
+
msg = "The highest Brazilian GDP occured in #{max_gdp[:year]}, when it peaked at US$ " +
|
87
|
+
"#{max_gdp_val}. This was #{percentual_increase}% more than its minumum GDP " +
|
88
|
+
"in #{min_gdp[:year]}"
|
89
|
+
|
90
|
+
print msg
|
91
|
+
|
92
|
+
# The highest Brazilian GDP occured in 2011, when it peaked at US$ 2,615,189,973,181. This was 172.44% more than its minimum GDP in 1960.
|
93
|
+
```
|
94
|
+
|
69
95
|
## Creating a Data Package
|
70
96
|
|
71
97
|
```ruby
|
data/lib/datapackage/resource.rb
CHANGED
data/lib/datapackage/version.rb
CHANGED
data/lib/datapackage.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datapackage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leigh Dodds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -110,6 +110,20 @@ dependencies:
|
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: jsontableschema
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :runtime
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
113
127
|
- !ruby/object:Gem::Dependency
|
114
128
|
name: bundler
|
115
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,20 +208,6 @@ dependencies:
|
|
194
208
|
- - ">="
|
195
209
|
- !ruby/object:Gem::Version
|
196
210
|
version: '0'
|
197
|
-
- !ruby/object:Gem::Dependency
|
198
|
-
name: henry
|
199
|
-
requirement: !ruby/object:Gem::Requirement
|
200
|
-
requirements:
|
201
|
-
- - ">="
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
version: '0'
|
204
|
-
type: :development
|
205
|
-
prerelease: false
|
206
|
-
version_requirements: !ruby/object:Gem::Requirement
|
207
|
-
requirements:
|
208
|
-
- - ">="
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
version: '0'
|
211
211
|
description:
|
212
212
|
email:
|
213
213
|
- ops@theodi.org
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
version: '0'
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.
|
249
|
+
rubygems_version: 2.6.6
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Library for working with data packages
|