ruby_px 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/ruby_px/dataset.rb +4 -2
- data/lib/ruby_px/dataset/data.rb +48 -0
- data/ruby_px.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abe10d6ad1aed7bb9d28535671457cad398d7c17cab9c9bc49376dd46be5a3a
|
4
|
+
data.tar.gz: 95e9b594074e45eaa34e319c2ef58fc73edf4e5f6ceee9ae7c67bb2919407425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff283ea31198ae6fd560b591ac6c1d7dc649a148a61a3a4570953c380c22f4c667fe15a569454df1649d744845b62734051d89863e7e8c523e2f270ea77b3762
|
7
|
+
data.tar.gz: a36341f8e244874a2d588b0e28319c43da1f9f8b2488007ea79f1cccf16be8db544bf59839d6c1dc8f495e0581e2f3341922c41df9ef6a3d907f57748a0e31f2
|
data/CHANGELOG.md
CHANGED
data/lib/ruby_px/dataset.rb
CHANGED
@@ -4,6 +4,8 @@ require 'open-uri'
|
|
4
4
|
|
5
5
|
module RubyPx
|
6
6
|
class Dataset
|
7
|
+
require 'ruby_px/dataset/data'
|
8
|
+
|
7
9
|
attr_reader :headings, :stubs
|
8
10
|
|
9
11
|
METADATA_RECORDS = %w[TITLE UNITS SOURCE CONTACT LAST-UPDATED CREATION-DATE].freeze
|
@@ -15,7 +17,7 @@ module RubyPx
|
|
15
17
|
@headings = []
|
16
18
|
@stubs = []
|
17
19
|
@values = {}
|
18
|
-
@data =
|
20
|
+
@data = Data.new
|
19
21
|
|
20
22
|
parse_resource(resource_uri)
|
21
23
|
end
|
@@ -82,7 +84,7 @@ module RubyPx
|
|
82
84
|
offset += (d ? p * d : p)
|
83
85
|
end
|
84
86
|
|
85
|
-
@data
|
87
|
+
@data.at(offset)
|
86
88
|
|
87
89
|
# Return an array of options
|
88
90
|
elsif options.length == dimensions.length - 1
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module RubyPx
|
2
|
+
class Dataset
|
3
|
+
class Data
|
4
|
+
|
5
|
+
CHUNK_SIZE = 5_000
|
6
|
+
attr_accessor :current_chunk_index
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@current_chunk_index = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def at index
|
13
|
+
chunk_index = index/CHUNK_SIZE
|
14
|
+
index_inside_chunk = index%CHUNK_SIZE
|
15
|
+
|
16
|
+
get_chunk(chunk_index)[index_inside_chunk]
|
17
|
+
end
|
18
|
+
|
19
|
+
def concat array
|
20
|
+
current_chunk.concat(array)
|
21
|
+
if current_chunk.size > CHUNK_SIZE
|
22
|
+
excess = current_chunk.pop(current_chunk.size-CHUNK_SIZE)
|
23
|
+
self.current_chunk_index += 1
|
24
|
+
concat(excess)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def indexes_count
|
29
|
+
self.current_chunk_index+1
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
|
35
|
+
def current_chunk
|
36
|
+
current = instance_variable_get("@chunk_#{self.current_chunk_index}")
|
37
|
+
return current if current
|
38
|
+
|
39
|
+
instance_variable_set("@chunk_#{self.current_chunk_index}", [])
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_chunk chunk_index
|
43
|
+
instance_variable_get("@chunk_#{chunk_index}")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/ruby_px.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_px
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Blat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- bin/setup
|
87
87
|
- lib/ruby_px.rb
|
88
88
|
- lib/ruby_px/dataset.rb
|
89
|
+
- lib/ruby_px/dataset/data.rb
|
89
90
|
- ruby_px.gemspec
|
90
91
|
homepage: https://github.com/PopulateTools/ruby_px
|
91
92
|
licenses:
|