tableschema 0.5.0 → 0.6.0
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/README.md +7 -8
- data/lib/tableschema/table.rb +4 -4
- data/lib/tableschema/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4213e2bcb8976d39f68070432938713c4b3427c0
|
4
|
+
data.tar.gz: ffdc42291e4875bed97368c6c74ea63382733eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6af414cb6b284600fcbea95103a18d485a55def675507a289be49681f00b130463c7b896b57651ef24730511ee26caedb58ac14ebf0ded385270c5080a8c70
|
7
|
+
data.tar.gz: 5fb01a2169b7a6e616a19346c616fdb1f090e6010b5de2c61dbc504b97f192454f216a9e86b7b20d170385b91f767d349e655cbcd776b5ba649893765e96be3b
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
#
|
2
|
-
formerly known as JSON Table Schema
|
1
|
+
# tableschema-rb
|
3
2
|
|
4
3
|
[](https://travis-ci.org/frictionlessdata/tableschema-rb)
|
5
4
|
[](https://coveralls.io/github/frictionlessdata/tableschema-rb?branch=master)
|
@@ -46,11 +45,11 @@ The gem `jsontableschema` is no longer maintained. Here are the steps to transit
|
|
46
45
|
2. Replace module name `JsonTableSchema` with module name `TableSchema`. For example:
|
47
46
|
|
48
47
|
```ruby
|
49
|
-
JsonTableSchema::Table.new(source, schema)
|
48
|
+
JsonTableSchema::Table.new(source, schema: schema)
|
50
49
|
```
|
51
50
|
with
|
52
51
|
```ruby
|
53
|
-
TableSchema::Table.new(source, schema)
|
52
|
+
TableSchema::Table.new(source, schema: schema)
|
54
53
|
```
|
55
54
|
|
56
55
|
## Usage
|
@@ -75,9 +74,9 @@ schema = {
|
|
75
74
|
]
|
76
75
|
}
|
77
76
|
|
78
|
-
|
77
|
+
source = 'https://github.com/frictionlessdata/tableschema-rb/raw/master/spec/fixtures/simple_data.csv'
|
79
78
|
|
80
|
-
table = TableSchema::Table.new(
|
79
|
+
table = TableSchema::Table.new(source, schema: schema)
|
81
80
|
|
82
81
|
# Iterate through rows
|
83
82
|
table.iter{ |row| print row }
|
@@ -100,9 +99,9 @@ Both `iter` and `read` take the optional parameters:
|
|
100
99
|
If you don't have a schema for a CSV, and want to generate one, you can infer a schema like so:
|
101
100
|
|
102
101
|
```ruby
|
103
|
-
|
102
|
+
source = 'https://github.com/frictionlessdata/tableschema-rb/raw/master/spec/fixtures/simple_data.csv' # Can also be a url or array of arrays
|
104
103
|
|
105
|
-
table = TableSchema::Table.new(
|
104
|
+
table = TableSchema::Table.new(source)
|
106
105
|
table.infer()
|
107
106
|
table.schema
|
108
107
|
#=> {:fields=>[{:name=>"id", :title=>"", :description=>"", :type=>"integer", :format=>"default", :constraints=>{}}, {:name=>"title", :title=>"", :description=>"", :type=>"string", :format=>"default", :constraints=>{}}]}
|
data/lib/tableschema/table.rb
CHANGED
@@ -5,12 +5,12 @@ module TableSchema
|
|
5
5
|
|
6
6
|
attr_reader :headers, :schema
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(source, schema: nil, csv_options: {})
|
9
9
|
@csv_options = csv_options.merge(headers: true)
|
10
|
-
@
|
11
|
-
@
|
10
|
+
@csv = parse_csv(source)
|
11
|
+
@descriptor = schema
|
12
12
|
@headers = initialize_headers
|
13
|
-
if
|
13
|
+
if !@descriptor.nil?
|
14
14
|
@schema = TableSchema::Schema.new(@descriptor)
|
15
15
|
initialize_unique_colums
|
16
16
|
end
|
data/lib/tableschema/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tableschema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Open Knowledge Foundation
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|