rightmove_blm 0.1.0 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +15 -13
- data/VERSION +1 -1
- data/lib/rightmove_blm/document.rb +3 -3
- data/lib/rightmove_blm/version.rb +1 -1
- data/rightmove_blm.gemspec +2 -6
- metadata +8 -12
- data/spec/blm_spec.rb +0 -72
- data/spec/spec_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d86b0d52da5fad3fdac5c44ad7cc0ee515b67b6f4bdb7b2abd25ae92cd65aad3
|
4
|
+
data.tar.gz: 84d91eda581f2a813bd5da72db9f2a9384262505913074077ba78fe104169bd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 653deacb786ab85ba54a77318e62f36fc570c2da370163b475191003190db55d7d77e4019924e2643c56ad00b2a04060ae142fc57eb65f5997f0aa41ee53e9dc
|
7
|
+
data.tar.gz: e16d71c8a41018d8d4adbeedf69059e5b111a3dbb22a23f818ab36c7d6545529eed67d1f6cbba0d900811bf0abda5ebab79792f55852aecdce449021bc1e41d0
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.7
|
data/Gemfile.lock
CHANGED
@@ -3,16 +3,17 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
ast (2.4.2)
|
5
5
|
concurrent-ruby (1.1.8)
|
6
|
-
devpack (0.3.
|
6
|
+
devpack (0.3.3)
|
7
7
|
diff-lcs (1.4.4)
|
8
8
|
i18n (1.8.10)
|
9
9
|
concurrent-ruby (~> 1.0)
|
10
|
+
json (2.6.3)
|
10
11
|
paint (2.2.1)
|
11
|
-
parallel (1.
|
12
|
-
parser (3.
|
12
|
+
parallel (1.22.1)
|
13
|
+
parser (3.1.3.0)
|
13
14
|
ast (~> 2.4.1)
|
14
|
-
rainbow (3.
|
15
|
-
regexp_parser (2.
|
15
|
+
rainbow (3.1.1)
|
16
|
+
regexp_parser (2.6.1)
|
16
17
|
rexml (3.2.5)
|
17
18
|
rspec (3.10.0)
|
18
19
|
rspec-core (~> 3.10.0)
|
@@ -32,17 +33,18 @@ GEM
|
|
32
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
33
34
|
rspec-support (~> 3.10.0)
|
34
35
|
rspec-support (3.10.2)
|
35
|
-
rubocop (1.
|
36
|
+
rubocop (1.41.1)
|
37
|
+
json (~> 2.3)
|
36
38
|
parallel (~> 1.10)
|
37
|
-
parser (>= 3.
|
39
|
+
parser (>= 3.1.2.1)
|
38
40
|
rainbow (>= 2.2.2, < 4.0)
|
39
41
|
regexp_parser (>= 1.8, < 3.0)
|
40
|
-
rexml
|
41
|
-
rubocop-ast (>= 1.
|
42
|
+
rexml (>= 3.2.5, < 4.0)
|
43
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
42
44
|
ruby-progressbar (~> 1.7)
|
43
45
|
unicode-display_width (>= 1.4.0, < 3.0)
|
44
|
-
rubocop-ast (1.
|
45
|
-
parser (>=
|
46
|
+
rubocop-ast (1.24.0)
|
47
|
+
parser (>= 3.1.1.0)
|
46
48
|
rubocop-rspec (2.2.0)
|
47
49
|
rubocop (~> 1.0)
|
48
50
|
rubocop-ast (>= 1.1.0)
|
@@ -50,7 +52,7 @@ GEM
|
|
50
52
|
strong_versions (0.4.5)
|
51
53
|
i18n (>= 0.5)
|
52
54
|
paint (~> 2.0)
|
53
|
-
unicode-display_width (2.
|
55
|
+
unicode-display_width (2.3.0)
|
54
56
|
|
55
57
|
PLATFORMS
|
56
58
|
ruby
|
@@ -65,4 +67,4 @@ DEPENDENCIES
|
|
65
67
|
strong_versions (~> 0.4.5)
|
66
68
|
|
67
69
|
BUNDLED WITH
|
68
|
-
2.
|
70
|
+
2.3.7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
@@ -5,7 +5,7 @@ module RightmoveBLM
|
|
5
5
|
class Document
|
6
6
|
def self.from_array_of_hashes(array)
|
7
7
|
date = Time.now.utc.strftime('%d-%b-%Y %H:%M').upcase
|
8
|
-
header = { version: '3', eof: '^', eor: '~',
|
8
|
+
header = { version: '3', eof: '^', eor: '~', 'property count': array.size.to_s, 'generated date': date }
|
9
9
|
new(header: header, definition: array.first.keys.map(&:to_sym), data: array)
|
10
10
|
end
|
11
11
|
|
@@ -28,10 +28,10 @@ module RightmoveBLM
|
|
28
28
|
@header ||= contents(:header).each_line.map do |line|
|
29
29
|
next nil if line.empty?
|
30
30
|
|
31
|
-
key, _, value = line.partition('
|
31
|
+
key, _, value = line.partition(':')
|
32
32
|
next nil if value.nil?
|
33
33
|
|
34
|
-
[key.downcase.to_sym, value.tr("'", '').strip]
|
34
|
+
[key.strip.downcase.to_sym, value.tr("'", '').strip]
|
35
35
|
end.compact.to_h
|
36
36
|
end
|
37
37
|
|
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 = '
|
13
|
+
spec.required_ruby_version = '>= 2.7'
|
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)/}) }
|
@@ -19,10 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.homepage = 'http://github.com/robertmay/blm'
|
20
20
|
spec.licenses = ['MIT']
|
21
21
|
spec.require_paths = ['lib']
|
22
|
-
spec.rubygems_version = '1.3.7'
|
23
22
|
spec.summary = 'A parser for the Rightmove .blm format'
|
24
|
-
spec.
|
25
|
-
'spec/blm_spec.rb',
|
26
|
-
'spec/spec_helper.rb'
|
27
|
-
]
|
23
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
28
24
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parse and generate Rightmove BLM files
|
14
14
|
email: git@bob.frl
|
@@ -33,32 +33,28 @@ files:
|
|
33
33
|
- lib/rightmove_blm/row.rb
|
34
34
|
- lib/rightmove_blm/version.rb
|
35
35
|
- rightmove_blm.gemspec
|
36
|
-
- spec/blm_spec.rb
|
37
|
-
- spec/spec_helper.rb
|
38
36
|
homepage: http://github.com/robertmay/blm
|
39
37
|
licenses:
|
40
38
|
- MIT
|
41
|
-
metadata:
|
39
|
+
metadata:
|
40
|
+
rubygems_mfa_required: 'true'
|
42
41
|
post_install_message:
|
43
42
|
rdoc_options: []
|
44
43
|
require_paths:
|
45
44
|
- lib
|
46
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
46
|
requirements:
|
48
|
-
- - "
|
47
|
+
- - ">="
|
49
48
|
- !ruby/object:Gem::Version
|
50
|
-
version: '2.
|
49
|
+
version: '2.7'
|
51
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
52
|
- - ">="
|
54
53
|
- !ruby/object:Gem::Version
|
55
54
|
version: '0'
|
56
55
|
requirements: []
|
57
|
-
|
58
|
-
rubygems_version: 2.7.6.2
|
56
|
+
rubygems_version: 3.1.6
|
59
57
|
signing_key:
|
60
58
|
specification_version: 4
|
61
59
|
summary: A parser for the Rightmove .blm format
|
62
|
-
test_files:
|
63
|
-
- spec/blm_spec.rb
|
64
|
-
- spec/spec_helper.rb
|
60
|
+
test_files: []
|
data/spec/blm_spec.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RightmoveBLM do
|
4
|
-
context 'reading a .blm file' do
|
5
|
-
let(:data) { fixture('example_data.blm') }
|
6
|
-
let(:blm) { RightmoveBLM::Document.new(source: data.read) }
|
7
|
-
|
8
|
-
it 'should parse settings from the header' do
|
9
|
-
expect(blm.header).to be_a(Hash)
|
10
|
-
expect(blm.header[:version]).to_not be_nil
|
11
|
-
expect(blm.header[:eof]).to_not be_nil
|
12
|
-
expect(blm.header[:eor]).to_not be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should parse the column definition' do
|
16
|
-
expect(blm.definition).to be_a(Array)
|
17
|
-
expect(blm.definition.size).to be >= 1
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should parse the data into an array of hashes' do
|
21
|
-
expect(blm.data).to be_a(Array)
|
22
|
-
expect(blm.data.size).to be >= 1
|
23
|
-
expect(blm.data).to respond_to(:each, :each_with_index)
|
24
|
-
blm.data.each { |row| expect(row).to be_a(RightmoveBLM::Row) }
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should allow access to data values via methods' do
|
28
|
-
blm.data.each { |row| expect(row.address_1).to_not be_nil }
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should allow access to the @attributes hash directly' do
|
32
|
-
blm.data.each { |row| expect(row.attributes).to be_a(Hash) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'creating a .blm file' do
|
37
|
-
subject(:document) { RightmoveBLM::Document.from_array_of_hashes(data) }
|
38
|
-
|
39
|
-
let(:data) do
|
40
|
-
[{ field1: 'row 1 field 1 data', field2: 'row 1 field 2 data', field3: 'row 1 field 3 data' },
|
41
|
-
{ field1: 'row 2 field 1 data', field2: 'row 2 field 2 data', field3: 'row 2 field 3 data' }]
|
42
|
-
end
|
43
|
-
|
44
|
-
its(:header) { is_expected.to include({ 'property count': '2' }) }
|
45
|
-
its(:header) { is_expected.to include({ version: '3' }) }
|
46
|
-
its(:definition) { is_expected.to eql %i[field1 field2 field3] }
|
47
|
-
|
48
|
-
describe '#to_blm' do
|
49
|
-
let(:loaded_document) { RightmoveBLM::Document.new(source: subject.to_blm) }
|
50
|
-
|
51
|
-
it 'has a property count' do
|
52
|
-
expect(loaded_document.header[:'property count']).to eql '2'
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'has a version' do
|
56
|
-
expect(loaded_document.header[:version]).to eql '3'
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'has a "generated date" timestamp' do
|
60
|
-
expect(loaded_document.header[:'generated date']).to start_with Time.now.utc.strftime('%d-%b-%Y').upcase
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'has property data' do
|
64
|
-
expect(loaded_document.data.map(&:to_h)).to eql data
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'has a field definition' do
|
68
|
-
expect(loaded_document.definition).to eql %w[field1 field2 field3]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'devpack'
|
5
|
-
require 'rightmove_blm'
|
6
|
-
|
7
|
-
require 'rspec/file_fixtures'
|
8
|
-
require 'rspec/its'
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.example_status_persistence_file_path = '.rspec_status'
|
12
|
-
config.disable_monkey_patching!
|
13
|
-
config.expect_with :rspec do |c|
|
14
|
-
c.syntax = :expect
|
15
|
-
end
|
16
|
-
end
|