rightmove 0.1.0 → 0.2.1
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.
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -5
- data/VERSION +1 -1
- data/lib/rightmove.rb +39 -24
- data/spec/rightmove_spec.rb +5 -3
- metadata +4 -7
- data/.rspec +0 -1
- data/rightmove.gemspec +0 -72
- data/spec/rightmove/example.zip +0 -0
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
|
@@ -11,7 +11,6 @@ require 'rake'
|
|
|
11
11
|
|
|
12
12
|
require 'jeweler'
|
|
13
13
|
Jeweler::Tasks.new do |gem|
|
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
15
14
|
gem.name = "rightmove"
|
|
16
15
|
gem.homepage = "http://github.com/robertmay/rightmove"
|
|
17
16
|
gem.license = "MIT"
|
|
@@ -19,10 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
|
19
18
|
gem.description = %Q{This library is used to parse a Rightmove format zip file}
|
|
20
19
|
gem.email = "robotmay@gmail.com"
|
|
21
20
|
gem.authors = ["Robert May"]
|
|
22
|
-
|
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
|
24
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
|
25
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
|
21
|
+
gem.files.exclude 'spec'
|
|
26
22
|
end
|
|
27
23
|
Jeweler::RubygemsDotOrgTasks.new
|
|
28
24
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1
|
|
1
|
+
0.2.1
|
data/lib/rightmove.rb
CHANGED
|
@@ -2,49 +2,64 @@ require 'zip/zipfilesystem'
|
|
|
2
2
|
require 'blm'
|
|
3
3
|
|
|
4
4
|
module Rightmove
|
|
5
|
-
class Archive
|
|
6
|
-
@@configuration = {
|
|
7
|
-
:tmp_dir => "/tmp/rightmove/"
|
|
8
|
-
}
|
|
9
|
-
|
|
5
|
+
class Archive
|
|
10
6
|
def initialize(file = nil, options = {})
|
|
11
7
|
open(file) unless file.nil?
|
|
12
|
-
@@configuration.update(options)
|
|
13
8
|
end
|
|
14
9
|
|
|
15
|
-
def open(file, arguments)
|
|
16
|
-
|
|
17
|
-
@file = file
|
|
10
|
+
def open(file, arguments = {})
|
|
11
|
+
self.zip_file = file
|
|
18
12
|
read(arguments)
|
|
19
13
|
end
|
|
20
14
|
|
|
21
15
|
def document
|
|
22
16
|
@document
|
|
23
17
|
end
|
|
18
|
+
|
|
19
|
+
def zip_file
|
|
20
|
+
@zip_file
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def zip_file=(file)
|
|
24
|
+
puts "derp"
|
|
25
|
+
if file.instance_of?(Zip::ZipFile)
|
|
26
|
+
@zip_file = file
|
|
27
|
+
else
|
|
28
|
+
return false unless File.exists?(file)
|
|
29
|
+
@zip_file = Zip::ZipFile.open(file)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
24
32
|
|
|
25
33
|
private
|
|
26
34
|
def read(arguments)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
blm = @zip_file.entries.select! {|v| v.to_s =~ /\.blm/i }.first
|
|
30
|
-
@document = BLM::Document.new( zip.read(blm) )
|
|
31
|
-
instantiate_files if arguments[:instantiate_files]
|
|
32
|
-
end
|
|
33
|
-
@document
|
|
35
|
+
blm = self.zip_file.entries.select! {|v| v.to_s =~ /\.blm/i }.first
|
|
36
|
+
@document = BLM::Document.new( self.zip_file.read(blm) )
|
|
34
37
|
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
module BLM
|
|
42
|
+
class Row
|
|
43
|
+
def method_missing(method, arguments = {}, &block)
|
|
44
|
+
unless @attributes[method].nil?
|
|
45
|
+
value = @attributes[method]
|
|
46
|
+
if arguments[:instantiate_with]
|
|
47
|
+
return value unless value =~ /\.(jpg|png|gif)/i
|
|
48
|
+
if arguments[:instantiate_with].instance_of?(Zip::ZipFile)
|
|
49
|
+
zip = arguments[:instantiate_with]
|
|
50
|
+
else
|
|
51
|
+
zip = Zip::ZipFile.open(arguments[:instantiate_with])
|
|
52
|
+
end
|
|
53
|
+
matching_files = zip.entries.select! {|v| v.to_s =~ /#{value}/ }
|
|
41
54
|
unless matching_files.empty?
|
|
42
|
-
file = StringIO.new(
|
|
55
|
+
file = StringIO.new( zip.read(matching_files.first) )
|
|
43
56
|
file.class.class_eval { attr_accessor :original_filename, :content_type }
|
|
44
57
|
file.original_filename = matching_files.first.to_s
|
|
45
58
|
file.content_type = "image/jpg"
|
|
46
|
-
|
|
59
|
+
return file
|
|
47
60
|
end
|
|
61
|
+
else
|
|
62
|
+
value
|
|
48
63
|
end
|
|
49
64
|
end
|
|
50
65
|
end
|
data/spec/rightmove_spec.rb
CHANGED
|
@@ -4,15 +4,17 @@ describe Rightmove do
|
|
|
4
4
|
context "manipulating the file" do
|
|
5
5
|
before :all do
|
|
6
6
|
@rm = Rightmove::Archive.new
|
|
7
|
+
@zip_file = Zip::ZipFile.open(File.dirname(__FILE__) + "/rightmove/example.zip")
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
it "should open the zip file and return useful data" do
|
|
10
11
|
@rm.should respond_to(:open)
|
|
11
|
-
@rm.open(
|
|
12
|
+
@rm.open(@zip_file).should be_a(BLM::Document)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
it "should return images as StringIO objects" do
|
|
15
|
-
@rm.document.data.first.media_image_00.should be_a(StringIO)
|
|
15
|
+
it "should return images as StringIO objects if passed :instantiate_with" do
|
|
16
|
+
@rm.document.data.first.media_image_00(:instantiate_with => @zip_file).should be_a(StringIO)
|
|
17
|
+
@rm.document.data.first.media_image_00.should be_a(String)
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
end
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
+
- 2
|
|
7
8
|
- 1
|
|
8
|
-
|
|
9
|
-
version: 0.1.0
|
|
9
|
+
version: 0.2.1
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Robert May
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2011-01-
|
|
17
|
+
date: 2011-01-27 00:00:00 +00:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -112,7 +112,6 @@ extra_rdoc_files:
|
|
|
112
112
|
- README.textile
|
|
113
113
|
files:
|
|
114
114
|
- .document
|
|
115
|
-
- .rspec
|
|
116
115
|
- Gemfile
|
|
117
116
|
- Gemfile.lock
|
|
118
117
|
- LICENSE.txt
|
|
@@ -120,8 +119,6 @@ files:
|
|
|
120
119
|
- Rakefile
|
|
121
120
|
- VERSION
|
|
122
121
|
- lib/rightmove.rb
|
|
123
|
-
- rightmove.gemspec
|
|
124
|
-
- spec/rightmove/example.zip
|
|
125
122
|
- spec/rightmove_spec.rb
|
|
126
123
|
- spec/spec_helper.rb
|
|
127
124
|
has_rdoc: true
|
|
@@ -138,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
138
135
|
requirements:
|
|
139
136
|
- - ">="
|
|
140
137
|
- !ruby/object:Gem::Version
|
|
141
|
-
hash: -
|
|
138
|
+
hash: -108944433
|
|
142
139
|
segments:
|
|
143
140
|
- 0
|
|
144
141
|
version: "0"
|
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--color
|
data/rightmove.gemspec
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |s|
|
|
7
|
-
s.name = %q{rightmove}
|
|
8
|
-
s.version = "0.1.0"
|
|
9
|
-
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
-
s.authors = ["Robert May"]
|
|
12
|
-
s.date = %q{2011-01-26}
|
|
13
|
-
s.description = %q{This library is used to parse a Rightmove format zip file}
|
|
14
|
-
s.email = %q{robotmay@gmail.com}
|
|
15
|
-
s.extra_rdoc_files = [
|
|
16
|
-
"LICENSE.txt",
|
|
17
|
-
"README.textile"
|
|
18
|
-
]
|
|
19
|
-
s.files = [
|
|
20
|
-
".document",
|
|
21
|
-
".rspec",
|
|
22
|
-
"Gemfile",
|
|
23
|
-
"Gemfile.lock",
|
|
24
|
-
"LICENSE.txt",
|
|
25
|
-
"README.textile",
|
|
26
|
-
"Rakefile",
|
|
27
|
-
"VERSION",
|
|
28
|
-
"lib/rightmove.rb",
|
|
29
|
-
"rightmove.gemspec",
|
|
30
|
-
"spec/rightmove/example.zip",
|
|
31
|
-
"spec/rightmove_spec.rb",
|
|
32
|
-
"spec/spec_helper.rb"
|
|
33
|
-
]
|
|
34
|
-
s.homepage = %q{http://github.com/robertmay/rightmove}
|
|
35
|
-
s.licenses = ["MIT"]
|
|
36
|
-
s.require_paths = ["lib"]
|
|
37
|
-
s.rubygems_version = %q{1.3.7}
|
|
38
|
-
s.summary = %q{A library for parsing a Rightmove format zip file}
|
|
39
|
-
s.test_files = [
|
|
40
|
-
"spec/rightmove_spec.rb",
|
|
41
|
-
"spec/spec_helper.rb"
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
if s.respond_to? :specification_version then
|
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
46
|
-
s.specification_version = 3
|
|
47
|
-
|
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
49
|
-
s.add_runtime_dependency(%q<blm>, [">= 0"])
|
|
50
|
-
s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
|
|
51
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
52
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
53
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
54
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
55
|
-
else
|
|
56
|
-
s.add_dependency(%q<blm>, [">= 0"])
|
|
57
|
-
s.add_dependency(%q<rubyzip>, [">= 0"])
|
|
58
|
-
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
59
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
60
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
61
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
|
62
|
-
end
|
|
63
|
-
else
|
|
64
|
-
s.add_dependency(%q<blm>, [">= 0"])
|
|
65
|
-
s.add_dependency(%q<rubyzip>, [">= 0"])
|
|
66
|
-
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
67
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
68
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
69
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
data/spec/rightmove/example.zip
DELETED
|
Binary file
|