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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb84e12719ee64149ce55090e044b3c3e0b9b53b
4
- data.tar.gz: 640e9f0767bd8eb9b3106b7318a9c6ba34919e6c
3
+ metadata.gz: 3f38a45ae4c97e921217cdc3f2356967d69c5d1b
4
+ data.tar.gz: 0923d54e09b5e94ee492a8d2548e3115ba22e417
5
5
  SHA512:
6
- metadata.gz: 5e1b5b0d89eb6e7de6d653513249933f31a9d585235686c6da68ad721adf52a48e516df5eaff89cbd963e414c1b34435732605f64e7e44ed4e31342117fd7ab1
7
- data.tar.gz: 144af9b89a679f9614862d34947337ec034db04672c95d2fa5e4342b6bd01eb5ab6b4b81cc51305681d70ccde680e8ed589cd60491902c1c20bd77ed5c575738
6
+ metadata.gz: 6f30dd75b849c05dd81c6c6a7c941e95d50ab921714faf103baeadfe21324f081b1ed84d0138a398fb546fa21558fbdeb28896fb0e83b0e506db3226476fdde0
7
+ data.tar.gz: 0eaee104168e6c1da58663f53b0abaea7e52d6a31919ea4822ef851cb4728f1713ad153bca180bf57c3e56563e4453b9bea68b73fe3bbc95368b07316b8cc679
@@ -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
- puts '----------------------'
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 "invalid usage...\n" << usage << "\n\n"
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 value =~ /^(>|<|>=|<=|==)\d*.\d*?$/ if match[:key].to_sym.eql?(:price)
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 "invalid parameters"
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 (args)
59
- validate_args (args)
57
+ def initialize(args)
58
+ validate_args(args)
60
59
  pages
61
60
  end
62
61
  end
@@ -67,7 +67,6 @@ module QueenShopScraper
67
67
  end
68
68
 
69
69
  def scrape (params=[])
70
- params = ARGV.empty? ? params : ARGV
71
70
  conf = QConfig.new(params)
72
71
  @price_filter = conf.parameters[:price]
73
72
 
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
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-23 00:00:00.000000000 Z
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