snaka-favoraretter 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.
- data/History.txt +6 -0
- data/Manifest.txt +7 -0
- data/README.txt +51 -0
- data/Rakefile +10 -0
- data/bin/favoraretter.rb +134 -0
- data/bin/register.bat +60 -0
- data/bin/start-watching.bat +30 -0
- data/bin/stop-watching.bat +30 -0
- data/bin/unregister.bat +34 -0
- metadata +93 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= favoraretter
|
2
|
+
|
3
|
+
* http://d.hatena.ne.jp/snaka72/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
指定されたユーザーのふぁぼられを監視して、誰かからふぁぼられたら
|
8
|
+
Growlでお知らせします。
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
下記機能をバッチファイルとして提供してます
|
13
|
+
* サービスへの登録
|
14
|
+
* サービスからの登録解除
|
15
|
+
* サービスの開始
|
16
|
+
* サービスの停止
|
17
|
+
|
18
|
+
== REQUIREMENTS:
|
19
|
+
|
20
|
+
* nokogiri (>= 1.3.2)
|
21
|
+
* ruby_gntp (>= 0.1.1)
|
22
|
+
* win32-service (>= 0.6.1)
|
23
|
+
|
24
|
+
== INSTALL:
|
25
|
+
|
26
|
+
* gem install snaka-favoraretter --source http://gems.github.com/
|
27
|
+
|
28
|
+
== LICENSE:
|
29
|
+
|
30
|
+
(The MIT License)
|
31
|
+
|
32
|
+
Copyright (c) 2009 snaka <snaka.gml@gmail.com>
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
35
|
+
a copy of this software and associated documentation files (the
|
36
|
+
'Software'), to deal in the Software without restriction, including
|
37
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
38
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
39
|
+
permit persons to whom the Software is furnished to do so, subject to
|
40
|
+
the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be
|
43
|
+
included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
48
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
49
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
50
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
51
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/favoraretter.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
#
|
2
|
+
# favoraretter.rb for Windows
|
3
|
+
#
|
4
|
+
|
5
|
+
# This software distributable under the terms of an MIT-style license.
|
6
|
+
# Copyright (c) 2009 snaka<snaka.gml@gmail.com>
|
7
|
+
# http://d.hatena.ne.jp/snaka72/
|
8
|
+
|
9
|
+
require 'pstore'
|
10
|
+
require 'open-uri'
|
11
|
+
|
12
|
+
LOG = 'fav.log'
|
13
|
+
def log(msg) File.open(LOG, "a") {|f| f.puts "#{Time.now} #{msg}"} end
|
14
|
+
def debug(msg)
|
15
|
+
return unless $DEBUG
|
16
|
+
File.open(LOG, "a") {|f| f.puts "#{Time.now} #{msg}"}
|
17
|
+
end
|
18
|
+
|
19
|
+
log "started."
|
20
|
+
|
21
|
+
FAVOTTER_BASE_URI = 'http://favotter.matope.com'
|
22
|
+
ICON_DIR = "icons/"
|
23
|
+
|
24
|
+
USER = ARGV[0] || ""
|
25
|
+
|
26
|
+
|
27
|
+
def watch
|
28
|
+
|
29
|
+
count = 0
|
30
|
+
doc = Nokogiri::HTML(open(FAVOTTER_BASE_URI + "/user.php?user=#{USER}"))
|
31
|
+
|
32
|
+
$store.transaction do
|
33
|
+
doc.css("div.entry").each do |entry|
|
34
|
+
entry_id = entry.attribute("id").to_s.match(/status_([0-9]+)/)[1]
|
35
|
+
user = entry.css("img.user_icon")[0].attribute("alt").to_s
|
36
|
+
status = entry.css("span.status_text")[0].inner_text
|
37
|
+
fav_count = (favs = entry.css("span.favotters")).inner_text
|
38
|
+
|
39
|
+
favs.css("img.fav_icon").each do |favotter|
|
40
|
+
favotter_name = favotter.attribute("title").to_s
|
41
|
+
favotter_icon = favotter.attribute("src")
|
42
|
+
|
43
|
+
if($store[entry_id])
|
44
|
+
debug "@#{entry_id} exists"
|
45
|
+
if($store[entry_id][favotter_name])
|
46
|
+
debug "@#{favotter_name} exists"
|
47
|
+
next
|
48
|
+
end
|
49
|
+
else
|
50
|
+
$store[entry_id] = {}
|
51
|
+
end
|
52
|
+
|
53
|
+
log "#{favotter_name} #{favotter_icon} fav #{user}'s tweet #{status}"
|
54
|
+
$growl.notify({
|
55
|
+
:name => "Favorare",
|
56
|
+
:title => "#{favotter_name} favs..",
|
57
|
+
:text => %Q(#{user}:"#{status}"),
|
58
|
+
:icon => favotter_icon
|
59
|
+
})
|
60
|
+
|
61
|
+
count += 1
|
62
|
+
$store[entry_id][favotter_name] = true
|
63
|
+
sleep(1)
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return count
|
70
|
+
end
|
71
|
+
|
72
|
+
begin
|
73
|
+
require 'rubygems'
|
74
|
+
require "win32/daemon"
|
75
|
+
include Win32
|
76
|
+
|
77
|
+
$store = PStore.new("./store")
|
78
|
+
|
79
|
+
class FavoraretterDaemon < Daemon
|
80
|
+
|
81
|
+
VERSION = "0.0.1"
|
82
|
+
|
83
|
+
def service_main
|
84
|
+
log "require gems..."
|
85
|
+
require 'nokogiri'
|
86
|
+
require 'ruby_gntp'
|
87
|
+
|
88
|
+
log "register GNTP server..."
|
89
|
+
$growl = GNTP.new("Favoraretter")
|
90
|
+
$growl.register({
|
91
|
+
:app_icon => "http://favotter.matope.com/favicon.ico",
|
92
|
+
:notifications => [{
|
93
|
+
:name => "Favorare",
|
94
|
+
:disp_name => "You've got fav!",
|
95
|
+
:enabled => true
|
96
|
+
}]
|
97
|
+
})
|
98
|
+
|
99
|
+
log "notify stating..."
|
100
|
+
$growl.notify({
|
101
|
+
:name => "Favorare",
|
102
|
+
:title => "Now stating favoraretter..",
|
103
|
+
:text => "Please wait a moment."
|
104
|
+
})
|
105
|
+
|
106
|
+
log "enter main loop..."
|
107
|
+
while running?
|
108
|
+
|
109
|
+
sleep 600
|
110
|
+
log "fetch fav. for #{USER}"
|
111
|
+
watch
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def service_stop
|
116
|
+
log "finish."
|
117
|
+
$growl.notify({
|
118
|
+
:name => "Favorare",
|
119
|
+
:title => "Now stopping the service.",
|
120
|
+
:text => "Please wait a moment."
|
121
|
+
})
|
122
|
+
exit!
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
FavoraretterDaemon.mainloop
|
127
|
+
|
128
|
+
rescue Exception => err
|
129
|
+
log "error=#{err}"
|
130
|
+
# err.backtrace
|
131
|
+
raise
|
132
|
+
end
|
133
|
+
|
134
|
+
# vim: ts=2 sw=2 et
|
data/bin/register.bat
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
@echo off
|
2
|
+
rem
|
3
|
+
rem register.bat
|
4
|
+
rem
|
5
|
+
rem Copyright (c) 2009 snaka <snaka.gml@gmail.com>
|
6
|
+
rem
|
7
|
+
|
8
|
+
ruby -x -Ks "%~f0"
|
9
|
+
pause
|
10
|
+
exit
|
11
|
+
|
12
|
+
#! ruby
|
13
|
+
require "readline"
|
14
|
+
|
15
|
+
require "rubygems"
|
16
|
+
require "win32/service"
|
17
|
+
include Win32
|
18
|
+
|
19
|
+
require "constant"
|
20
|
+
|
21
|
+
def register(user)
|
22
|
+
user = user || ''
|
23
|
+
puts "#{user_display_name(user)}�̂ӂ��ڂ��Ď��T�[�r�X��o�^���܂��B"
|
24
|
+
|
25
|
+
if Service.exists?(SERVICE)
|
26
|
+
puts "ERR: �T�[�r�X�͊��ɓo�^����Ă��܂��B"
|
27
|
+
else
|
28
|
+
Service.create(SERVICE, nil,
|
29
|
+
:service_type => Service::WIN32_OWN_PROCESS,
|
30
|
+
:description => "Favoraretter daemon",
|
31
|
+
:start_type => Service::AUTO_START,
|
32
|
+
:error_control => Service::ERROR_NORMAL,
|
33
|
+
:binary_path_name => %("c:\\Program Files\\ruby-1.8\\bin\\rubyw.exe" -C"#{current_path}" favoraretter.rb #{user}),
|
34
|
+
:display_name => "Favoraetter daemon!"
|
35
|
+
)
|
36
|
+
puts "�ӂ��ڂ��Ď��T�[�r�X��o�^���܂����B"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def user_display_name(user)
|
41
|
+
if user == ''
|
42
|
+
return '�݂��'
|
43
|
+
end
|
44
|
+
return user
|
45
|
+
end
|
46
|
+
|
47
|
+
def current_path
|
48
|
+
Dir.pwd.gsub(File::Separator, File::ALT_SEPARATOR)
|
49
|
+
end
|
50
|
+
|
51
|
+
puts <<EOS
|
52
|
+
�ӂ��ڂ����Ď����������[�U�[��id����͂��Ă��������B
|
53
|
+
���͂��ȗ������ꍇ�́u�ӂ��ڂ����[�v�̃y�[�W�ɕ\�������S�Ẵ��[�U�[��
|
54
|
+
�ӂ��ڂ����Ď����܂��B
|
55
|
+
EOS
|
56
|
+
user = Readline.readline('userid?> ', true)
|
57
|
+
|
58
|
+
register user
|
59
|
+
|
60
|
+
# vim: ts=2 sw=2 et ft=ruby
|
@@ -0,0 +1,30 @@
|
|
1
|
+
@echo off
|
2
|
+
rem
|
3
|
+
rem start-watching.bat
|
4
|
+
rem
|
5
|
+
rem Copyright (c) 2009 snaka <snaka.gml@gmail.com>
|
6
|
+
rem
|
7
|
+
|
8
|
+
ruby -x -Ks "%~f0"
|
9
|
+
pause
|
10
|
+
exit
|
11
|
+
|
12
|
+
#! ruby
|
13
|
+
require "readline"
|
14
|
+
|
15
|
+
require "rubygems"
|
16
|
+
require "win32/service"
|
17
|
+
include Win32
|
18
|
+
|
19
|
+
require "constant"
|
20
|
+
|
21
|
+
begin
|
22
|
+
puts "�T�[�r�X���J�n���܂��B"
|
23
|
+
Service.start(SERVICE)
|
24
|
+
puts "�T�[�r�X���J�n���܂����B"
|
25
|
+
rescue Exception => ex
|
26
|
+
puts "ERR:�T�[�r�X�̊J�n�Ŗ�肪�������܂���"
|
27
|
+
puts ex
|
28
|
+
end
|
29
|
+
|
30
|
+
# vim: ts=2 sw=2 et
|
@@ -0,0 +1,30 @@
|
|
1
|
+
@echo off
|
2
|
+
rem
|
3
|
+
rem stop-watching.bat
|
4
|
+
rem
|
5
|
+
rem Copyright (c) 2009 snaka <snaka.gml@gmail.com>
|
6
|
+
rem
|
7
|
+
|
8
|
+
ruby -x -Ks "%~f0"
|
9
|
+
pause
|
10
|
+
exit
|
11
|
+
|
12
|
+
#! ruby
|
13
|
+
require "readline"
|
14
|
+
|
15
|
+
require "rubygems"
|
16
|
+
require "win32/service"
|
17
|
+
include Win32
|
18
|
+
|
19
|
+
require "constant"
|
20
|
+
|
21
|
+
begin
|
22
|
+
puts "�T�[�r�X���~���܂��B"
|
23
|
+
Service.stop(SERVICE)
|
24
|
+
puts "�T�[�r�X���~���܂����B"
|
25
|
+
rescue Exception => ex
|
26
|
+
puts "ERR:�T�[�r�X�̒�~�Ŗ�肪�������܂���"
|
27
|
+
puts ex
|
28
|
+
end
|
29
|
+
|
30
|
+
# vim: ts=2 sw=2 et
|
data/bin/unregister.bat
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
@echo off
|
2
|
+
rem
|
3
|
+
rem unregister.bat
|
4
|
+
rem
|
5
|
+
rem Copyright (c) 2009 snaka <snaka.gml@gmail.com>
|
6
|
+
rem
|
7
|
+
|
8
|
+
ruby -x -Ks "%~f0"
|
9
|
+
pause
|
10
|
+
exit
|
11
|
+
|
12
|
+
#! ruby
|
13
|
+
require "readline"
|
14
|
+
|
15
|
+
require "rubygems"
|
16
|
+
require "win32/service"
|
17
|
+
include Win32
|
18
|
+
|
19
|
+
require "constant"
|
20
|
+
|
21
|
+
begin
|
22
|
+
Service.stop(SERVICE)
|
23
|
+
rescue Exception => ex
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
Service.delete(SERVICE)
|
28
|
+
puts "�T�[�r�X�̓o�^���������܂����B"
|
29
|
+
rescue Exception => ex
|
30
|
+
puts "ERR:�T�[�r�X�̓o�^�����Ŗ�肪�������܂���"
|
31
|
+
puts ex
|
32
|
+
end
|
33
|
+
|
34
|
+
# vim: ts=2 sw=2 et
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snaka-favoraretter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- snaka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.3.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ruby_gntp
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.1
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: win32-service
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.6.1
|
44
|
+
version:
|
45
|
+
description: Watch "favorare" status and notify if "favorare" added.
|
46
|
+
email: snaka.gml@gmail.com
|
47
|
+
executables:
|
48
|
+
- start-watching.bat
|
49
|
+
- stop-watching.bat
|
50
|
+
- register.bat
|
51
|
+
- unregister.bat
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files: []
|
55
|
+
|
56
|
+
files:
|
57
|
+
- History.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- README.txt
|
60
|
+
- Rakefile
|
61
|
+
- bin/start-watching.bat
|
62
|
+
- bin/stop-watching.bat
|
63
|
+
- bin/register.bat
|
64
|
+
- bin/unregister.bat
|
65
|
+
- bin/favoraretter.rb
|
66
|
+
has_rdoc: false
|
67
|
+
homepage: http://d.hatena.ne.jp/snaka72/
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
|
71
|
+
require_paths:
|
72
|
+
- bin
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.2.0
|
89
|
+
signing_key:
|
90
|
+
specification_version: 2
|
91
|
+
summary: Watch "favorare" status and notify if "favorare" added.
|
92
|
+
test_files: []
|
93
|
+
|