apmex-price 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 181fe4d5c0d581a0ca72957f4896d5c1e29e3a5c
4
- data.tar.gz: 6bf68ac2f74c09d8320749993a54b24cda6ecf43
3
+ metadata.gz: 1fff363ca9069a960361778b6b797a66d2918f3e
4
+ data.tar.gz: d9f67bc3c30bb2a8fb64ac5c3bb866f017964adb
5
5
  SHA512:
6
- metadata.gz: b5f3442b13c4afbea91e7699703ffe5c65680042c299faa04b84e7dd07bcb59b2fd8ee07647d42a579299f006ac80893aa2117bb6c4b2eeda053741bd91ac37d
7
- data.tar.gz: 7cc982bd3e1cc9208a453e6951e9c5bcd5c39c72241c5f3fec790a4fcdb09899794188c2d68ae21e018ea0c19ee0a7bb8fda62da4b8f47461fa5a2b0bb83088a
6
+ metadata.gz: a23a05a3284c8cbe20d1862297113d0eb87f5492e59a4d4d972fc8c0d4bcedae6093933286ef7b54054fd38e9db25ab27d9ab7098b288c0873516cde4cbfe286
7
+ data.tar.gz: 8132e9c56f424db67442031c4465bcf8f6a72fd1535571047df6ad9815487640ebd5ec89670e4dd3542ccd9dc4730deb419951972b1b7cad9fb998c2fc026c87
@@ -1,30 +1,30 @@
1
- require 'nokogiri'
2
- require 'open-uri'
3
-
4
- class ApmexPrice
5
- attr_accessor :url, :page, :buy
6
-
7
- DOLLARS_REGEX = /(\d*,*\d+\.\d+)/
8
- BUY_CSS = 'div.page-content-main > div > div > strong'
9
-
10
- def initialize(url)
11
- @url = url
12
- match()
13
- end
14
-
15
- def match
16
- @page = Nokogiri::HTML(open(@url))
17
- @buy = match_dollars(BUY_CSS)
18
- end
19
-
20
- def match_dollars(dollars_css)
21
- dollars_text = @page.css(dollars_css).text
22
- dollars_match = DOLLARS_REGEX.match(dollars_text)
23
-
24
- if dollars_match != nil
25
- dollars_match[1].gsub(',', '').to_f
26
- else
27
- 0.0
28
- end
29
- end
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ class ApmexPrice
5
+ attr_accessor :url, :page, :buy
6
+
7
+ DOLLARS_REGEX = /(\d*,*\d+\.\d+)/
8
+ BUY_CSS = 'div.page-content-main > div > div > strong'
9
+
10
+ def initialize(url)
11
+ @url = url
12
+ match()
13
+ end
14
+
15
+ def match
16
+ @page = Nokogiri::HTML(open(@url))
17
+ @buy = match_dollars(BUY_CSS)
18
+ end
19
+
20
+ def match_dollars(dollars_css)
21
+ dollars_text = @page.css(dollars_css).text
22
+ dollars_match = DOLLARS_REGEX.match(dollars_text)
23
+
24
+ if dollars_match != nil
25
+ dollars_match[1].gsub(',', '').to_f
26
+ else
27
+ 0.0
28
+ end
29
+ end
30
30
  end
@@ -1,38 +1,42 @@
1
- require 'minitest/autorun'
2
- require_relative '../lib/apmex-price'
3
-
4
- class ApmexPriceTest < Minitest::Test
5
- def test_
6
- apmex_urls = [
7
- 'http://www.apmex.com/sell-to-us/71274',
8
- 'http://www.apmex.com/sell-to-us/59146',
9
- 'http://www.apmex.com/sell-to-us/12082',
10
- 'http://www.apmex.com/sell-to-us/57010',
11
- 'http://www.apmex.com/sell-to-us/59157',
12
- 'http://www.apmex.com/sell-to-us/79019',
13
- 'http://www.apmex.com/sell-to-us/54875',
14
- 'http://www.apmex.com/sell-to-us/54875',
15
- 'http://www.apmex.com/sell-to-us/84445',
16
- 'http://www.apmex.com/sell-to-us/79047',
17
- 'http://www.apmex.com/sell-to-us/79021',
18
- 'http://www.apmex.com/sell-to-us/79573',
19
- 'http://www.apmex.com/sell-to-us/71264',
20
- 'http://www.apmex.com/sell-to-us/79041',
21
- 'http://www.apmex.com/sell-to-us/56011',
22
- 'http://www.apmex.com/sell-to-us/72454',
23
- 'http://www.apmex.com/sell-to-us/72458',
24
- 'http://www.apmex.com/sell-to-us/69514',
25
- 'http://www.apmex.com/sell-to-us/11951',
26
- 'http://www.apmex.com/sell-to-us/57159',
27
- 'http://www.apmex.com/sell-to-us/43309',
28
- 'http://www.apmex.com/sell-to-us/72281',
29
- 'http://www.apmex.com/sell-to-us/72281'
30
- ]
31
-
32
- apmex_urls.each do |u|
33
- a = ApmexPrice.new(u)
34
- puts a.buy.to_s
35
- assert a.buy.is_a? Float
36
- end
37
- end
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/apmex-price'
3
+
4
+ class ApmexPriceTest < Minitest::Test
5
+ def test_
6
+ apmex_urls = [
7
+ 'http://www.apmex.com/sell-to-us/3',
8
+ 'http://www.apmex.com/sell-to-us/59146',
9
+ 'http://www.apmex.com/sell-to-us/12082',
10
+ 'http://www.apmex.com/sell-to-us/57010',
11
+ 'http://www.apmex.com/sell-to-us/59157',
12
+ 'http://www.apmex.com/sell-to-us/79019',
13
+ 'http://www.apmex.com/sell-to-us/92698',
14
+ 'http://www.apmex.com/sell-to-us/54875',
15
+ 'http://www.apmex.com/sell-to-us/54875',
16
+ 'http://www.apmex.com/sell-to-us/84445',
17
+ 'http://www.apmex.com/sell-to-us/4233',
18
+ 'http://www.apmex.com/sell-to-us/79021',
19
+ 'http://www.apmex.com/sell-to-us/71264',
20
+ 'http://www.apmex.com/sell-to-us/79041',
21
+ 'http://www.apmex.com/sell-to-us/56011',
22
+ 'http://www.apmex.com/sell-to-us/93757',
23
+ 'http://www.apmex.com/sell-to-us/72454',
24
+ 'http://www.apmex.com/sell-to-us/72458',
25
+ 'http://www.apmex.com/sell-to-us/79573',
26
+ 'http://www.apmex.com/sell-to-us/69514',
27
+ 'http://www.apmex.com/sell-to-us/87944',
28
+ 'http://www.apmex.com/sell-to-us/11951',
29
+ 'http://www.apmex.com/sell-to-us/57159',
30
+ 'http://www.apmex.com/sell-to-us/92390',
31
+ 'http://www.apmex.com/sell-to-us/43309',
32
+ 'http://www.apmex.com/sell-to-us/72281',
33
+ 'http://www.apmex.com/sell-to-us/72281'
34
+ ]
35
+
36
+ apmex_urls.each do |u|
37
+ a = ApmexPrice.new(u)
38
+ puts a.buy.to_s
39
+ assert a.buy.is_a? Float
40
+ end
41
+ end
38
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apmex-price
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cscribn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.8.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.8.1
41
41
  description: Do you own precious metals? Are you interested in getting the current
42
42
  value of your collection? If so, this gem is for you. Simply find the URL of a
43
43
  product you are interested in, pass it as an argument, and you will get back the
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 2.2.3
73
+ rubygems_version: 2.6.11
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Get buy price of precious metals using apmex.com URLs.