nkrb 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 +4 -4
- data/README.md +8 -6
- data/lib/nkrb.rb +2 -3
- data/lib/nkrb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ac25c854562cb63ab1f3d896315870d89ca9ad0
|
|
4
|
+
data.tar.gz: 1caa154e3f029a7de6a5c8ad1bcde004b5cd1e44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 874e329878f845b3df793528ccaec527e7043c480d6a14fce3e84899cd616b7ebe7c30a995be0d13a716a6b7e9dab4cf56acf951323a2b639de90a48f3ea0852
|
|
7
|
+
data.tar.gz: f3c66c73042479cc66100be83deb560984ed5d842e344b27dcd39c832bf1b163914fa9b44e47c20fbfa0717d4224b90f35b22db44adf8ae14341ffa56d99b1ac
|
data/README.md
CHANGED
|
@@ -30,7 +30,7 @@ p texts
|
|
|
30
30
|
## "I'm your father."
|
|
31
31
|
## ]
|
|
32
32
|
```
|
|
33
|
-
|
|
33
|
+
text.txt
|
|
34
34
|
```
|
|
35
35
|
Hello world.
|
|
36
36
|
I'm your father.
|
|
@@ -62,11 +62,11 @@ id\tname
|
|
|
62
62
|
|
|
63
63
|
```
|
|
64
64
|
collection = [
|
|
65
|
-
{
|
|
66
|
-
{
|
|
67
|
-
{
|
|
65
|
+
{id: "1", name: "satoh"},
|
|
66
|
+
{id: "2", name: "suzuki"},
|
|
67
|
+
{id: "3", name: "takahashi"},
|
|
68
68
|
]
|
|
69
|
-
p Nkrb.pluck(collection, key:
|
|
69
|
+
p Nkrb.pluck(collection, key: :name)
|
|
70
70
|
## =>
|
|
71
71
|
## [
|
|
72
72
|
## "satoh", "suzuki", "takahashi"
|
|
@@ -95,13 +95,15 @@ res = connection.get do |req|
|
|
|
95
95
|
req.url '/search', :page => 2
|
|
96
96
|
req.params['limit'] = 100
|
|
97
97
|
end
|
|
98
|
+
p res.body
|
|
98
99
|
```
|
|
99
100
|
|
|
100
101
|
#### 6. nokogiri
|
|
101
102
|
|
|
102
103
|
```
|
|
103
104
|
url = "https://www.youtube.com/?hl=ja&gl=JP"
|
|
104
|
-
Nkrb.nokogiri(url)
|
|
105
|
+
doc = Nkrb.nokogiri(url)
|
|
106
|
+
p doc
|
|
105
107
|
```
|
|
106
108
|
|
|
107
109
|
|
data/lib/nkrb.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "nkrb/version"
|
|
2
2
|
require "open-uri"
|
|
3
|
-
require "FileUtils"
|
|
4
3
|
require 'faraday'
|
|
4
|
+
require 'nokogiri'
|
|
5
5
|
|
|
6
6
|
module Nkrb
|
|
7
7
|
module_function
|
|
@@ -52,7 +52,7 @@ module Nkrb
|
|
|
52
52
|
# 3. collection の key となるのは一行目の文字列を \t で split した文字列群である
|
|
53
53
|
# 4. 末尾にある改行コードは削除する
|
|
54
54
|
def read_tsv(filename, delimiter: "\t")
|
|
55
|
-
tsv_data =
|
|
55
|
+
tsv_data = read_file(filename, delimiter: delimiter)
|
|
56
56
|
return nil if tsv_data.nil?
|
|
57
57
|
|
|
58
58
|
begin
|
|
@@ -129,7 +129,6 @@ module Nkrb
|
|
|
129
129
|
Nokogiri::HTML.parse(open(url), nil, charset)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
|
|
133
132
|
def random_str(len=5)
|
|
134
133
|
o = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map { |i| i.to_a }.flatten
|
|
135
134
|
(0...len).map { o[rand(o.length)] }.join
|
data/lib/nkrb/version.rb
CHANGED