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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0639f1c287f8e8df080c7038fdcf1a430cd64124
4
- data.tar.gz: bea01dc1367d5955f3c55aad9d978b545d0397b2
3
+ metadata.gz: c34187a0841ceb70e647553dcf59f6fe7cbdc9ed
4
+ data.tar.gz: 9f3f9e40e3f082c69c044ca4f8c3feb57967233b
5
5
  SHA512:
6
- metadata.gz: 95baaf146d64c51500576c8afb0d02a2b9185cc4de3ef680dcb24563459c739a64fa4f119c405bd07ab8f84c000fbad13ba9998e688b61fe8a8afa180f2ad8c3
7
- data.tar.gz: e664704510c7b5f0cdb72f0fdcf1501860b68a17ab15f3dc013f5f3f45ed766cd81bc3553c489de458c51d79c931181cd304b695adf7269f1939c079fe2d9fe0
6
+ metadata.gz: 5d7129f943b31574fa5afdbd0a890f0bd5344e69b552fbefcacad9f6cd21fef4728c8422cd6a675a3c0123886c1bf5a1b413172a559c442328c0a469e6011b5c
7
+ data.tar.gz: 09c9ce41462355c104ae6e5e0fc6addc99acfb8677e839345742134602efe990c3ce25d09affb40c0ad496ae1a764d0d77e9c7fe503c4d73628a5d4712f602b3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruremasearcher (0.0.2)
4
+ ruremasearcher (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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].text.strip if hp.titles[i]}
29
- 分類:#{hp.metadata[i].text.strip if hp.metadata[i]}
30
- 要約:#{hp.summaries[i].text.strip if hp.summaries[i]}
31
- 説明:#{hp.descriptions[i].text.strip if 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
@@ -1,3 +1,3 @@
1
1
  module Ruremasearcher
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
24
25
  end
@@ -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.3')
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].text.strip).to eq("String#split(sep = $;, limit = 0) -> [String] | [[String]]\n \n (18222)")
127
- expect(hp.metadata[0].text.strip).to eq('インスタンスメソッド')
128
- expect(hp.summaries[0].text.strip).to eq("第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、\n結果を文字列の配列で返します。")
129
- expect(hp.descriptions[0].text.strip).to eq("...p \" a \t b \n c\".split(/ +/) # => [\"\", \"a\", \"b\", \"c\"] p \" a \t b \n c\".split(nil) # => [\"a\", \"b\", \"c\"] p \" a \t b \n c\".split(' ') # => [\"a\", \"b\", \"c\"] # split(nil) と同じ p \" a \t b \n c\".split # => [\"a\", \"b\", \"c\"] # split(nil) と同じ #...")
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.3
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