bbs_2ch_url_validator 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/bbs_2ch_url_validator.rb +40 -6
- data/lib/bbs_2ch_url_validator/version.rb +1 -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: 4715910d9dd5a43bc119afd5f11034ff4c38792e
|
4
|
+
data.tar.gz: 9d6f0ca4e3bbe5b8b6e4fa4211386586fd28b123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 840762e7d9ea40021c7dc6fdae61d73a5de830f8c063cf999e7aa5753dfe02fe205620f2415fe2a5162431e44fbc49d782ddf3b443a0431d63734d283b5ee15a
|
7
|
+
data.tar.gz: e5e9244fa79278c6cba707ae25154702b71027f3b7a448f2e48fa51311974c58eb3bdb0c180a03a214a77012b2d00fbcb9765e947ab025db3a225e353d3ea1ad
|
data/README.md
CHANGED
@@ -45,6 +45,7 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
45
45
|
|
46
46
|
## History
|
47
47
|
|
48
|
+
- v0.1.3 Add Bbs2chUrlValidator::URL#subject, #dat, #setting, #dat?, #subject?, #setting?, #open?
|
48
49
|
- v0.1.2 Put #build_url into instance variable 'built_url'
|
49
50
|
- v0.1.1 Add UrlInfo#build_url
|
50
51
|
- v0.1.0 first release
|
@@ -46,9 +46,10 @@ module Bbs2chUrlValidator
|
|
46
46
|
|
47
47
|
class UrlInfo
|
48
48
|
# @return [String]
|
49
|
-
attr_reader :server_name, :tld, :board_name, :thread_key, :
|
49
|
+
attr_reader :server_name, :tld, :board_name, :thread_key, :built_url
|
50
50
|
# @return [Boolean]
|
51
|
-
|
51
|
+
# @deprecated
|
52
|
+
attr_reader :is_dat, :is_subject, :is_setting, :is_open
|
52
53
|
|
53
54
|
# @param [Hash] hash
|
54
55
|
def initialize(hash)
|
@@ -57,13 +58,32 @@ module Bbs2chUrlValidator
|
|
57
58
|
instance_variable_set("@#{k}", value)
|
58
59
|
end
|
59
60
|
@built_url = build_url
|
61
|
+
define_methods
|
62
|
+
end
|
63
|
+
|
64
|
+
def dat
|
65
|
+
generate_special_url(:dat)
|
66
|
+
end
|
67
|
+
|
68
|
+
def subject
|
69
|
+
generate_special_url(:subject)
|
70
|
+
end
|
71
|
+
|
72
|
+
def setting
|
73
|
+
generate_special_url(:setting)
|
60
74
|
end
|
61
75
|
|
62
76
|
private
|
63
77
|
|
78
|
+
def define_methods
|
79
|
+
%w(is_open is_dat is_subject is_setting).each do |attr|
|
80
|
+
self.class.send(:define_method, attr.gsub(/is_(.+)/) { "#{$1}?" }) { attr }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
64
84
|
def build_url
|
65
85
|
if @is_dat || @is_subject || @is_setting
|
66
|
-
|
86
|
+
generate_special_url_by_flags
|
67
87
|
elsif @thread_key
|
68
88
|
# http://viper.2ch.sc/test/read.cgi/news4vip/9990000001/
|
69
89
|
combine_url("/test/read.cgi/#{@board_name}/#{@thread_key}/")
|
@@ -76,14 +96,28 @@ module Bbs2chUrlValidator
|
|
76
96
|
end
|
77
97
|
end
|
78
98
|
|
79
|
-
def
|
99
|
+
def generate_special_url_by_flags
|
80
100
|
if @is_dat
|
101
|
+
generate_special_url(:dat)
|
102
|
+
elsif @is_subject
|
103
|
+
generate_special_url(:subject)
|
104
|
+
elsif @is_setting
|
105
|
+
generate_special_url(:setting)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def generate_special_url(type)
|
110
|
+
case type
|
111
|
+
when :dat
|
112
|
+
return nil unless @board_name && @thread_key
|
81
113
|
# http://viper.2ch.sc/news4vip/dat/9990000001.dat
|
82
114
|
combine_url("/#{@board_name}/dat/#{@thread_key}.dat")
|
83
|
-
|
115
|
+
when :subject
|
116
|
+
return nil unless @board_name
|
84
117
|
# http://viper.2ch.sc/news4vip/subject.txt
|
85
118
|
combine_url("/#{@board_name}/subject.txt")
|
86
|
-
|
119
|
+
when :setting
|
120
|
+
return nil unless @board_name
|
87
121
|
# http://viper.2ch.sc/news4vip/SETTING.TXT
|
88
122
|
combine_url("/#{@board_name}/SETTING.TXT")
|
89
123
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbs_2ch_url_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dogwood008
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|