rightmove_blm 0.2.4 → 0.2.6
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/lib/rightmove_blm/document.rb +16 -3
- data/lib/rightmove_blm/version.rb +1 -1
- data/rightmove_blm.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27c31f1462ef7ed1cb02253396803510703b7a3f2d14678dd359bd002ff1f113
|
4
|
+
data.tar.gz: 2c08d19df9a78f7ceae30a97dbd2be7dba9e6e8d3636779d1cdc3e6db14e75bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b599bc06336d93a1102b5276debb05eb285599f4169dae7fa744070c362e637107221e18a31346af2b6971314f0f1120f095627869a7ac90806023fc129b0922
|
7
|
+
data.tar.gz: e1c457877d3163e5b19d2570eab8d07190936cce9132c1588e5f4d8447065e45456c801df245fe8bee3d26142a585bf076e209526930fac0133d496b88f7828d
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module RightmoveBLM
|
4
4
|
# A BLM document including its header, definition, and data content.
|
5
5
|
class Document # rubocop:disable Metrics/ClassLength
|
6
|
+
BLM_4_FILE_KEYWORDS = %w[HEADER VERSION EOF EOR DEFINITION DATA END].freeze
|
7
|
+
|
6
8
|
def self.from_array_of_hashes(array)
|
7
9
|
date = Time.now.utc.strftime('%d-%b-%Y %H:%M').upcase
|
8
10
|
header = { version: '3', eof: '^', eor: '~', 'property count': array.size.to_s, 'generated date': date }
|
@@ -15,6 +17,7 @@ module RightmoveBLM
|
|
15
17
|
@definition = definition
|
16
18
|
@name = name
|
17
19
|
initialize_with_data(data) unless data.nil?
|
20
|
+
verify_source_file_structure(source) unless source.nil?
|
18
21
|
end
|
19
22
|
|
20
23
|
def inspect(safe: false, error: nil)
|
@@ -92,8 +95,8 @@ module RightmoveBLM
|
|
92
95
|
|
93
96
|
def contents(section = :data)
|
94
97
|
marker = "##{section.to_s.upcase}#"
|
95
|
-
start =
|
96
|
-
finish =
|
98
|
+
start = verify_marker_presence(:start, @source.index(marker)) + marker.size
|
99
|
+
finish = verify_marker_presence(:end, @source.index('#END#', start)) - 1
|
97
100
|
@source[start..finish].strip
|
98
101
|
rescue Encoding::CompatibilityError => e
|
99
102
|
raise_parser_error 'Unable to parse document due to encoding error.', e
|
@@ -105,12 +108,22 @@ module RightmoveBLM
|
|
105
108
|
raise_parser_error "Unable to parse document. Error found in header for key `#{key}`", e
|
106
109
|
end
|
107
110
|
|
108
|
-
|
111
|
+
# INFO : for reverse compatibility. can remove this method and it's calls within this update.
|
112
|
+
# verify_file_structure should cover all cases of this method calls
|
113
|
+
def verify_marker_presence(type, val)
|
109
114
|
return val unless val.nil?
|
110
115
|
|
111
116
|
raise_parser_error "Unable to parse document: could not detect #{type} marker."
|
112
117
|
end
|
113
118
|
|
119
|
+
def verify_source_file_structure(source)
|
120
|
+
BLM_4_FILE_KEYWORDS.each do |keyword|
|
121
|
+
next if source.index(keyword)
|
122
|
+
|
123
|
+
raise_parser_error "Unable to process document with this structure: could not detect #{keyword} marker."
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
114
127
|
def generated_date
|
115
128
|
header[:'generated date'] || Time.now.utc.strftime('%d-%b-%Y %H:%M').upcase
|
116
129
|
end
|
data/rightmove_blm.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary
|
12
12
|
spec.description = 'Parse and generate Rightmove BLM files'
|
13
|
-
spec.required_ruby_version = '>= 2.7'
|
13
|
+
spec.required_ruby_version = '>= 2.7.1'
|
14
14
|
|
15
15
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
16
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rightmove_blm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parse and generate Rightmove BLM files
|
14
14
|
email: git@bob.frl
|
@@ -45,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 2.7.1
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|