atok-twitter 0.1.0-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ *.log
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 MIKAMI Yoshiyuki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ = atok-twitter
2
+
3
+ Twitter client on ATOK.
4
+
5
+ == How to use
6
+
7
+ [つぶやく]
8
+ tw: または tw: に続けてつぶやき
9
+ 例)tw:ハラヘッタ
10
+ [タイムラインを見る]
11
+ twtl または twtl
12
+
13
+ == Note on Patches/Pull Requests
14
+
15
+ * Fork the project.
16
+ * Make your feature addition or bug fix.
17
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
18
+ * Commit, do not mess with rakefile, version, or history.
19
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
20
+ * Send me a pull request. Bonus points for topic branches.
21
+
22
+ == Copyright
23
+
24
+ Copyright (c) 2009 MIKAMI Yoshiyuki. See LICENSE for details.
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "atok-twitter"
8
+ gem.summary = %Q{Twitter client on ATOK.}
9
+ gem.description = %Q{Twitter client on ATOK.}
10
+ gem.email = "yoshuki@saikyoline.jp"
11
+ gem.homepage = "http://github.com/yoshuki/atok-twitter"
12
+ gem.authors = ["MIKAMI Yoshiyuki"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ gem.platform = 'x86-mswin32'
16
+ gem.add_dependency 'nokogiri', '>= 1.4.0'
17
+ gem.executables = ['atok-twitter-install']
18
+ gem.default_executable = 'atok-twitter-install'
19
+ gem.files.exclude '**/*.log'
20
+ gem.files.include 'lib/**/*.rb', 'plugin/**/*', 'extra/**/*'
21
+ gem.post_install_message = "\n\n������ atok-twitter-install �����s���ăv���O�C�����C���X�g�[�����Ă��������B ������\n\n\n"
22
+ end
23
+ Jeweler::GemcutterTasks.new
24
+ rescue LoadError
25
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
26
+ end
27
+
28
+ require 'spec/rake/spectask'
29
+ Spec::Rake::SpecTask.new(:spec) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.spec_files = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
35
+ spec.libs << 'lib' << 'spec'
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :spec => :check_dependencies
41
+
42
+ task :default => :spec
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "atok-twitter #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,77 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{atok-twitter}
8
+ s.version = "0.1.0"
9
+ s.platform = %q{x86-mswin32}
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["MIKAMI Yoshiyuki"]
13
+ s.date = %q{2009-11-26}
14
+ s.default_executable = %q{atok-twitter-install}
15
+ s.description = %q{Twitter client on ATOK.}
16
+ s.email = %q{yoshuki@saikyoline.jp}
17
+ s.executables = ["atok-twitter-install"]
18
+ s.extra_rdoc_files = [
19
+ "LICENSE",
20
+ "README.rdoc"
21
+ ]
22
+ s.files = [
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "atok-twitter.gemspec",
29
+ "bin/atok-twitter-install",
30
+ "extra/README",
31
+ "extra/log/README",
32
+ "extra/speak_server.rb",
33
+ "extra/start_servers.bat",
34
+ "extra/tuple_server.rb",
35
+ "lib/atok/twitter/installer.rb",
36
+ "plugin/ATOK_PLUGIN_MESSAGE.DLL",
37
+ "plugin/DATA/twitter.xml",
38
+ "plugin/DATA/twitter_wo_login_info.rb",
39
+ "plugin/SETUP.EXE",
40
+ "plugin/SETUPINFO.XML",
41
+ "spec/atok-twitter_spec.rb",
42
+ "spec/spec.opts",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+ s.homepage = %q{http://github.com/yoshuki/atok-twitter}
46
+ s.post_install_message = %q{
47
+
48
+ ������ atok-twitter-install �����s���ăv���O�C�����C���X�g�[�����Ă��������B ������
49
+
50
+
51
+ }
52
+ s.rdoc_options = ["--charset=UTF-8"]
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = %q{1.3.5}
55
+ s.summary = %q{Twitter client on ATOK.}
56
+ s.test_files = [
57
+ "spec/spec_helper.rb",
58
+ "spec/atok-twitter_spec.rb"
59
+ ]
60
+
61
+ if s.respond_to? :specification_version then
62
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
66
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
67
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.0"])
68
+ else
69
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
70
+ s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
71
+ end
72
+ else
73
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
74
+ s.add_dependency(%q<nokogiri>, [">= 1.4.0"])
75
+ end
76
+ end
77
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'atok/twitter/installer'
4
+
5
+ plugin_root = File.join(File.dirname(__FILE__), '..', 'plugin')
6
+ ATOK::Twitter::Installer.new(plugin_root).install
@@ -0,0 +1 @@
1
+ gem install aqtk �����s���ĕK�v��gem���C���X�g�[�����Ă��������B
@@ -0,0 +1 @@
1
+ �����Ƀ��O������܂��B
@@ -0,0 +1,48 @@
1
+ require 'logger'
2
+ require 'rinda/ring'
3
+ require 'rubygems'
4
+ require 'aqtk'
5
+
6
+ RETRY_TIMES = 5
7
+ RETRY_INTERVAL = 3
8
+
9
+ logger = Logger.new(File.join(File.dirname(File.expand_path(__FILE__)), 'log', "#{File.basename(__FILE__, '.*')}.log").tr('/', '\\'), 'daily')
10
+ logger.datetime_format = '%Y-%m-%d %H:%M '
11
+ logger.progname = File.basename(__FILE__, '.*')
12
+ logger.level = Logger::INFO
13
+
14
+ case ARGV[0]
15
+ when 'start', 'startlocal'
16
+ retries = []
17
+ loop do
18
+ begin
19
+ ts = nil
20
+ if ARGV[0] == 'startlocal'
21
+ ts = DRbObject.new_with_uri('druby://localhost:12345')
22
+ else
23
+ DRb.start_service
24
+ puts DRb.uri
25
+ ts = Rinda::RingFinger.primary
26
+ end
27
+ puts ts.inspect
28
+
29
+ while message = ts.take([:message, String], false)
30
+ puts message[1].tosjis
31
+ logger.debug(message[1].tosjis)
32
+ AquesTalk::Da.play_sync(message[1].tosjis, 100)
33
+ retries.clear
34
+ end
35
+ rescue => evar
36
+ logger.error(evar.inspect)
37
+ if retries.size < RETRY_TIMES
38
+ retries << Time.now
39
+ sleep RETRY_INTERVAL
40
+ else
41
+ logger.error(retries.inspect)
42
+ break
43
+ end
44
+ end
45
+ end
46
+ else
47
+ puts "Usage: ruby #{File.basename(__FILE__)} [start]"
48
+ end
@@ -0,0 +1,10 @@
1
+ @ECHO OFF
2
+
3
+ IF "%1" == "" (
4
+ SET TIMES=1
5
+ ) ELSE (
6
+ SET TIMES=%1
7
+ )
8
+
9
+ start ruby tuple_server.rb startlocal && sleep 2
10
+ FOR /L %%i IN (1, 1, %TIMES%) DO sleep 1 && start ruby speak_server.rb startlocal
@@ -0,0 +1,84 @@
1
+ require 'logger'
2
+ require 'rinda/ring'
3
+ require 'rinda/tuplespace'
4
+
5
+ class TupleServer
6
+ TIME_OUT = 180
7
+
8
+ def initialize
9
+ @logger = Logger.new(File.join(File.dirname(File.expand_path(__FILE__)), 'log', "#{File.basename(__FILE__, '.*')}.log").tr('/', '\\'), 'daily')
10
+ @logger.datetime_format = '%Y-%m-%d %H:%M '
11
+ @logger.progname = self.class.name
12
+ @logger.level = Logger::INFO
13
+
14
+ @ts = Rinda::TupleSpaceProxy.new(Rinda::TupleSpace.new)
15
+ @ts.write([:started_at, Time.now])
16
+ end
17
+
18
+ def write(tuple, time_out=true)
19
+ @logger.debug("WRITE: #{tuple.inspect}")
20
+ if time_out
21
+ @ts.write(tuple, TIME_OUT)
22
+ else
23
+ @ts.write(tuple)
24
+ end
25
+ end
26
+
27
+ def take(pattern, time_out=true, &block)
28
+ @logger.debug("TAKE: #{pattern.inspect}")
29
+ if time_out
30
+ @ts.take(pattern, TIME_OUT, &block)
31
+ else
32
+ @ts.take(pattern, nil, &block)
33
+ end
34
+ end
35
+
36
+ def read(pattern, time_out=true)
37
+ @logger.debug("READ: #{pattern.inspect}")
38
+ if time_out
39
+ @ts.read(pattern, TIME_OUT)
40
+ else
41
+ @ts.read(pattern)
42
+ end
43
+ end
44
+
45
+ def read_all(pattern)
46
+ @logger.debug("READ_ALL: #{pattern.inspect}")
47
+ @ts.read_all(pattern)
48
+ end
49
+
50
+ def notify(event, pattern, time_out=true)
51
+ @logger.debug("NOTIFY: #{pattern.inspect}")
52
+ if time_out
53
+ @ts.notify(event, pattern, TIME_OUT)
54
+ else
55
+ @ts.notify(event, pattern)
56
+ end
57
+ end
58
+ end
59
+
60
+ if $0 == __FILE__
61
+ case ARGV[0]
62
+ when 'start', 'startlocal'
63
+ if ARGV[0] == 'startlocal'
64
+ DRb.start_service('druby://localhost:12345', TupleServer.new)
65
+ else
66
+ DRb.start_service
67
+ ring_server = Rinda::RingServer.new(TupleServer.new)
68
+ end
69
+ puts DRb.uri
70
+ DRb.thread.join
71
+ when 'show', 'showlocal'
72
+ ts = nil
73
+ if ARGV[0] == 'showlocal'
74
+ ts = DRbObject.new_with_uri('druby://localhost:12345')
75
+ else
76
+ DRb.start_service
77
+ ts = Rinda::RingFinger.primary
78
+ end
79
+ tuples = ts.read_all([nil, nil])
80
+ tuples.each{|t| puts t.inspect unless t.empty?}
81
+ else
82
+ puts "Usage: ruby #{File.basename(__FILE__)} [start|show]"
83
+ end
84
+ end
@@ -0,0 +1,74 @@
1
+ require 'win32ole'
2
+
3
+ class ATOK
4
+ class Twitter
5
+ class Installer
6
+ def initialize(plugin_root)
7
+ @plugin_root = plugin_root
8
+ @sc = WIN32OLE.new("ScriptControl")
9
+ @sc.language = 'VBScript'
10
+ end
11
+
12
+ def install
13
+ login_info = get_login_info
14
+ if login_info[:user] && login_info[:pass]
15
+ if login_info[:user].index("}") || login_info[:pass].index("}") # �V���^�b�N�X�G���[�̉”\��
16
+ @sc.eval('MsgBox("���[�U�[���܂��̓p�X���[�h�Ɂu}�v���܂߂邱�Ƃ͂ł��܂���B", vbOKOnly Or vbCritical, "Twitter")')
17
+ else
18
+ set_login_info(login_info)
19
+ system(File.join(@plugin_root, 'SETUP.EXE'))
20
+ end
21
+ else
22
+ @sc.eval('MsgBox("�C���X�g�[���O�Ƀ��O�C�����̐ݒ肪�K�v�ł��B", vbOKOnly Or vbCritical, "Twitter")')
23
+ end
24
+ end
25
+
26
+ private
27
+ def get_login_info
28
+ while true
29
+ user = @sc.eval('InputBox("���[�U�[��", "Twitter")')
30
+ if user.nil?
31
+ break
32
+ elsif !(user =~ /^[0-9A-Z_]+$/i)
33
+ @sc.eval('MsgBox("���[�U�[��������������܂���B", vbOKOnly Or vbExclamation, "Twitter")')
34
+ redo
35
+ end
36
+
37
+ raise '���[�U�[����������' unless user
38
+ while true
39
+ pass = @sc.eval('InputBox("�p�X���[�h", "Twitter")')
40
+ break if pass.nil?
41
+
42
+ raise '�p�X���[�h��������' unless pass
43
+ pass_confirm = @sc.eval('InputBox("�p�X���[�h�m�F", "Twitter")')
44
+ redo if pass_confirm.nil?
45
+
46
+ raise '�p�X���[�h�m�F��������' unless pass_confirm
47
+ break if pass == pass_confirm
48
+
49
+ @sc.eval('MsgBox("�p�X���[�h����v���܂���B", vbOKOnly Or vbExclamation, "Twitter")')
50
+ end
51
+
52
+ if user && pass
53
+ answer = @sc.eval('MsgBox("���[�U���F'+user+'"&vbCrLf&"�p�X���[�h�F*****"&vbCrLf&vbCrLf&"��낵���ł����H", vbYesNoCancel Or vbQuestion, "Twitter")')
54
+ case answer
55
+ when @sc.eval('vbYes'); break
56
+ when @sc.eval('vbNo'); redo
57
+ else
58
+ user = pass = nil
59
+ break
60
+ end
61
+ end
62
+ end
63
+
64
+ {:user => user, :pass => pass}
65
+ end
66
+
67
+ def set_login_info(login_info)
68
+ twitter_rb = File.read(File.join(@plugin_root, 'DATA', 'twitter_wo_login_info.rb'))
69
+ twitter_rb.sub!(/TW_SCREEN_NAME *= *'.*?'/, "TW_SCREEN_NAME = %q{#{login_info[:user]}}").sub!(/TW_PASSWORD *= *'.*?'/, "TW_PASSWORD = %q{#{login_info[:pass]}}")
70
+ File.open(File.join(@plugin_root, 'DATA', 'twitter.rb'), 'w') {|f| f.write(twitter_rb)}
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <plugin_info>
3
+ <name>Twitter</name>
4
+ <name_short>Twitter</name_short>
5
+ <description>Twitterクライアントです。</description>
6
+ <copyright>Copyright (C) 2009 yoshuki</copyright>
7
+ <major_version>0</major_version>
8
+ <minor_version>5</minor_version>
9
+ <callback>true</callback>
10
+ </plugin_info>
@@ -0,0 +1,151 @@
1
+ require 'drb'
2
+ require 'net/http'; Net::HTTP.version_1_2
3
+ require 'time'
4
+ require 'rubygems'
5
+ require 'nokogiri'
6
+
7
+ module Atok_plugin
8
+ TW_SCREEN_NAME = 'xxxxxxxxxx' # あなたの「ユーザ名」に置き換えてください。
9
+ TW_PASSWORD = 'xxxxxxxxxx' # あなたの「パスワード」に置き換えてください。
10
+
11
+ def run_process(request)
12
+ candidates = []
13
+
14
+ begin
15
+ ts = DRbObject.new_with_uri('druby://localhost:12345')
16
+ ts = nil unless ts.respond_to?(:write)
17
+ rescue DRb::DRbConnError => evar
18
+ ts = nil
19
+ end
20
+
21
+ case request['composition_string']
22
+ when /^(tw:|tw:)(.+)$/
23
+ new_status = /^(tw:|tw:)(.+)$/.match(request['composition_string'])[2]
24
+ return nil unless doc = post_request('http://twitter.com/statuses/update.xml', {:status => new_status})
25
+
26
+ status = doc.xpath('/status')
27
+ now = Time.now
28
+ created_at = Time.parse(status.xpath('created_at').text)
29
+ date_or_time = (now.month == created_at.month && now.day == created_at.day) ? created_at.strftime('%H:%M') : created_at.strftime('%m-%d')
30
+
31
+ ts && ts.write([:message, status.xpath('text').text + '。'])
32
+
33
+ candidates = [
34
+ {'hyoki' => "[#{date_or_time}] " + status.xpath('user/screen_name').text,
35
+ 'comment_xhtml' => <<-EOT
36
+ <?xml version="1.0" encoding="UTF-8" ?>
37
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
38
+ <head><title>AtokDirect</title></head>
39
+ <body>
40
+ <table>
41
+ <tr>
42
+ <td rowspan="2"><img src="#{status.xpath('user/profile_image_url').text}" /></td>
43
+ <td>#{status.xpath('user/name').text}</td>
44
+ </tr>
45
+ <tr>
46
+ <td>#{status.xpath('user/screen_name').text}</td>
47
+ </tr>
48
+ </table>
49
+ <hr />
50
+ <p>#{status.xpath('text').text}</p>
51
+ </body>
52
+ </html>
53
+ EOT
54
+ }
55
+ ]
56
+ when 'twtl', 'twtl'
57
+ return nil unless doc = get_response('http://twitter.com/statuses/friends_timeline.xml')
58
+
59
+ doc.xpath('/statuses/status').each do |status|
60
+ now = Time.now
61
+ created_at = Time.parse(status.xpath('created_at').text)
62
+ date_or_time = (now.month == created_at.month && now.day == created_at.day) ? created_at.strftime('%H:%M') : created_at.strftime('%m-%d')
63
+
64
+ from_now = (now - created_at).to_i
65
+ if from_now < 60
66
+ from_now_text = from_now.to_s + '秒前'
67
+ elsif from_now < 3600
68
+ from_now_text = (from_now / 60).to_s + '分前'
69
+ else
70
+ from_now_m = (from_now % 3600) / 60
71
+ from_now_h = (from_now - from_now_m) / 3600
72
+ from_now_text = "#{from_now_h}時間#{from_now_m}分前"
73
+ end
74
+
75
+ ts && ts.write([:message, status.xpath('text').text + '。'])
76
+
77
+ candidates <<
78
+ {'hyoki' => "[#{date_or_time}] " + status.xpath('user/screen_name').text,
79
+ 'comment_xhtml' => <<-EOT
80
+ <?xml version="1.0" encoding="UTF-8" ?>
81
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
82
+ <head><title>AtokDirect</title></head>
83
+ <body>
84
+ <table>
85
+ <tr>
86
+ <td rowspan="2" style="padding-right: 1em;"><img src="#{status.xpath('user/profile_image_url').text}" /></td>
87
+ <td>#{status.xpath('user/name').text}</td>
88
+ </tr>
89
+ <tr>
90
+ <td>#{status.xpath('user/screen_name').text}</td>
91
+ </tr>
92
+ </table>
93
+ <hr />
94
+ <p>#{status.xpath('text').text}</p>
95
+ <div style="text-align: right;">---- #{from_now_text}</div>
96
+ </body>
97
+ </html>
98
+ EOT
99
+ }
100
+ end
101
+ else
102
+ return nil
103
+ end
104
+
105
+ {'candidate' => candidates}
106
+ end
107
+
108
+ def run_callback(selected)
109
+ selected['composition_string']
110
+ selected['candidate_string']
111
+ end
112
+
113
+ private
114
+ def post_request(url, params)
115
+ return nil unless params.is_a?(Hash)
116
+ res = nil
117
+ uri = URI.parse(url)
118
+ Net::HTTP.start(uri.host) do |http|
119
+ req = Net::HTTP::Post.new(uri.path)
120
+ req.basic_auth(TW_SCREEN_NAME, TW_PASSWORD)
121
+ req.set_form_data(params)
122
+ res = http.request(req)
123
+ end
124
+ return nil unless res.is_a?(Net::HTTPOK)
125
+ # File.open(File.join(File.dirname(File.expand_path(__FILE__)), 'response.xml'), 'w') {|f| f.write(res.body)}
126
+ # Nokogiri::XML.parse(File.read(File.join(File.dirname(File.expand_path(__FILE__)), 'response.xml')))
127
+ Nokogiri::XML.parse(res.body)
128
+ rescue TimeoutError => evar
129
+ nil
130
+ rescue => evar
131
+ nil
132
+ end
133
+
134
+ def get_response(url)
135
+ res = nil
136
+ uri = URI.parse(url)
137
+ Net::HTTP.start(uri.host) do |http|
138
+ req = Net::HTTP::Get.new(uri.path)
139
+ req.basic_auth TW_SCREEN_NAME, TW_PASSWORD
140
+ res = http.request(req)
141
+ end
142
+ return nil unless res.is_a?(Net::HTTPOK)
143
+ # File.open(File.join(File.dirname(File.expand_path(__FILE__)), 'response.xml'), 'w') {|f| f.write(res.body)}
144
+ # Nokogiri::XML.parse(File.read(File.join(File.dirname(File.expand_path(__FILE__)), 'response.xml')))
145
+ Nokogiri::XML.parse(res.body)
146
+ rescue TimeoutError => evar
147
+ nil
148
+ rescue => evar
149
+ nil
150
+ end
151
+ end
Binary file
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <setup_info_list>
3
+ <setup_info>
4
+ <data_folder_name>DATA</data_folder_name>
5
+ <plugin_file_name>twitter.rb</plugin_file_name>
6
+ <plugin_enable>true</plugin_enable>
7
+ <only_individual_run>true</only_individual_run>
8
+ <add_position>1</add_position>
9
+ </setup_info>
10
+ </setup_info_list>
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe 'AtokTwitter' do
4
+ describe 'extra' do
5
+ it 'has all required files' do
6
+ @extra_files.each do |file|
7
+ File.file?(File.join(@extra_root, file)).should be_true
8
+ end
9
+ end
10
+ end
11
+
12
+ describe 'plugin' do
13
+ it 'has all required files' do
14
+ @plugin_files.each do |file|
15
+ File.file?(File.join(@plugin_root, file)).should be_true
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'spec'
4
+ require 'spec/autorun'
5
+
6
+ Spec::Runner.configure do |config|
7
+ config.before(:all) do
8
+ @extra_root = File.join(File.dirname(__FILE__), '..', 'extra')
9
+ @extra_files = [
10
+ File.join('log', 'README'),
11
+ 'README',
12
+ 'speak_server.rb',
13
+ 'start_servers.bat',
14
+ 'tuple_server.rb',
15
+ ]
16
+ @plugin_root = File.join(File.dirname(__FILE__), '..', 'plugin')
17
+ @plugin_files = [
18
+ File.join('DATA', 'twitter.xml'),
19
+ File.join('DATA', 'twitter_wo_login_info.rb'),
20
+ 'ATOK_PLUGIN_MESSAGE.DLL',
21
+ 'SETUP.EXE',
22
+ 'SETUPINFO.XML'
23
+ ]
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atok-twitter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: x86-mswin32
6
+ authors:
7
+ - MIKAMI Yoshiyuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-26 00:00:00 +09:00
13
+ default_executable: atok-twitter-install
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.4.0
34
+ version:
35
+ description: Twitter client on ATOK.
36
+ email: yoshuki@saikyoline.jp
37
+ executables:
38
+ - atok-twitter-install
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .gitignore
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - VERSION
50
+ - atok-twitter.gemspec
51
+ - bin/atok-twitter-install
52
+ - extra/README
53
+ - extra/log/README
54
+ - extra/speak_server.rb
55
+ - extra/start_servers.bat
56
+ - extra/tuple_server.rb
57
+ - lib/atok/twitter/installer.rb
58
+ - plugin/ATOK_PLUGIN_MESSAGE.DLL
59
+ - plugin/DATA/twitter.xml
60
+ - plugin/DATA/twitter_wo_login_info.rb
61
+ - plugin/SETUP.EXE
62
+ - plugin/SETUPINFO.XML
63
+ - spec/atok-twitter_spec.rb
64
+ - spec/spec.opts
65
+ - spec/spec_helper.rb
66
+ has_rdoc: true
67
+ homepage: http://github.com/yoshuki/atok-twitter
68
+ licenses: []
69
+
70
+ post_install_message: !binary |
71
+ CgqBpoGmgaYgYXRvay10d2l0dGVyLWluc3RhbGwggvCOwI1zgrWCxIN2g4mD
72
+ T4NDg5OC8INDg5ODWINngVuDi4K1gsSCrYK+grOCooFCIIGmgaaBpgoKCg==
73
+
74
+ rdoc_options:
75
+ - --charset=UTF-8
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.3.5
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Twitter client on ATOK.
97
+ test_files:
98
+ - spec/spec_helper.rb
99
+ - spec/atok-twitter_spec.rb