ruby_px 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfa0ddb5f455e289afe1507164ab005e0896e7e091531a052472f36cfdfe11d3
4
- data.tar.gz: 3acf6d18b2ae29ddceab2c0859d4fe79be33a61a54be7f93632a014ebaf5dee7
3
+ metadata.gz: 6f5d35908531ee6fa8cf93f8ee71fb406c13d15ab65cd2f0e62a0333a3525320
4
+ data.tar.gz: 787d66c1ebb61aad54d2bb3809716bda8f89b4abab6a2e26fe0de6a19cdd507a
5
5
  SHA512:
6
- metadata.gz: c2439c7a3698ae78f288866cb91933325dbd48ec88a2bbc6b54353e6fe4567e768b7a2c6febb326c2e6566f1f4633eca4b6bb4d7e5ea471dacae21dbe6818f66
7
- data.tar.gz: 5482d50e2be5fc9fc4ab6c1b2d40bdf7e2b4b1ea8f2f528ef13d2c575cd9630208ff6e188ba3e3e8c3f17eb4e005787c7c64095c4619d77b0ed23125a5865d80
6
+ metadata.gz: 79c159ae77206a80e507f5450568df35fb7343b791350e583e15dada526aed82c6c39da78cbefd3210096121176f6a9dcbf856b1a706c228b96b9b2e7ba5f052
7
+ data.tar.gz: 2f97231b09776a596f5863e1c1d66a87ee6bf6fb032e6ec91c91113f8c8a500df52c64ce728d96796f9fa23c95ecc9285665db8091704a2cea47ec8121272e29
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.8.0 (2021-03-04)
4
+
5
+ - Fix wrong DATA key error [#10](https://github.com/PopulateTools/ruby_px/pull/10)
6
+
7
+ ## 0.7.0 (2021-03-04)
8
+
9
+ - Performance in large datasets [#9](https://github.com/PopulateTools/ruby_px/pull/9)
10
+
3
11
  ## 0.6.0 (2020-04-28)
4
12
 
5
13
  - Nice badge with the current version
@@ -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
@@ -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[offset]
87
+ @data.at(offset)
86
88
 
87
89
  # Return an array of options
88
90
  elsif options.length == dimensions.length - 1
@@ -160,7 +162,7 @@ module RubyPx
160
162
  elsif key =~ /\AVALUES/ && key !~ /\[\w\w\]/
161
163
  @type = :values
162
164
  key.match(/\"([^"]+)\"/)[1]
163
- elsif key =~ /\ADATA/
165
+ elsif key =~ /\ADATA\z/
164
166
  @type = :data
165
167
  key
166
168
  end
data/ruby_px.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'ruby_px'
8
- spec.version = '0.6.0'
8
+ spec.version = '0.8.0'
9
9
  spec.authors = ['Fernando Blat']
10
10
  spec.email = ['fernando@blat.es']
11
11
 
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.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Blat
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,13 +86,14 @@ 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:
92
93
  - MIT
93
94
  metadata:
94
95
  allowed_push_host: https://rubygems.org
95
- post_install_message:
96
+ post_install_message:
96
97
  rdoc_options: []
97
98
  require_paths:
98
99
  - lib
@@ -107,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
110
  requirements: []
110
- rubygems_version: 3.1.2
111
- signing_key:
111
+ rubygems_version: 3.4.20
112
+ signing_key:
112
113
  specification_version: 4
113
114
  summary: Read PC-Axis files using Ruby
114
115
  test_files: []