rightmove 0.2.1 → 0.2.2

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/rightmove.rb +10 -10
  3. data/spec/rightmove_spec.rb +6 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/lib/rightmove.rb CHANGED
@@ -3,6 +3,8 @@ require 'blm'
3
3
 
4
4
  module Rightmove
5
5
  class Archive
6
+ attr_accessor :document, :zip_file, :branch_id, :timestamp
7
+
6
8
  def initialize(file = nil, options = {})
7
9
  open(file) unless file.nil?
8
10
  end
@@ -11,23 +13,15 @@ module Rightmove
11
13
  self.zip_file = file
12
14
  read(arguments)
13
15
  end
14
-
15
- def document
16
- @document
17
- end
18
-
19
- def zip_file
20
- @zip_file
21
- end
22
16
 
23
17
  def zip_file=(file)
24
- puts "derp"
25
18
  if file.instance_of?(Zip::ZipFile)
26
19
  @zip_file = file
27
20
  else
28
21
  return false unless File.exists?(file)
29
22
  @zip_file = Zip::ZipFile.open(file)
30
23
  end
24
+ parse_file_name
31
25
  end
32
26
 
33
27
  private
@@ -35,6 +29,12 @@ module Rightmove
35
29
  blm = self.zip_file.entries.select! {|v| v.to_s =~ /\.blm/i }.first
36
30
  @document = BLM::Document.new( self.zip_file.read(blm) )
37
31
  end
32
+
33
+ def parse_file_name
34
+ branch_id, timestamp = @zip_file.to_s.split("_").pop(2)
35
+ @branch_id = branch_id.to_i
36
+ @timestamp = Time.new(timestamp)
37
+ end
38
38
  end
39
39
  end
40
40
 
@@ -44,7 +44,7 @@ module BLM
44
44
  unless @attributes[method].nil?
45
45
  value = @attributes[method]
46
46
  if arguments[:instantiate_with]
47
- return value unless value =~ /\.(jpg|png|gif)/i
47
+ return value unless value =~ /\.jpg/i
48
48
  if arguments[:instantiate_with].instance_of?(Zip::ZipFile)
49
49
  zip = arguments[:instantiate_with]
50
50
  else
@@ -4,7 +4,7 @@ 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
+ @zip_file = Zip::ZipFile.open(File.dirname(__FILE__) + "/rightmove/rmc_2559_20050908161421.zip")
8
8
  end
9
9
 
10
10
  it "should open the zip file and return useful data" do
@@ -16,5 +16,10 @@ describe Rightmove do
16
16
  @rm.document.data.first.media_image_00(:instantiate_with => @zip_file).should be_a(StringIO)
17
17
  @rm.document.data.first.media_image_00.should be_a(String)
18
18
  end
19
+
20
+ it "should provide the branch id and timestamp of the file" do
21
+ @rm.branch_id.should be_a(Integer)
22
+ @rm.timestamp.should be_a(Time)
23
+ end
19
24
  end
20
25
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Robert May
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- hash: -108944433
138
+ hash: -611782865
139
139
  segments:
140
140
  - 0
141
141
  version: "0"