url_incrementer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/url_incrementer.rb +4 -36
- data/lib/url_incrementer/version.rb +1 -1
- data/spec/url_incrementer_spec.rb +19 -3
- data/url_incrementer.gemspec +0 -1
- metadata +8 -18
data/README.md
CHANGED
@@ -26,4 +26,4 @@ TODO: Write usage instructions here
|
|
26
26
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
27
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
29
|
+
5. Create new Pull Request
|
data/lib/url_incrementer.rb
CHANGED
@@ -10,13 +10,14 @@ module UrlIncrementer
|
|
10
10
|
self.page_size = options[:page_size]
|
11
11
|
self.offset = options[:offset] || 0
|
12
12
|
self.page_num = options[:page_num] || 0
|
13
|
-
|
13
|
+
# dates in next version
|
14
|
+
# self.page_date = options[:page_date] || DateTime.now
|
14
15
|
end
|
15
16
|
|
16
17
|
def update_counters
|
17
18
|
self.page_num += 1
|
18
19
|
self.offset += self.page_size
|
19
|
-
self.page_date += 1
|
20
|
+
# self.page_date += 1
|
20
21
|
end
|
21
22
|
|
22
23
|
def next
|
@@ -29,37 +30,4 @@ module UrlIncrementer
|
|
29
30
|
Hash[instance_variables.map { |name| [name.to_s.gsub('@', '').to_sym, instance_variable_get(name)] } ]
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
=begin
|
36
|
-
|
37
|
-
class UrlIncrementer
|
38
|
-
|
39
|
-
attr_accessor :type, :template, :page_size, :start_page, :event_list_css, :current_url, :tempate
|
40
|
-
attr_writer :page_num, :page_date, :entries
|
41
|
-
|
42
|
-
def page_num ; @page_num.nil? ? (self.start_page.nil? ? 1 : self.start_page) : @page_num end
|
43
|
-
def page_date ; @page_date.nil? ? Time.now : @page_date end
|
44
|
-
def entries ; @entries.nil? ? [] : @entries end
|
45
|
-
def date_format_1; "%Y-%m-%d" end
|
46
|
-
def date_format_2; "%m/%d/%Y" end
|
47
|
-
def date_format_3; "%Y/%m" end
|
48
|
-
def start_date; Time.now end
|
49
|
-
def end_date; 6.months.from_now end
|
50
|
-
|
51
|
-
def last_modified
|
52
|
-
@last_modified ||= begin
|
53
|
-
entry = entries.reject {|e| e.published.nil? }.sort_by { |entry| entry.published if entry.published }.last
|
54
|
-
entry ? entry.published : nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def updated?
|
59
|
-
@updated
|
60
|
-
end
|
61
|
-
|
62
|
-
def new_entries
|
63
|
-
@new_entries ||= []
|
64
|
-
end
|
65
|
-
=end
|
33
|
+
end
|
@@ -5,7 +5,23 @@ describe UrlIncrementer do
|
|
5
5
|
UrlIncrementer::VERSION.should_not be_nil
|
6
6
|
end
|
7
7
|
|
8
|
-
it 'should
|
9
|
-
|
8
|
+
it 'should increment using offsets' do
|
9
|
+
type = :offset
|
10
|
+
|
11
|
+
# test size 50 page starting at 0
|
12
|
+
template = "http://www.example.com/searchresults?rows=%{page_size}&start=%{offset}"
|
13
|
+
options = { page_size: 50, offset: 0 }
|
14
|
+
|
15
|
+
ui = UrlIncrementer::Inc.new(template, type, options)
|
16
|
+
ui.next.should == "http://www.example.com/searchresults?rows=50&start=0"
|
17
|
+
ui.next.should == "http://www.example.com/searchresults?rows=50&start=50"
|
18
|
+
ui.next.should == "http://www.example.com/searchresults?rows=50&start=100"
|
19
|
+
|
20
|
+
# test size 20 page starting at 1
|
21
|
+
options = { page_size: 20, offset: 1 }
|
22
|
+
ui = UrlIncrementer::Inc.new(template, type, options)
|
23
|
+
ui.next.should == "http://www.example.com/searchresults?rows=20&start=1"
|
24
|
+
ui.next.should == "http://www.example.com/searchresults?rows=20&start=21"
|
25
|
+
ui.next.should == "http://www.example.com/searchresults?rows=20&start=41"
|
10
26
|
end
|
11
|
-
end
|
27
|
+
end
|
data/url_incrementer.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_incrementer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -43,22 +43,6 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: handlebars
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
46
|
description: URL incremeter for traversing web pages
|
63
47
|
email:
|
64
48
|
- goldcaddy77@gmail.com
|
@@ -89,12 +73,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
73
|
- - ! '>='
|
90
74
|
- !ruby/object:Gem::Version
|
91
75
|
version: '0'
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
hash: 195399569
|
92
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
80
|
none: false
|
94
81
|
requirements:
|
95
82
|
- - ! '>='
|
96
83
|
- !ruby/object:Gem::Version
|
97
84
|
version: '0'
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
hash: 195399569
|
98
88
|
requirements: []
|
99
89
|
rubyforge_project:
|
100
90
|
rubygems_version: 1.8.25
|