holden-hostelify 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.
data/hostelify.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hostelify}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Holden Thomas"]
data/lib/hostel/hostel.rb CHANGED
@@ -1,4 +1,4 @@
1
- class Hostel
1
+ class Hostelify
2
2
  attr_accessor :hostel_id, :name, :address, :description, :facilities, :ratings, :directions, :geo, :images, :video, :availability
3
3
  attr_accessor :rating, :dorm, :single, :unavailable
4
4
 
@@ -11,7 +11,7 @@ class Hostel
11
11
 
12
12
  end
13
13
 
14
- class HostelCollection < Array
14
+ class HostelifyCollection < Array
15
15
  # This collection does everything an Array does, plus
16
16
  # you can add utility methods like names.
17
17
 
@@ -35,7 +35,7 @@ class HostelCollection < Array
35
35
 
36
36
  end
37
37
 
38
- class HostelAvailable
38
+ class HostelifyAvailable
39
39
  attr_accessor :name, :price, :spots, :bookdate
40
40
 
41
41
  def initialize(name, price, spots, bookdate)
@@ -25,7 +25,7 @@ class Hostelbookers
25
25
 
26
26
  data = data.search("//div[@id='propertyResultsList']")
27
27
  #@results = []
28
- @results = HostelCollection.new
28
+ @results = HostelifyCollection.new
29
29
  #coder = HTMLEntities.new
30
30
  (data/"tr.propertyRow").each do |row|
31
31
  name = row.at("a.propertyTitle").inner_text
@@ -37,8 +37,8 @@ class Hostelbookers
37
37
  single = row.at("td.private/text()")
38
38
  hb_id = url.match(/[\d]{2,5}.$/).to_s.to_i
39
39
 
40
- #@results << Hostel.new(:hostel_id => hb_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single)
41
- @results << Hostel.new(:hostel_id => hb_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single)
40
+ #@results << Hostelify.new(:hostel_id => hb_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single)
41
+ @results << Hostelify.new(:hostel_id => hb_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single)
42
42
  end
43
43
  return @results
44
44
  end
@@ -49,7 +49,7 @@ class Hostelbookers
49
49
  id = options[:id]
50
50
  url = HB_SINGULAR_DETAIL_URL + "#{country}/#{city}/#{id}"
51
51
 
52
- hostel = Hostel.new
52
+ hostel = Hostelify.new
53
53
 
54
54
  if options[:date]
55
55
  options = @default_options.merge(options)
@@ -118,7 +118,7 @@ class Hostelbookers
118
118
  price = price.inner_text.to_s.match(/[\d.]{1,5}/)[0] unless price.nil?
119
119
  (0..(options[:no_days].to_i-1)).each do |x|
120
120
  #@availables << { :name => name, :spots => people, :price => price, :bookdate => (date+x).to_s } unless price.nil?
121
- @availables << HostelAvailable.new(name,price,people,(date+x).to_s) unless price.nil?
121
+ @availables << HostelifyAvailable.new(name,price,people,(date+x).to_s) unless price.nil?
122
122
  end
123
123
  end
124
124
  end
@@ -25,7 +25,7 @@ class Hostelworld
25
25
  url = HW_SINGULAR_DETAIL_URL + id
26
26
 
27
27
  #coder = HTMLEntities.new
28
- hostel = Hostel.new
28
+ hostel = Hostelify.new
29
29
  hostel.hostel_id = id
30
30
 
31
31
  if options[:date]
@@ -107,7 +107,7 @@ class Hostelworld
107
107
  end
108
108
 
109
109
  data = data.search("//div[@id='content']")
110
- @results = HostelCollection.new
110
+ @results = HostelifyCollection.new
111
111
 
112
112
  (data/"div.hostelListing").each do |row|
113
113
  name = row.at("h3").inner_text
@@ -124,9 +124,9 @@ class Hostelworld
124
124
  single = row.at("p.hostelListingPrivateRate/span.blueBeds/text()").to_s.gsub(/[A-Z$]*/,'')
125
125
  available = row/"ul.hostelListingDates/li.noAvail/text()"
126
126
  available = available.to_a.join(',').split(',')
127
- @results << Hostel.new(:hostel_id => hostel_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single, :unavailable => available)
127
+ @results << Hostelify.new(:hostel_id => hostel_id, :name => name, :description => desc, :rating => rating, :dorm => dorm, :single => single, :unavailable => available)
128
128
  else
129
- @results << Hostel.new(:hostel_id => hostel_id, :name => name, :description => desc, :rating => rating)
129
+ @results << Hostelify.new(:hostel_id => hostel_id, :name => name, :description => desc, :rating => rating)
130
130
  end
131
131
  end
132
132
  return @results
@@ -190,9 +190,9 @@ class Hostelworld
190
190
 
191
191
  if available
192
192
  beds = available.to_s.match(/[\d]{1,2}/)[0]
193
- availables << HostelAvailable.new(name,price,beds,date)
193
+ availables << HostelifyAvailable.new(name,price,beds,date)
194
194
  else
195
- availables << HostelAvailable.new(name,price,0,date)
195
+ availables << HostelifyAvailable.new(name,price,0,date)
196
196
  end
197
197
  end
198
198
  end
data/spec/_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
- require 'hostel'
4
+ require 'hostelify'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holden-hostelify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Holden Thomas