rightmove_blm 0.2.8 → 0.2.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ec340ad11adaadec9ee744185f62256797740385074cbf5a36d9913e5820bb7
4
- data.tar.gz: 796260e176480613f01e44120088dc3806e54eea0b45eda665a50dd1c1d984ab
3
+ metadata.gz: c36cee929807f94509cb288993f9397a15692e2864da29590e7203e49d5cecd6
4
+ data.tar.gz: daddb217445d0d89ac2c319d6243167fcd08d6c042566d31389837947992ffb2
5
5
  SHA512:
6
- metadata.gz: 4b684cc031000728ae2e69674192bb5620c6189917ba157e0be33e59b98c50d9b089ccdba136c05cb5ac3c3a3efe96dc9b56a6428df4caa15cb2e049f87e2315
7
- data.tar.gz: 715ae92488da5080b281633c0d0d75e6c26162434492569356c10815fc5e51b3917b631da6c4bab28530db20e4385070255d7a988b08d82e3939299bba25d39b
6
+ metadata.gz: f66e75f7d997d70f1212584ebaf531d35027e61add06d57df3684157de0284993ba33ed93a9f8014ce0d6c3bb762bcbce8f037f1066c6d8903a011c4bf9b3c71
7
+ data.tar.gz: c5322e77e44c19ee6d070042917ea07afd5808902773cf3f52e88df7262ed079ff68b4a1a88dcd6b1b38077fd48a833d43043df3d4d115e41b2392a6b4c17db3
data/README.md CHANGED
@@ -68,3 +68,9 @@ The keys from the first _hash_ in the provided _array_ are used to provide the f
68
68
  document = RightmoveBLM::Document.from_array_of_hashes([{ field1: 'foo', field2: 'bar' }, { field1: 'baz', field2: 'foobar' }])
69
69
  File.write('my_data.blm', document.to_blm)
70
70
  ```
71
+
72
+ To generate a Rightmove document with version 3i, provide `true` for the optional parameter `international`.
73
+
74
+ ```ruby
75
+ document = RightmoveBLM::Document.from_array_of_hashes([{ field1: 'foo', field2: 'bar' }, { field1: 'baz', field2: 'foobar' }], international: true)
76
+ ```
@@ -5,9 +5,10 @@ module RightmoveBLM
5
5
  class Document # rubocop:disable Metrics/ClassLength
6
6
  BLM_FILE_SECTIONS = %w[HEADER DEFINITION DATA END].freeze
7
7
 
8
- def self.from_array_of_hashes(array)
8
+ def self.from_array_of_hashes(array, international: false, eor: '~', eof: '^')
9
9
  date = Time.now.utc.strftime('%d-%b-%Y %H:%M').upcase
10
- header = { version: '3', eof: '^', eor: '~', 'property count': array.size.to_s, 'generated date': date }
10
+ version = international ? '3i' : '3'
11
+ header = { version: version, eof: eof, eor: eor, 'property count': array.size.to_s, 'generated date': date }
11
12
  new(header: header, definition: array.first.keys.map(&:to_sym), data: array)
12
13
  end
13
14
 
@@ -54,7 +55,7 @@ module RightmoveBLM
54
55
  end
55
56
 
56
57
  def definition
57
- @definition ||= contents(:definition).split(header[:eor]).first.split(header[:eof]).map do |field|
58
+ @definition ||= contents(:definition).split(eor).first.split(eof).map do |field|
58
59
  next nil if field.empty?
59
60
 
60
61
  field.downcase.strip
@@ -129,20 +130,28 @@ module RightmoveBLM
129
130
  end
130
131
 
131
132
  def header_string
132
- ['#HEADER#', "VERSION : #{header[:version]}", "EOF : '|'", "EOR : '~'",
133
+ ['#HEADER#', "VERSION : #{header[:version]}", "EOF : '#{eof}'", "EOR : '#{eor}'",
133
134
  "Property Count : #{data.size}", "Generated Date : #{generated_date}", '']
134
135
  end
135
136
 
136
137
  def definition_string
137
- ['#DEFINITION#', "#{definition.join('|')}|~", '']
138
+ ['#DEFINITION#', "#{definition.join(eof)}#{eof}#{eor}", '']
138
139
  end
139
140
 
140
141
  def data_string
141
- ['#DATA#', *data.map { |row| "#{row.attributes.values.join('|')}~" }, '#END#']
142
+ ['#DATA#', *data.map { |row| "#{row.attributes.values.join(eof)}#{eor}" }, '#END#']
142
143
  end
143
144
 
144
145
  def raise_parser_error(message, cause = nil)
145
146
  raise ParserError, "#{inspect(safe: true)}: #{message} #{cause}"
146
147
  end
148
+
149
+ def eor
150
+ header[:eor]
151
+ end
152
+
153
+ def eof
154
+ header[:eof]
155
+ end
147
156
  end
148
- end
157
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RightmoveBLM
4
- VERSION = '0.2.8'
4
+ VERSION = '0.2.10'
5
5
  end
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.8
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-27 00:00:00.000000000 Z
11
+ date: 2024-10-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parse and generate Rightmove BLM files
14
14
  email: git@bob.frl
@@ -37,7 +37,7 @@ licenses:
37
37
  - MIT
38
38
  metadata:
39
39
  rubygems_mfa_required: 'true'
40
- post_install_message:
40
+ post_install_message:
41
41
  rdoc_options: []
42
42
  require_paths:
43
43
  - lib
@@ -52,8 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.4.13
56
- signing_key:
55
+ rubygems_version: 3.1.6
56
+ signing_key:
57
57
  specification_version: 4
58
58
  summary: A parser for the Rightmove .blm format
59
59
  test_files: []