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 +4 -4
- data/README.md +6 -1
- data/hmc_outlets.gemspec +1 -1
- data/lib/hmc_outlets.rb +39 -6
- data/lib/hmc_outlets/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 323afb28f7ad62bb07bd09b228e9a37ad1fe81d0
|
4
|
+
data.tar.gz: 076ceeeebca510bd91538fdecffe6d0652e7836f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d230d6c46b03eb0bf4e43d27c1e512848370b2b56fd8b8a87ae44fb10531772a4035366d14ac7316cd411c004427c7327db877f10a56455c6b3cddf80e9a9d1
|
7
|
+
data.tar.gz: a6f5a56d346fddb87e5c83e84cb29776c582706da7696fd64d202abfeb641c890c96e6cc023b9960a095594226fb8c4a2417db0eadd056158ec79e61fab16932
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# HmcOutlets
|
2
2
|
|
3
|
+
[](https://coveralls.io/github/AprenticeButchr/hmc_outlets?branch=master)
|
4
|
+
|
5
|
+
[](https://badge.fury.io/rb/hmc_outlets)
|
6
|
+
|
7
|
+
[](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/
|
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
|
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
|
-
|
9
|
+
certified_outlet_list.include?(outlet_name)
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
13
|
-
|
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 ||=
|
50
|
+
@certified_outlets ||= outlets.select { |o| o[:status] == 'certified' }
|
18
51
|
end
|
19
52
|
|
20
|
-
def self.
|
21
|
-
@
|
53
|
+
def self.revoked_outlets
|
54
|
+
@revoked_outlets ||= outlets.select { |o| o[:status] == 'revoked' }
|
22
55
|
end
|
23
56
|
|
24
57
|
private
|
data/lib/hmc_outlets/version.rb
CHANGED
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.
|
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-
|
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
|
126
|
-
|
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: []
|