csvpack 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,61 +1,62 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_companies.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestCompanies < MiniTest::Test
11
-
12
- def test_s_and_p_500_companies
13
-
14
- pak = Datapak::Pak.new( './pak/s-and-p-500-companies/datapackage.json' )
15
-
16
- puts "name: #{pak.name}"
17
- puts "title: #{pak.title}"
18
- puts "license: #{pak.license}"
19
-
20
- pp pak.tables
21
- pp pak.table[0]['Symbol']
22
- pp pak.table[495]['Symbol']
23
-
24
- ## pak.table.each do |row|
25
- ## pp row
26
- ## end
27
-
28
- puts pak.tables[0].dump_schema
29
- puts pak.tables[1].dump_schema
30
-
31
- # database setup 'n' config
32
- ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ':memory:' )
33
- ActiveRecord::Base.logger = Logger.new( STDOUT )
34
-
35
- pak.table.up!
36
- pak.table.import!
37
-
38
- pak.tables[1].up!
39
- pak.tables[1].import!
40
-
41
-
42
- pp pak.table.ar_clazz
43
-
44
-
45
- company = pak.table.ar_clazz
46
-
47
- puts "Company.count: #{company.count}"
48
- pp company.first
49
- pp company.find_by!( symbol: 'MMM' )
50
- pp company.find_by!( name: '3M Co' )
51
- pp company.where( sector: 'Industrials' ).count
52
- pp company.where( sector: 'Industrials' ).all
53
-
54
-
55
- ### todo: try a join w/ belongs_to ??
56
-
57
- assert true # if we get here - test success
58
- end
59
-
60
- end # class TestCompanies
61
-
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_companies.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestCompanies < MiniTest::Test
11
+
12
+ def test_s_and_p_500_companies
13
+
14
+ pack = CsvPack::Pack.new( './pack/s-and-p-500-companies/datapackage.json' )
15
+
16
+ meta = pack.meta
17
+ puts "name: #{meta.name}"
18
+ puts "title: #{meta.title}"
19
+ puts "license: #{meta.license}"
20
+
21
+ pp pack.tables
22
+ pp pack.table[0]['Symbol']
23
+ pp pack.table[495]['Symbol']
24
+
25
+ ## pak.table.each do |row|
26
+ ## pp row
27
+ ## end
28
+
29
+ puts pack.tables[0].dump_schema
30
+
31
+ # database setup 'n' config
32
+ ActiveRecord::Base.establish_connection( adapter: 'sqlite3',
33
+ database: ':memory:' )
34
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
35
+
36
+ pack.table.up!
37
+ pack.table.import!
38
+
39
+ ## pack.tables[0].up!
40
+ ## pack.tables[0].import!
41
+
42
+
43
+ pp pack.table.ar_clazz
44
+
45
+
46
+ company = pack.table.ar_clazz
47
+
48
+ puts "Company:"
49
+ pp company.count
50
+ pp company.first
51
+ pp company.find_by!( symbol: 'MMM' )
52
+ pp company.find_by!( name: '3M Company' )
53
+ pp company.where( sector: 'Industrials' ).count
54
+ pp company.where( sector: 'Industrials' ).all
55
+
56
+
57
+ ### todo: try a join w/ belongs_to ??
58
+
59
+ assert true # if we get here - test success
60
+ end
61
+
62
+ end # class TestCompanies
@@ -1,40 +1,41 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_countries.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestCountries < MiniTest::Test
11
-
12
- def test_country_list
13
- pak = Datapak::Pak.new( './pak/country-list/datapackage.json' )
14
-
15
- puts "name: #{pak.name}"
16
- puts "title: #{pak.title}"
17
- puts "license: #{pak.license}"
18
-
19
- pp pak.tables
20
-
21
- ## pak.table.each do |row|
22
- ## pp row
23
- ## end
24
-
25
- puts pak.table.dump_schema
26
-
27
- # database setup 'n' config
28
- ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ':memory:' )
29
- ActiveRecord::Base.logger = Logger.new( STDOUT )
30
-
31
- pak.table.up!
32
- pak.table.import!
33
-
34
- pp pak.table.ar_clazz
35
-
36
- assert true # if we get here - test success
37
- end
38
-
39
- end # class TestCountries
40
-
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_countries.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestCountries < MiniTest::Test
11
+
12
+ def test_country_list
13
+ pack = CsvPack::Pack.new( './pack/country-list/datapackage.json' )
14
+
15
+ meta = pack.meta
16
+ puts "name: #{meta.name}"
17
+ puts "title: #{meta.title}"
18
+ puts "license: #{meta.license}"
19
+
20
+ pp pack.tables
21
+
22
+ ## pak.table.each do |row|
23
+ ## pp row
24
+ ## end
25
+
26
+ puts pack.table.dump_schema
27
+
28
+ # database setup 'n' config
29
+ ActiveRecord::Base.establish_connection( adapter: 'sqlite3',
30
+ database: ':memory:' )
31
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
32
+
33
+ pack.table.up!
34
+ pack.table.import!
35
+
36
+ pp pack.table.ar_clazz
37
+
38
+ assert true # if we get here - test success
39
+ end
40
+
41
+ end # class TestCountries
@@ -1,32 +1,32 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_downloader.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestDownloader < MiniTest::Test
11
-
12
- def test_download
13
-
14
- names = [
15
- 'country-list',
16
- 'country-codes',
17
- 'language-codes',
18
- 'cpi', ## Annual Consumer Price Index (CPI)
19
- 'gdp', ## Country, Regional and World GDP (Gross Domestic Product)
20
- 's-and-p-500-companies', ## S&P 500 Companies with Financial Information
21
- 'un-locode', ## UN-LOCODE Codelist - note: incl. country-codes.csv
22
- ]
23
-
24
- dl = Datapak::Downloader.new
25
- names.each do |name|
26
- dl.fetch( name )
27
- end
28
-
29
- assert true # if we get here - test success
30
- end
31
-
32
- end # class TestDownloader
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_downloader.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestDownloader < MiniTest::Test
11
+
12
+ def test_download
13
+
14
+ names = [
15
+ 'country-list',
16
+ 'country-codes',
17
+ 'language-codes',
18
+ 'cpi', ## Annual Consumer Price Index (CPI)
19
+ 'gdp', ## Country, Regional and World GDP (Gross Domestic Product)
20
+ 's-and-p-500-companies', ## S&P 500 Companies with Financial Information
21
+ 'un-locode', ## UN-LOCODE Codelist - note: incl. country-codes.csv
22
+ ]
23
+
24
+ dl = CsvPack::Downloader.new
25
+ names.each do |name|
26
+ dl.fetch( name )
27
+ end
28
+
29
+ assert true # if we get here - test success
30
+ end
31
+
32
+ end # class TestDownloader
@@ -1,22 +1,22 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_import.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestImport < MiniTest::Test
11
-
12
- def test_import
13
-
14
- CsvPack.import(
15
- 'cpi', ## Annual Consumer Price Index (CPI)
16
- 'gdp', ## Country, Regional and World GDP (Gross Domestic Product)
17
- )
18
-
19
- assert true # if we get here - test success
20
- end
21
-
22
- end # class TestImport
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_import.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestImport < MiniTest::Test
11
+
12
+ def test_import
13
+
14
+ CsvPack.import(
15
+ 'cpi', ## Annual Consumer Price Index (CPI)
16
+ 'gdp', ## Country, Regional and World GDP (Gross Domestic Product)
17
+ )
18
+
19
+ assert true # if we get here - test success
20
+ end
21
+
22
+ end # class TestImport
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils