hmc_outlets 0.0.0 → 0.1.0

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
  SHA1:
3
- metadata.gz: a592f16ef570a669c9073bd41d00b98a98c2c40c
4
- data.tar.gz: 629f9918e1e8accba5640da4c5f5835d71a5cf7f
3
+ metadata.gz: 323afb28f7ad62bb07bd09b228e9a37ad1fe81d0
4
+ data.tar.gz: 076ceeeebca510bd91538fdecffe6d0652e7836f
5
5
  SHA512:
6
- metadata.gz: b7d422f3ca8fd1f197dc05f4c0fa715efc55d79684ff16abed7e4942fc2fc33bb09cfa386c889d00bef40e12d5346de3250b49fc2a5d4ca5b45c162adc56d489
7
- data.tar.gz: 7ab00285670a6ef8a7975fa4bd7214e41b9807509ebb09d30c29fbfda2e31dbb56b345ed0b9a1d78e20cfd54b6eff092286bbd55f90996dce8cd38dca1f879bd
6
+ metadata.gz: 1d230d6c46b03eb0bf4e43d27c1e512848370b2b56fd8b8a87ae44fb10531772a4035366d14ac7316cd411c004427c7327db877f10a56455c6b3cddf80e9a9d1
7
+ data.tar.gz: a6f5a56d346fddb87e5c83e84cb29776c582706da7696fd64d202abfeb641c890c96e6cc023b9960a095594226fb8c4a2417db0eadd056158ec79e61fab16932
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # HmcOutlets
2
2
 
3
+ [![Coverage Status](https://coveralls.io/repos/AprenticeButchr/hmc_outlets/badge.svg?branch=master&service=github)](https://coveralls.io/github/AprenticeButchr/hmc_outlets?branch=master)
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/hmc_outlets.svg)](https://badge.fury.io/rb/hmc_outlets)
6
+
7
+ [![Build Status](https://travis-ci.org/AprenticeButchr/hmc_outlets.svg?branch=v0.1.0)](https://travis-ci.org/AprenticeButchr/hmc_outlets)
3
8
 
4
9
  This a pretty simple gem that grabs HMC's certified list and gives back some simple information.
5
10
 
@@ -47,7 +52,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
47
52
 
48
53
  ## Contributing
49
54
 
50
- 1. Fork it ( https://github.com/[my-github-username]/hmc_outlets/fork )
55
+ 1. Fork it ( https://github.com/AprenticeButchr/hmc_outlets/fork )
51
56
  2. Create your feature branch (`git checkout -b my-new-feature`)
52
57
  3. Commit your changes (`git commit -am 'Add some feature'`)
53
58
  4. Push to the branch (`git push origin my-new-feature`)
data/hmc_outlets.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Abdullah Hashim"]
10
10
  spec.email = ["aprenticebutchr@gmail.com"]
11
11
  spec.summary = "Gives some basic information on certified outlets"
12
- spec.description = "Checks against HMC's outlet page to determine if an outlet is certified, removed or otherwise."
12
+ spec.description = "Checks against HMC's outlet page and collects data about outlets registered with HMC, including if they are certified or revoked."
13
13
  spec.homepage = "https://github.com/AprenticeButchr/hmc_outlets"
14
14
  spec.license = "MIT"
15
15
 
data/lib/hmc_outlets.rb CHANGED
@@ -6,19 +6,52 @@ module HmcOutlets
6
6
  CERTIFIED_OUTLETS_URI = "http://www.halalhmc.org/certified-outlets-results.htm#result"
7
7
 
8
8
  def self.certified?(outlet_name)
9
- certified_outlets.include?(outlet_name)
9
+ certified_outlet_list.include?(outlet_name)
10
10
  end
11
11
 
12
- def self.removed?(outlet_name)
13
- removed_outlets.include?(outlet_name)
12
+ def self.revoked?(outlet_name)
13
+ revoked_outlet_list.include?(outlet_name)
14
+ end
15
+
16
+ def self.outlet_list
17
+ @outlet_list ||= outlets.map { |o| o[:name] }
18
+ end
19
+
20
+ def self.certified_outlet_list
21
+ @certified_outlet_list ||= certified_outlets.map { |o| o[:name] }
22
+ end
23
+
24
+ def self.revoked_outlet_list
25
+ @removed_outlets ||= revoked_outlets.map { |o| o[:name] }
26
+ end
27
+
28
+ def self.outlets
29
+ unless @outlets
30
+ @outlets = Array.new
31
+ outlets_page.css('table.outlettable tr').each do |o|
32
+ if o.css('strong').size > 0 # if the table row has no strong element it means that it is not an outlet row.
33
+ address = o.at_css('td[4]').text.gsub(/\t|,/, '').split("\n")
34
+ @outlets << {
35
+ name: o.at_css('strong').text.gsub(/[[:space:]]$/, ''),
36
+ phone: o.at_css('.tel').text.gsub(/[[:space:]]$/, ''),
37
+ street: address[0],
38
+ city: address[1],
39
+ county: address[2],
40
+ postcode: address[3],
41
+ status: o.css('td.removed').size == 0 ? "certified" : "revoked"
42
+ }
43
+ end
44
+ end
45
+ end
46
+ @outlets
14
47
  end
15
48
 
16
49
  def self.certified_outlets
17
- @certified_outlets ||= outlets_page.css('table.outlettable tr td:not(.removed) strong').map { |name| name.text.gsub(/[[:space:]]$/, '') }
50
+ @certified_outlets ||= outlets.select { |o| o[:status] == 'certified' }
18
51
  end
19
52
 
20
- def self.removed_outlets
21
- @removed_outlets ||= outlets_page.css('table.outlettable tr td.removed strong').map { |name| name.text.gsub(/[[:space:]]$/, '') }
53
+ def self.revoked_outlets
54
+ @revoked_outlets ||= outlets.select { |o| o[:status] == 'revoked' }
22
55
  end
23
56
 
24
57
  private
@@ -1,3 +1,3 @@
1
1
  module HmcOutlets
2
- VERSION = "0.0.0"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hmc_outlets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdullah Hashim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-29 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,8 +122,8 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.6'
125
- description: Checks against HMC's outlet page to determine if an outlet is certified,
126
- removed or otherwise.
125
+ description: Checks against HMC's outlet page and collects data about outlets registered
126
+ with HMC, including if they are certified or revoked.
127
127
  email:
128
128
  - aprenticebutchr@gmail.com
129
129
  executables: []