samao 0.1.2 → 0.1.3

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: a483278b39eb8b7c7f68d9ccd02b9d8fa7bb5cec
4
- data.tar.gz: 307181057f12f81fca2a408a85dfa9de6fdedeaf
3
+ metadata.gz: 8052607754894bc0b6aab5725ced6198df5fc63a
4
+ data.tar.gz: 17102ace2e60b4eea948d1ee2263fe090381cc15
5
5
  SHA512:
6
- metadata.gz: e4608bbab36feb41b82f5779a7c2be74c45349b349b2243cbe30ccf4666c83a95e1407b7439a36c9f4ce0fb3eabc5bd0d2a9cca5b0c6529bde85355ae84afea0
7
- data.tar.gz: f181681e70dd14f9607f9a8002e2656522b6f4cb483aa3aa18153f6c2d5bc74619436997e3e1eac5a7d2e3558dfb66fae355bd2c3e73b80a6f39cb40ef8b38c7
6
+ metadata.gz: 24e2ef9f4883c62cb2ed5bd6925e9bf4990f522fd62a1a2f03534fee96ab7fc0a728dac663b92210a7a539229c3bbcdedf38297d89348b5d593f92a4ef459f9b
7
+ data.tar.gz: d72849be792f00b93b58fae10374b42359f8d51d67f9d82f0325162680f8f269bdf435596b5f6b8b1d09f3ca5e88f2b097312292ac21999ffcd418cc4ec1c415
data/README.md CHANGED
@@ -22,47 +22,52 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- #!/usr/bin/env ruby
26
- require 'samao'
27
-
28
- # create samao detector
29
- samao = Samao::Detector.new
30
-
31
- # set base url and start page
32
- samao.baseurl 'https://github.com'
33
- samao.from '/Lax?tab=repositories'
34
- # the following line have the same effect
35
- #samao.from 'https://github.com/Lax?tab=repositories'
36
-
37
- # tell samao how to find the next page
38
- samao.find :next, 'div.pagination a.next_page'
39
- samao.max_page 1
40
-
41
- # tell samao how to find items.
42
- # further more, set the data from matched HTML node/element.
43
- samao.find_item 'div#user-repositories-list li a[itemprop="name codeRepository"]' do |item|
44
- item.set_url :url, item.raw(:item)['href']
45
- item.set :title, item.raw(:item).text.strip
46
- end
47
-
48
- samao.find_item 'div#user-repositories-list li' do |item|
49
- item.find(:url, 'a[itemprop="name codeRepository"]') {|value| [:set_url, :url, value.first['href']] }
50
- item.find(:title, 'a[itemprop="name codeRepository"]') {|value| [:set, value.first.text.strip] }
51
- end
52
-
53
- # if it need to open content page for more information
54
- # default key is :url
55
- samao.add_detail :url do |detail|
56
- #samao.add_detail do |detail|
57
- detail.find(:author, 'h1.public .author a') {|value| value.first.text.strip }
58
- end
59
-
60
- # run the detector
61
- samao.run
62
-
63
- # read items
64
- p samao.items
65
- ## [{:url=>"https://github.com/Lax/awesome", :title=>"awesome", :author=>"Lax"}, {:url=>"https://github.com/Lax/lax.github.com", :title=>"lax.github.com", :author=>"Lax"}, ..]
25
+ ```ruby
26
+ #!/usr/bin/env ruby
27
+ require 'samao'
28
+
29
+ # create samao detector
30
+ samao = Samao::Detector.new
31
+
32
+ # set max concurrent level
33
+ samao.concurrent 3
34
+
35
+ # set base url and start page
36
+ samao.baseurl 'https://github.com'
37
+ samao.from '/Lax?tab=repositories'
38
+ # the following line have the same effect
39
+ #samao.from 'https://github.com/Lax?tab=repositories'
40
+
41
+ # tell samao how to find the next page
42
+ samao.find :next, 'div.pagination a.next_page'
43
+ samao.max_page 1
44
+
45
+ # tell samao how to find items.
46
+ # further more, set the data from matched HTML node/element.
47
+ samao.find_item 'div#user-repositories-list li a[itemprop="name codeRepository"]' do |item|
48
+ item.set_url :url, item.raw(:item)['href']
49
+ item.set :title, item.raw(:item).text.strip
50
+ end
51
+
52
+ samao.find_item 'div#user-repositories-list li' do |item|
53
+ item.find(:url, 'a[itemprop="name codeRepository"]') {|value| [:set_url, :url, value.first['href']] }
54
+ item.find(:title, 'a[itemprop="name codeRepository"]') {|value| [:set, value.first.text.strip] }
55
+ end
56
+
57
+ # if it need to open content page for more information
58
+ # default key is :url
59
+ samao.add_detail :url do |detail|
60
+ #samao.add_detail do |detail|
61
+ detail.find(:author, 'h1.public .author a') {|value| value.first.text.strip }
62
+ end
63
+
64
+ # run the detector
65
+ samao.run
66
+
67
+ # read items
68
+ p samao.items
69
+ ## [{:url=>"https://github.com/Lax/awesome", :title=>"awesome", :author=>"Lax"}, {:url=>"https://github.com/Lax/lax.github.com", :title=>"lax.github.com", :author=>"Lax"}, ..]
70
+ ```
66
71
 
67
72
  ## Development
68
73
 
@@ -113,12 +113,13 @@ module Samao
113
113
  self
114
114
  end
115
115
 
116
- # set max page
117
- def max_page(max)
118
- @max_page = max
116
+ # set max concurrent level
117
+ def max_concurrent(max)
118
+ @max_concurrent = max
119
119
 
120
120
  self
121
121
  end
122
+ alias :concurrent :max_concurrent
122
123
 
123
124
  # get pages
124
125
  def pages
@@ -1,3 +1,3 @@
1
1
  module Samao
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Lantao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2016-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri