webpage_update_checker 1.2.0 → 1.3.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
  SHA256:
3
- metadata.gz: 46e6b17d245cd2498f15e9c90cf27a0fe7eab44a5225df8b2f85e2ba1d0b3168
4
- data.tar.gz: e0ddec03ded73b0ff25fb501dd4ff109116312a8b6d8e755bf760fa7c944620c
3
+ metadata.gz: f8c2526d9cd437964c3c639911f5f67a47ac66864e6728ca16c5f3369b761bb0
4
+ data.tar.gz: 18acb4cde3a66373d7ddea4b1175d89b696ca52dc08be62e39a327f535dcdb79
5
5
  SHA512:
6
- metadata.gz: c0bff916a00b5d212371a290815641d8157bec705f132a437f1c04a6a78fba26be6fe60395339b1d5dd018a8d8c97763db25a7b50aa1c05bd39c7f9f4df35ef1
7
- data.tar.gz: f2b51da4b49bf233ab3c01b54fc2759d9222fc7706ab43974fef603abefdab023bca5f566ad6c6d026f5706989174a82321bac933a064fb2d86a11e68ab3b6ef
6
+ metadata.gz: 261c561477dce557e7ea8dcb849ef598040dafa37533dd5ec9a48a77c9ea9039b92adce9cc6cc18429fde9d1b567e8424be76556ad50a820d08209704bdd049b
7
+ data.tar.gz: eb0d9b21d0ec08687c1eb3b66944569ca01c146bbb26cab94352f5569195fd46c7fb037971078f79ce471d05bd5c0242553a3e619b962dc0b80ecf1c658d9c37
data/.gitignore CHANGED
@@ -51,3 +51,4 @@ build-iPhoneSimulator/
51
51
 
52
52
  .rspec_status
53
53
  .vscode
54
+ .history
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpage_update_checker (1.2.0)
4
+ webpage_update_checker (1.3.0)
5
5
  mechanize
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -7,11 +7,16 @@
7
7
 
8
8
  # Usage
9
9
  ```
10
- gem 'webpage_update_checker'
10
+ $ vim Gemfile
11
+ # Add a line
12
+ # gem 'webpage_update_checker'
13
+ $ bundle install
11
14
  ```
12
15
 
16
+ or
17
+
13
18
  ```bash
14
- $ bundle install
19
+ $ gem install webpage_update_checker
15
20
  ```
16
21
 
17
22
  ```ruby
@@ -20,9 +25,15 @@ require 'webpage_update_checker'
20
25
  checker = WebpageUpdateChecker::Client.new
21
26
  target_page_md5 = WebpageUpdateChecker::Methods::Md5.new(uri: 'http://www.ne.jp/asahi/pursuits/ootsuki/pc/X68k/x680x0.xhtml')
22
27
 
23
- checker.current_diff_value(target_page_md5) #=> fb2eeb524e6b5637ef7fa4bed48f1d67
24
- checker.updated?(target_page_md5, previous_diff_value: 'fb2eeb524e6b5637ef7fa4bed48f1d67') #=> false (not updated)
25
- checker.updated?(target_page_md5, previous_diff_value: '12345678901234567890123456789012') #=> true (updated)
28
+ checker.current_comparison_value(target_page_md5) #=> fb2eeb524e6b5637ef7fa4bed48f1d67
29
+ checker.updated?(target_page_md5, previous_comparison_value: 'fb2eeb524e6b5637ef7fa4bed48f1d67') #=> false (not updated)
30
+ checker.updated?(target_page_md5, previous_comparison_value: '12345678901234567890123456789012') #=> true (updated)
31
+
32
+ target_page_last_modified = WebpageUpdateChecker::Methods::LastModified.new(uri: 'http://www.ne.jp/asahi/pursuits/ootsuki/pc/X68k/x680x0.xhtml')
33
+ checker.current_comparison_value(target_page_last_modified) #=> 2008-03-17 16:05:01 +0000
34
+
35
+ target_page_http_status_code = WebpageUpdateChecker::Methods::HttpStatusCode.new(uri: 'http://www.ne.jp/asahi/pursuits/ootsuki/pc/X68k/x680x0.xhtml')
36
+ checker.current_comparison_value(target_page_http_status_code) #=> 200
26
37
  ```
27
38
 
28
39
  # Methods
@@ -39,10 +50,15 @@ You can use these `Methods`.
39
50
  # methods
40
51
  You can use these methods in each `Methods`.
41
52
 
42
- - `#updated?(checked_object, previous_diff_value:)`
53
+ - `#updated?(checked_object, previous_comparison_value:)`
43
54
  - `#=> true or false`
44
- - `#current_diff_value(checked_object)`
45
- - `#=> object such as Time (LastModified) or String (MD5, SHA512...)`
55
+ - `#current_comparison_value(checked_object)`
56
+ - `#=> object such as Time (LastModified), String (MD5, SHA512...) or Integer (HTTP status code)`
57
+
58
+ # Note
59
+ On v1.3.0, the method name that `current_diff_value` was changed to `current_comparison_value` and the keyword argument name that `previous_diff_value` was changed to `previous_comparison_value`.
60
+
61
+ So please use `current_comparison_value` method and `previous_comparison_value` keyword argument becuase `current_diff_value` and `previous_diff_value` are deprecated now.
46
62
 
47
63
  # TODO
48
64
  - [Coveralls](https://coveralls.io/)
@@ -3,12 +3,22 @@ Dir[File.expand_path('methods', __dir__) << '/*.rb'].each { |file| require file
3
3
 
4
4
  module WebpageUpdateChecker
5
5
  class Client
6
- def updated?(checked_object, previous_diff_value:)
7
- current_diff_value(checked_object) != previous_diff_value
6
+ def updated?(checked_object, previous_comparison_value: nil, previous_diff_value: nil)
7
+ if previous_comparison_value.nil?
8
+ # Deprecated keyword argument
9
+ current_comparison_value(checked_object) != previous_diff_value
10
+ else
11
+ current_comparison_value(checked_object) != previous_comparison_value
12
+ end
8
13
  end
9
14
 
15
+ def current_comparison_value(checked_object)
16
+ checked_object.current_comparison_value
17
+ end
18
+
19
+ # Depricated method
10
20
  def current_diff_value(checked_object)
11
- checked_object.current_diff_value
21
+ current_comparison_value(checked_object)
12
22
  end
13
23
  end
14
24
  end
@@ -5,7 +5,7 @@ module WebpageUpdateChecker
5
5
  @uri = uri
6
6
  end
7
7
 
8
- def current_diff_value
8
+ def current_comparison_value
9
9
  page = Mechanize.new.get(@uri)
10
10
  page.code.to_i
11
11
  rescue Mechanize::ResponseCodeError => e
@@ -8,7 +8,7 @@ module WebpageUpdateChecker
8
8
  @uri = uri
9
9
  end
10
10
 
11
- def current_diff_value
11
+ def current_comparison_value
12
12
  page = Mechanize.new.get(@uri)
13
13
  page.header['last-modified'] ? Time.parse(page.header['last-modified']) : nil
14
14
  end
@@ -5,7 +5,7 @@ module WebpageUpdateChecker
5
5
  @uri = uri
6
6
  end
7
7
 
8
- def current_diff_value
8
+ def current_comparison_value
9
9
  require 'digest/md5'
10
10
 
11
11
  page = Mechanize.new.get(@uri)
@@ -5,7 +5,7 @@ module WebpageUpdateChecker
5
5
  @uri = uri
6
6
  end
7
7
 
8
- def current_diff_value
8
+ def current_comparison_value
9
9
  require 'digest/sha1'
10
10
 
11
11
  page = Mechanize.new.get(@uri)
@@ -5,7 +5,7 @@ module WebpageUpdateChecker
5
5
  @uri = uri
6
6
  end
7
7
 
8
- def current_diff_value
8
+ def current_comparison_value
9
9
  require 'digest/sha2'
10
10
 
11
11
  page = Mechanize.new.get(@uri)
@@ -5,7 +5,7 @@ module WebpageUpdateChecker
5
5
  @uri = uri
6
6
  end
7
7
 
8
- def current_diff_value
8
+ def current_comparison_value
9
9
  require 'digest/sha2'
10
10
 
11
11
  page = Mechanize.new.get(@uri)
@@ -5,7 +5,7 @@ module WebpageUpdateChecker
5
5
  @uri = uri
6
6
  end
7
7
 
8
- def current_diff_value
8
+ def current_comparison_value
9
9
  require 'digest/sha2'
10
10
 
11
11
  page = Mechanize.new.get(@uri)
@@ -1,3 +1,3 @@
1
1
  module WebpageUpdateChecker
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpage_update_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Osamu Takiya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-14 00:00:00.000000000 Z
11
+ date: 2018-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize