kcna 0.2.0 → 0.3.0
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 -1
- data/lib/kcna.rb +2 -2
- data/lib/kcna/article.rb +10 -1
- data/lib/kcna/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5327663d6ee91c7c5b64b5d828b58b749e3f06c3
|
4
|
+
data.tar.gz: ada8b6736dbd21ffdf50e5a4a8f24678537cc425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76b20d8f7cd99b658db891f2c3b5621da41174fe0fa9d1b36fad71cdcdd05d0f1be7200e62b358efae3194fa6d8391af6a36b65154ef42db3d2f2c8c52040b1
|
7
|
+
data.tar.gz: ec393882b3eb2a5d75c88de3f3312caea26dc1e23acb4176db681d322e5bd6fd3671cce18d91a0fd030712f097d8c253b91298bec8fbd157fda9452068d2a7cb
|
data/README.md
CHANGED
data/lib/kcna.rb
CHANGED
@@ -32,14 +32,14 @@ class KCNA
|
|
32
32
|
when "<br>"
|
33
33
|
"\n"
|
34
34
|
end
|
35
|
-
end.sub(
|
35
|
+
end.sub(/\s*(---|‐‐‐|―――)\s*\z/, "")
|
36
36
|
strip_html(replaced_content)
|
37
37
|
end
|
38
38
|
|
39
39
|
private def post(path, body, max_redirect = 3)
|
40
40
|
raise "Too many redirects" if max_redirect == 0
|
41
41
|
|
42
|
-
res = @client.post("http://kcna.kp#{path}", body: body)
|
42
|
+
res = @client.post("http://kcna.kp#{path}", body: body, header: { "Connection" => "Keep-Alive" })
|
43
43
|
if res.ok?
|
44
44
|
res
|
45
45
|
elsif res.redirect?
|
data/lib/kcna/article.rb
CHANGED
@@ -3,7 +3,10 @@ class KCNA::Article
|
|
3
3
|
# @return [String] ID of the article
|
4
4
|
attr_reader :id
|
5
5
|
|
6
|
+
@attribute_keys = [:id]
|
7
|
+
|
6
8
|
def self.attr_reader_hash(key, default = nil)
|
9
|
+
@attribute_keys.push(key)
|
7
10
|
define_method(key, -> { @attrs[key].nil? ? default : @attrs[key] })
|
8
11
|
end
|
9
12
|
private_class_method :attr_reader_hash
|
@@ -19,7 +22,7 @@ class KCNA::Article
|
|
19
22
|
attr_reader_hash :main_title
|
20
23
|
# @!attribute [r]
|
21
24
|
# @return [String] subtitle of the article
|
22
|
-
attr_reader_hash :sub_title
|
25
|
+
attr_reader_hash :sub_title
|
23
26
|
# @!attribute [r]
|
24
27
|
# @return [String]
|
25
28
|
attr_reader_hash :display_title
|
@@ -47,4 +50,10 @@ class KCNA::Article
|
|
47
50
|
@id = id
|
48
51
|
@attrs = attrs
|
49
52
|
end
|
53
|
+
|
54
|
+
# Convert the article to a hash table.
|
55
|
+
# @return [Hash]
|
56
|
+
def to_h
|
57
|
+
self.class.instance_variable_get(:@attribute_keys).map { |k| [k, self.send(k)] }.to_h
|
58
|
+
end
|
50
59
|
end
|
data/lib/kcna/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kcna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hinata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.6.
|
143
|
+
rubygems_version: 2.6.13
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: A Ruby gem for kcna.kp(KCNA, Korean Central News Agency)
|