queenshop 0.0.4 → 0.0.5
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/lib/queenshop/config.rb +9 -10
- data/lib/queenshop/scraper.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f38a45ae4c97e921217cdc3f2356967d69c5d1b
|
4
|
+
data.tar.gz: 0923d54e09b5e94ee492a8d2548e3115ba22e417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f30dd75b849c05dd81c6c6a7c941e95d50ab921714faf103baeadfe21324f081b1ed84d0138a398fb546fa21558fbdeb28896fb0e83b0e506db3226476fdde0
|
7
|
+
data.tar.gz: 0eaee104168e6c1da58663f53b0abaea7e52d6a31919ea4822ef851cb4728f1713ad153bca180bf57c3e56563e4453b9bea68b73fe3bbc95368b07316b8cc679
|
data/lib/queenshop/config.rb
CHANGED
@@ -9,31 +9,29 @@ module Validate
|
|
9
9
|
VALID_ARGS = [:item, :price, :pages]
|
10
10
|
|
11
11
|
def validate_args(args)
|
12
|
-
@parameters = {item: '', price: '', pages: '1..2'}
|
13
|
-
|
14
|
-
puts args
|
12
|
+
@parameters = { item: '', price: '', pages: '1..2' }
|
13
|
+
|
15
14
|
args.each do |arg|
|
16
15
|
begin
|
17
16
|
match = /(?<key>.*?)=(?<value>.*)/.match(arg)
|
18
|
-
puts '..................................'
|
19
|
-
puts match
|
20
17
|
fail unless VALID_ARGS.include?(match[:key].to_sym)
|
21
18
|
value = check(match)
|
22
19
|
@parameters[match[:key].to_sym] = value
|
23
20
|
rescue StandardError
|
24
|
-
abort
|
21
|
+
abort 'invalid usage: ' << usage << "\n\n"
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end # end validate_args
|
28
25
|
|
29
26
|
def check(match)
|
30
27
|
value = match[:value]
|
31
|
-
fail unless
|
28
|
+
fail unless
|
29
|
+
value =~ /^(>|<|>=|<=|==)\d*.\d*?$/ if match[:key].to_sym.eql?(:price)
|
32
30
|
# Float(value) if match[:key].to_sym.eql?(:price)
|
33
31
|
fail unless value =~ /^\d*([.]{2}\d*)?$/ if match[:key].to_sym.eql?(:pages)
|
34
32
|
value
|
35
33
|
rescue StandardError
|
36
|
-
abort
|
34
|
+
abort 'invalid parameters'
|
37
35
|
end
|
38
36
|
|
39
37
|
def pages
|
@@ -53,10 +51,11 @@ module Validate
|
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
54
|
+
# basic config name conflic if called Config
|
56
55
|
class QConfig
|
57
56
|
include Validate
|
58
|
-
def initialize
|
59
|
-
validate_args
|
57
|
+
def initialize(args)
|
58
|
+
validate_args(args)
|
60
59
|
pages
|
61
60
|
end
|
62
61
|
end
|
data/lib/queenshop/scraper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queenshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Even Chang
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-10-
|
14
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: This is a gem scraping queenshop's website and returns the items with
|
17
17
|
corresponding prices
|