mixi-community 0.0.4 → 0.0.5

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzM1YzQ2OGQ3OTE1NDEyYTgxMGZmMzlhN2FjYzE0OTRkZjU4YzQwMA==
5
+ data.tar.gz: !binary |-
6
+ Mjc2Zjc3M2QzNmIyYTkyMTkyZDY2YWYwNjdlMTYyM2RmOGY3MDgwMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MTVlZWI0ODI2N2IyMzcxMGIxMzcyMWQ2YzkxNWIxNDU5ODM4NWRiYTcyNTc5
10
+ NTgwNjQ2NjdmZmU3NmQxODlmNjVjZjEzYTcyMWMxZTEyOTFiZWQ3MmE0YzE5
11
+ NWY1NzM3NGNiNzE2NmVkM2EzY2Q2M2M2YmM3YmRhOTRjMmFhMTA=
12
+ data.tar.gz: !binary |-
13
+ NTFiNzQyYTc0MGFiMTE2NDJhZTEwYTMxMWE3NzhiYWNjN2QxMDcyMmE3Nzkw
14
+ OWJhMmM4OGM4ZTE5ZTlkYjRjODg4MmMwMzMzODJkM2ExYTJkN2UzODdkNjFm
15
+ YjJiMGM0MWI0MTNmMzI5ZDY0ZjBiZTFjYzgwMjU4YjczYzkwYTc=
data/Gemfile CHANGED
@@ -1 +1,2 @@
1
+ source 'https://rubygems.org'
1
2
  gemspec
data/README.md CHANGED
@@ -46,6 +46,12 @@ See source for details.
46
46
 
47
47
  ## Changes
48
48
 
49
+ ### 0.0.5
50
+
51
+ * Support new version HTML('jp.mixi.community.widget.deferedlink').
52
+ * Remove trashes from BBS comment text.
53
+ * Remove forwarding/trailing white spaces from users name.
54
+
49
55
  ### 0.0.4
50
56
 
51
57
  * Support new date format(again!)
@@ -3,6 +3,12 @@ require 'mechanize'
3
3
 
4
4
  module Mixi
5
5
  class Community
6
+ def self.read_href(elm)
7
+ URI.parse(
8
+ elm.attr('data-url') || elm.attr(:href)
9
+ )
10
+ end
11
+
6
12
  def initialize(id)
7
13
  @id = id
8
14
  end
@@ -17,7 +23,7 @@ module Mixi
17
23
  def fetch(fetcher)
18
24
  page = fetcher.get(uri)
19
25
  @recent_bbses = page.search('#newCommunityTopic .contents dl dd a').map {|a|
20
- bbs_uri = URI.parse(a.attr(:href))
26
+ bbs_uri = Mixi::Community.read_href(a)
21
27
  bbs_title = a.text
22
28
  bbs_id = Hash[bbs_uri.query.split('&').map{|kv|kv.split('=')}]['id']
23
29
 
@@ -50,10 +56,10 @@ module Mixi
50
56
  page = fetcher.get(uri)
51
57
  @title = page.at('.bbsTitle .title').text
52
58
  @recent_comments = page.at('#bbsComment').at('dl.commentList01').children.select{|e|%w(dt dd).include? e.name}.each_slice(2).map {|dt,dd|
53
- user_uri = URI.parse(dd.at('dl.commentContent01 dt a').attr(:href))
59
+ user_uri = Mixi::Community.read_href(dd.at('dl.commentContent01 dt a'))
54
60
  user_id = Hash[user_uri.query.split('&').map{|kv|kv.split('=')}]['content_id']
55
- user_name = dd.at('dl.commentContent01 dt a').text
56
- body_text = resolve_encoding(dd.at('dl.commentContent01 dd').text){|t|t.strip.gsub(/\n\n返信$/, '').gsub(/\r/,"\n")}
61
+ user_name = dd.at('dl.commentContent01 dt a').text.strip
62
+ body_text = resolve_encoding(read_bbs_text(dd.at('dl.commentContent01 dd'))){|t|t}
57
63
  comment_id = dt.at('.senderId a').attr(:name).gsub(/^comment_id_(\d+)$/, '\1')
58
64
  comment_num = dt.at('.senderId a').text.gsub(/^\[(\d+)\]$/, '\1')
59
65
  time = resolve_encoding(dt.at('.date').text) {|t| parse_comment_time(t) }
@@ -105,6 +111,11 @@ module Mixi
105
111
  end
106
112
  end
107
113
 
114
+ def read_bbs_text(elm)
115
+ text = elm.children.reject {|c| c.name == 'ul' }.map(&:text).join
116
+ text.strip.gsub(/\r/,"\n")
117
+ end
118
+
108
119
  class Comment
109
120
  def initialize(id, params)
110
121
  @id = id
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "mixi-community"
3
- gem.version = "0.0.4"
3
+ gem.version = "0.0.5"
4
4
  gem.authors = ["todesking"]
5
5
  gem.email = ["discommunicative@gmail.com"]
6
6
  gem.summary = %q{Access to Mixi community.}
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixi-community
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - todesking
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-25 00:00:00.000000000 Z
11
+ date: 2013-11-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mechanize
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -42,27 +39,26 @@ files:
42
39
  - mixi-community.gemspec
43
40
  homepage: https://github.com/todesking/mixi-community
44
41
  licenses: []
42
+ metadata: {}
45
43
  post_install_message:
46
44
  rdoc_options: []
47
45
  require_paths:
48
46
  - lib
49
47
  required_ruby_version: !ruby/object:Gem::Requirement
50
- none: false
51
48
  requirements:
52
49
  - - ! '>='
53
50
  - !ruby/object:Gem::Version
54
51
  version: '0'
55
52
  required_rubygems_version: !ruby/object:Gem::Requirement
56
- none: false
57
53
  requirements:
58
54
  - - ! '>='
59
55
  - !ruby/object:Gem::Version
60
56
  version: '0'
61
57
  requirements: []
62
58
  rubyforge_project:
63
- rubygems_version: 1.8.19
59
+ rubygems_version: 2.1.10
64
60
  signing_key:
65
- specification_version: 3
61
+ specification_version: 4
66
62
  summary: Access to Mixi community.
67
63
  test_files: []
68
64
  has_rdoc: