ruremasearcher 0.0.3 → 0.0.4
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/Gemfile.lock +1 -1
- data/bin/ruremasearcher +4 -4
- data/lib/html_parser.rb +17 -0
- data/lib/ruremasearcher/version.rb +1 -1
- data/ruremasearcher.gemspec +1 -0
- data/spec/ruremasearcher/ruremasearcher_spec.rb +5 -5
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c34187a0841ceb70e647553dcf59f6fe7cbdc9ed
|
4
|
+
data.tar.gz: 9f3f9e40e3f082c69c044ca4f8c3feb57967233b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d7129f943b31574fa5afdbd0a890f0bd5344e69b552fbefcacad9f6cd21fef4728c8422cd6a675a3c0123886c1bf5a1b413172a559c442328c0a469e6011b5c
|
7
|
+
data.tar.gz: 09c9ce41462355c104ae6e5e0fc6addc99acfb8677e839345742134602efe990c3ce25d09affb40c0ad496ae1a764d0d77e9c7fe503c4d73628a5d4712f602b3
|
data/Gemfile.lock
CHANGED
data/bin/ruremasearcher
CHANGED
@@ -25,10 +25,10 @@ module RuremaSearcher
|
|
25
25
|
(top5).times do |i|
|
26
26
|
out = <<-EOS
|
27
27
|
---検索結果:#{ i+1 }件目------------------------------
|
28
|
-
タイトル: #{hp.titles[i]
|
29
|
-
分類:#{hp.metadata[i]
|
30
|
-
要約:#{hp.summaries[i]
|
31
|
-
説明:#{hp.descriptions[i]
|
28
|
+
タイトル: #{hp.titles[i] if hp.titles[i]}
|
29
|
+
分類:#{hp.metadata[i] if hp.metadata[i]}
|
30
|
+
要約:#{hp.summaries[i] if hp.summaries[i]}
|
31
|
+
説明:#{hp.descriptions[i] if hp.descriptions[i]}
|
32
32
|
EOS
|
33
33
|
print out
|
34
34
|
end
|
data/lib/html_parser.rb
CHANGED
@@ -14,6 +14,23 @@ class HtmlParser
|
|
14
14
|
@metadata = @doc.css('ul.entry-metadata > li.entry-type > span')
|
15
15
|
@summaries = @doc.css('div.entry-summary > p')
|
16
16
|
@descriptions = @doc.css('div.entry-document > div.entry-snippets > div.snippet')
|
17
|
+
clean_string
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def clean_string
|
22
|
+
@titles = @titles.map do |e|
|
23
|
+
e.text.gsub(/\n/, '').strip.gsub(/\(\d+\)\Z/, '').strip
|
24
|
+
end
|
25
|
+
@metadata = @metadata.map do |e|
|
26
|
+
e.text.gsub(/\n/, '').strip
|
27
|
+
end
|
28
|
+
@summaries = @summaries.map do |e|
|
29
|
+
e.text.gsub(/\n/, '').strip
|
30
|
+
end
|
31
|
+
@descriptions = @descriptions.map do |e|
|
32
|
+
e.text.gsub(/\n/, '').strip
|
33
|
+
end
|
17
34
|
end
|
18
35
|
|
19
36
|
end
|
data/ruremasearcher.gemspec
CHANGED
@@ -7,7 +7,7 @@ require 'spec_helper'
|
|
7
7
|
|
8
8
|
describe Ruremasearcher do
|
9
9
|
it 'should have a version number' do
|
10
|
-
expect(Ruremasearcher::VERSION).to eq('0.0.
|
10
|
+
expect(Ruremasearcher::VERSION).to eq('0.0.4')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -123,10 +123,10 @@ describe HtmlParser do
|
|
123
123
|
EOS
|
124
124
|
hp = HtmlParser.new(html)
|
125
125
|
hp.parse
|
126
|
-
expect(hp.titles[0]
|
127
|
-
expect(hp.metadata[0]
|
128
|
-
expect(hp.summaries[0]
|
129
|
-
expect(hp.descriptions[0]
|
126
|
+
expect(hp.titles[0]).to eq("String#split(sep = $;, limit = 0) -> [String] | [[String]]")
|
127
|
+
expect(hp.metadata[0]).to eq('インスタンスメソッド')
|
128
|
+
expect(hp.summaries[0]).to eq("第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、結果を文字列の配列で返します。")
|
129
|
+
expect(hp.descriptions[0]).to eq("...p \" a \t b c\".split(/ +/) # => [\"\", \"a\", \"b\", \"c\"] p \" a \t b c\".split(nil) # => [\"a\", \"b\", \"c\"] p \" a \t b c\".split(' ') # => [\"a\", \"b\", \"c\"] # split(nil) と同じ p \" a \t b c\".split # => [\"a\", \"b\", \"c\"] # split(nil) と同じ #...")
|
130
130
|
|
131
131
|
end
|
132
132
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruremasearcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryosy383
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Search in http://rurema.clear-code.com/
|
56
70
|
email:
|
57
71
|
- mosso.ryosy383@gmail.com
|