sosowa 0.6 → 0.7

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.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7
2
+
3
+ * 新板創想話レイアウトに対応
4
+
1
5
  ## 0.6
2
6
  * tagsにゴミが混ざっている不具合を修正
3
7
 
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in sosowa.gemspec
4
4
  gemspec
5
+ gem "rake"
6
+ gem "rspec"
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Sosowa
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/oame/sosowa-ruby.png)](http://travis-ci.org/oame/sosowa-ruby)
4
+
3
5
  創想話パーサー for Ruby 1.9.x<br>
4
6
  samples/に各種サンプルが入っています。
5
7
 
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task :default => :spec
data/lib/sosowa/scheme.rb CHANGED
@@ -34,7 +34,11 @@ module Sosowa
34
34
  @page = @agent.get(URI.join(Sosowa::BASE_URL, params))
35
35
  title = (@page/%{div[@class="header"] > h1})[0].inner_html.to_s.toutf8.strip
36
36
  tags = (@page/%{dl[@class="info"][1] > dd > a}).map{|t| t.inner_html.to_s.toutf8 }
37
- text = (@page/%{div[@class="contents ss"]})[0].inner_html.to_s.toutf8
37
+ text = ""
38
+ text_node = @page/%{div[@class="contents ss"]}
39
+ text_node.children.each do |node|
40
+ text += node.inner_html.to_s.toutf8.strip
41
+ end
38
42
  aft = @page/%{div[@class="aft"]}
39
43
  ps = (aft.size > 0) ? aft[0].inner_html.to_s.toutf8 : ""
40
44
  author_name = (@page/%{div[@class="author"] b})[0].inner_html.to_s.toutf8
@@ -1,3 +1,3 @@
1
1
  module Sosowa
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
@@ -10,9 +10,9 @@ puts "Fetching thdic-mecab..."
10
10
  system("curl -L https://github.com/oame/thdic-mecab/raw/master/pkg/thdic-mecab.dic > thdic-mecab.dic") unless FileTest.exists? "thdic-mecab.dic"
11
11
 
12
12
  puts "Done. Initialize MeCab::Tagger"
13
- mecab = MeCab::Tagger.new("-u thdic-mecab.dic")
13
+ mecab = MeCab::Tagger.new#("-u thdic-mecab.dic")
14
14
 
15
- text = Sosowa.get.sample.fetch.text.plain
15
+ text = Sosowa.get.sample.fetch.plain
16
16
  tokens = mecab.parseToNode(text)
17
17
  tokens.each do |token|
18
18
  puts token.feature
@@ -0,0 +1,42 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require "pp"
4
+ require "spec_helper"
5
+
6
+ describe Sosowa, "が #get, :log => 0 を呼ぶ時は" do
7
+ before do
8
+ @log = Sosowa.get :log => 0
9
+ end
10
+
11
+ it "Sosowa::Logを返すこと" do
12
+ @log.class.should == Sosowa::Log
13
+ end
14
+
15
+ it "最初がSosowa::Indexであること" do
16
+ @log.first.class.should == Sosowa::Index
17
+ end
18
+
19
+ it "最初のタイトルがStringであること" do
20
+ @log.first.title.class.should == String
21
+ end
22
+
23
+ it "#next_pageがSosowa::Logを返すこと" do
24
+ @log.next_page.class.should == Sosowa::Log
25
+ end
26
+
27
+ it "#prev_pageがSosowa::Logを返すこと" do
28
+ @log.prev_page.class.should == Sosowa::Log
29
+ end
30
+
31
+ it "#latest_logがFixnumを返すこと" do
32
+ @log.latest_log.class.should == Fixnum
33
+ end
34
+
35
+ it "最初を#fetchしたらSosowa::Novelを返すこと" do
36
+ @log.first.fetch.class.should == Sosowa::Novel
37
+ end
38
+
39
+ it "最初を#fetchしたSosowa::Novel#titleがStringなこと" do
40
+ @log.first.fetch.title.class.should == String
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require "rspec"
4
+ require "sosowa"
5
+
6
+ RSpec.configure do |config|
7
+ config.color_enabled = true
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sosowa
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-25 00:00:00.000000000Z
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
16
- requirement: &70198979423520 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70198979423520
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Sosowa Parser for Ruby
26
31
  email:
27
32
  - oame@oameya.com
@@ -30,6 +35,8 @@ extensions: []
30
35
  extra_rdoc_files: []
31
36
  files:
32
37
  - .gitignore
38
+ - .rspec
39
+ - .travis.yml
33
40
  - CHANGELOG.md
34
41
  - Gemfile
35
42
  - LICENSE
@@ -45,6 +52,8 @@ files:
45
52
  - samples/tf-idf.rb
46
53
  - samples/token_segment.rb
47
54
  - sosowa.gemspec
55
+ - spec/sosowa_spec.rb
56
+ - spec/spec_helper.rb
48
57
  homepage: ''
49
58
  licenses: []
50
59
  post_install_message:
@@ -57,17 +66,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
66
  - - ! '>='
58
67
  - !ruby/object:Gem::Version
59
68
  version: '0'
69
+ segments:
70
+ - 0
71
+ hash: -181387724163016397
60
72
  required_rubygems_version: !ruby/object:Gem::Requirement
61
73
  none: false
62
74
  requirements:
63
75
  - - ! '>='
64
76
  - !ruby/object:Gem::Version
65
77
  version: '0'
78
+ segments:
79
+ - 0
80
+ hash: -181387724163016397
66
81
  requirements: []
67
82
  rubyforge_project:
68
- rubygems_version: 1.8.10
83
+ rubygems_version: 1.8.24
69
84
  signing_key:
70
85
  specification_version: 3
71
86
  summary: Sosowa Parser for Ruby 1.9.x.
72
- test_files: []
73
- has_rdoc:
87
+ test_files:
88
+ - spec/sosowa_spec.rb
89
+ - spec/spec_helper.rb