mode 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mode/connector/dataset.rb +4 -1
- data/lib/mode/connector/selector.rb +5 -2
- data/lib/mode/connector/uploader.rb +5 -0
- data/lib/mode/version.rb +1 -1
- data/spec/connector/uploader_spec.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bafc28cae256c4ce4821bb00753799dadb4c468c
|
4
|
+
data.tar.gz: 7360d725309e1253b0cff15f9974942405fbd370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e6ffd7b71345345d3e8399c74a7b6b358353ae632839ac60f46085cb0cbfaed4c09f4e2a748429ece0df50ed802095977adf605b92812e462544b2a864c4e56
|
7
|
+
data.tar.gz: 9bd2f1c0f0f3fe7f788a83785d7d1b591d6e355231ea3507dcf70db113e44d1ffc5c44b08cda7a0d65bd3a469ffd481ae8b9f8e781f1536d06f748752ca0a4bd
|
@@ -2,10 +2,13 @@ module Mode
|
|
2
2
|
module Connector
|
3
3
|
class Dataset
|
4
4
|
attr_reader :path
|
5
|
+
|
6
|
+
attr_reader :count
|
5
7
|
attr_reader :column_types
|
6
8
|
|
7
|
-
def initialize(path, column_types)
|
9
|
+
def initialize(path, count, column_types)
|
8
10
|
@path = path
|
11
|
+
@count = count
|
9
12
|
@column_types = column_types
|
10
13
|
end
|
11
14
|
end
|
@@ -5,16 +5,18 @@ module Mode
|
|
5
5
|
class Selector
|
6
6
|
attr_reader :query
|
7
7
|
attr_reader :data_source
|
8
|
+
|
9
|
+
attr_reader :count
|
8
10
|
attr_reader :column_types
|
9
11
|
|
10
12
|
def initialize(query, data_source)
|
11
13
|
@query, @data_source = query, data_source
|
12
|
-
@column_types = Mode::Connector::TypeMap.new
|
14
|
+
@count, @column_types = 0, Mode::Connector::TypeMap.new
|
13
15
|
end
|
14
16
|
|
15
17
|
def perform!
|
16
18
|
File.open(path, 'w+') { |file| write(file) }
|
17
|
-
Mode::Connector::Dataset.new(path, column_types)
|
19
|
+
Mode::Connector::Dataset.new(path, count, column_types)
|
18
20
|
end
|
19
21
|
|
20
22
|
def path
|
@@ -27,6 +29,7 @@ module Mode
|
|
27
29
|
index = 0
|
28
30
|
file.write '['
|
29
31
|
data_source.select(query) do |row|
|
32
|
+
@count += 1
|
30
33
|
write_row(file, row, index += 1)
|
31
34
|
end
|
32
35
|
file.write ']'
|
@@ -14,6 +14,7 @@ module Mode
|
|
14
14
|
path,
|
15
15
|
:execution => {
|
16
16
|
:dataset => {
|
17
|
+
:count => count,
|
17
18
|
:content => content,
|
18
19
|
:columns => JSON.generate(columns)
|
19
20
|
}
|
@@ -36,6 +37,10 @@ module Mode
|
|
36
37
|
|
37
38
|
private
|
38
39
|
|
40
|
+
def count
|
41
|
+
dataset.count
|
42
|
+
end
|
43
|
+
|
39
44
|
def columns
|
40
45
|
dataset.column_types.map do |name, type|
|
41
46
|
{:name => name, :type => type}
|
data/lib/mode/version.rb
CHANGED
@@ -8,6 +8,7 @@ describe Mode::Connector::Uploader do
|
|
8
8
|
let(:dataset) {
|
9
9
|
double(:dataset,
|
10
10
|
:path => outpath,
|
11
|
+
:count => 0,
|
11
12
|
:column_types => {
|
12
13
|
'int' => :integer,
|
13
14
|
'float' => :number
|
@@ -31,6 +32,7 @@ describe Mode::Connector::Uploader do
|
|
31
32
|
Mode::API::Request.should_receive(:put).with(execution_path,
|
32
33
|
:execution => {
|
33
34
|
:dataset => {
|
35
|
+
:count => 0,
|
34
36
|
:columns => an_instance_of(String),
|
35
37
|
:content => an_instance_of(Faraday::UploadIO)
|
36
38
|
}
|