mitten 0.0.5 → 0.0.6

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.
Files changed (47) hide show
  1. data/.gitignore +5 -24
  2. data/Gemfile +4 -0
  3. data/LICENSE +5 -4
  4. data/README.markdown +53 -0
  5. data/Rakefile +19 -45
  6. data/VERSION +1 -1
  7. data/bin/mitten +7 -0
  8. data/configs/example_environment.yaml +6 -5
  9. data/example/{sample.rb → echo.rb} +8 -2
  10. data/lib/mitten.rb +7 -9
  11. data/lib/{plugin.rb → mitten/plugin.rb} +9 -4
  12. data/lib/{utils.rb → mitten/utils.rb} +3 -2
  13. data/lib/mitten/version.rb +3 -0
  14. data/mitten.gemspec +16 -92
  15. metadata +58 -151
  16. data/.document +0 -5
  17. data/README.rdoc +0 -81
  18. data/bin/client +0 -10
  19. data/bin/daemon +0 -8
  20. data/configs/time_call.yaml +0 -13
  21. data/configs/twitter_bot.yaml +0 -3
  22. data/plugins/amazon_search.rb +0 -62
  23. data/plugins/bmi.rb +0 -48
  24. data/plugins/codepad.rb +0 -63
  25. data/plugins/fortune.rb +0 -40
  26. data/plugins/gasoline.rb +0 -46
  27. data/plugins/gmail.rb +0 -64
  28. data/plugins/google_profile.rb +0 -37
  29. data/plugins/google_transit.rb +0 -56
  30. data/plugins/google_weather.rb +0 -34
  31. data/plugins/holoscope.rb +0 -63
  32. data/plugins/loo_holoscope.rb +0 -51
  33. data/plugins/mixi_voice.rb +0 -139
  34. data/plugins/nanapi.rb +0 -31
  35. data/plugins/newspaper_headlines.rb +0 -48
  36. data/plugins/openpne_new_diary_check.rb +0 -66
  37. data/plugins/ramen.rb +0 -33
  38. data/plugins/rate.rb +0 -31
  39. data/plugins/screen_time_search.rb +0 -96
  40. data/plugins/time_call.rb +0 -25
  41. data/plugins/tweet.rb +0 -32
  42. data/plugins/twitter_bot.rb +0 -32
  43. data/plugins/typhoon.rb +0 -37
  44. data/plugins/uri_shorten.rb +0 -23
  45. data/spec/mitten_spec.rb +0 -11
  46. data/spec/spec.opts +0 -1
  47. data/spec/spec_helper.rb +0 -9
data/plugins/time_call.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'ostruct'
2
- require 'yaml'
3
-
4
- class TimeCall < Mitten::Plugin
5
- def initialize(*args)
6
- super
7
-
8
- @config_file = @config['config']
9
- end
10
-
11
- def before_hook
12
- @call_list = load_config
13
- end
14
-
15
- def load_config
16
- OpenStruct.new(File.open(@config_file) { |f| YAML.load(f) }).time
17
- end
18
-
19
- def main
20
- now = Time.now.strftime('%H%M').to_i
21
- @channels.each do |channel|
22
- notice(channel, @call_list[now]) if @call_list[now]
23
- end
24
- end
25
- end
data/plugins/tweet.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'open-uri'
2
- require 'nokogiri'
3
-
4
- class Tweet < Mitten::Plugin
5
- def initialize(*args)
6
- super
7
-
8
- @prefix = @config['prefix']
9
- end
10
-
11
- def on_privmsg(prefix, channel, message)
12
- if /#{@config['prefix']}/ =~ message
13
- user = $1
14
- html = Nokogiri::HTML(open("http://twitter.com/#{user}").read)
15
-
16
- tweet = (html/'.entry-content').first
17
- if !tweet.nil?
18
- tweet = "@#{user}: #{tweet.text}"
19
- else
20
- tweet = (html/'h1.logged-out').first
21
- if tweet.nil?
22
- tweet = 'いにゃい/(^o^)\'
23
- else
24
- tweet = tweet.text
25
- end
26
- end
27
- notice(channel, tweet)
28
- end
29
- rescue
30
- notice(channel, 'こわれたっ/(^o^)\')
31
- end
32
- end
@@ -1,32 +0,0 @@
1
- require 'ostruct'
2
- require 'yaml'
3
- require 'open-uri'
4
- require 'nokogiri'
5
-
6
- class TwitterBot < Mitten::Plugin
7
- def initialize(*args)
8
- super
9
-
10
- @config_file = @config['config']
11
- @bot_list = load_config
12
- end
13
-
14
- def load_config
15
- OpenStruct.new(File.open(@config_file) { |f| YAML.load(f) }).bot_list
16
- end
17
-
18
- def on_privmsg(prefix, channel, message)
19
- @bot_list.each_key do |key|
20
- notice(channel, get_tweet(@bot_list[key])) if message =~ Regexp.new(/#{key}(|?|\?)/)
21
- end
22
- end
23
-
24
- def get_tweet(bot)
25
- html = Nokogiri::HTML(open("http://twitter.com/#{bot}").read)
26
-
27
- tweet = (html/'.entry-content').first
28
- if !tweet.nil?
29
- tweet = tweet.text
30
- end
31
- end
32
- end
data/plugins/typhoon.rb DELETED
@@ -1,37 +0,0 @@
1
- require "open-uri"
2
- require 'nokogiri'
3
-
4
- class Typhoon < Mitten::Plugin
5
- def initialize(*args)
6
- super
7
-
8
- @uri = 'http://typhoon.yahoo.co.jp/weather/jp/typhoon/typha.html'
9
- @prefix = @config['prefix'] || '台風どうなった'
10
- end
11
-
12
- def on_privmsg(prefix, channel, message)
13
- case message
14
- when /^#{@prefix}(.+|)/
15
- get_typhoon_info.each { |message| notice(channel, message) }
16
- end
17
- end
18
-
19
- private
20
-
21
- def get_typhoon_info
22
- begin
23
- typhoon_info = []
24
- doc = Nokogiri::HTML(open(@uri).read, nil, 'EUC-JP')/'tr[@valign="top"]'
25
-
26
- (doc/'td[@widh="60%"]').each do |typhoon|
27
- typhoon_name = typhoon.inner_html.scan(/<b>(.+)<\/b>/)
28
- description = typhoon.inner_text.scan(/ (.+?)。/)
29
-
30
- typhoon_info << "#{typhoon_name} #{description}".toutf8
31
- end
32
- typhoon_info << @uri
33
- rescue
34
- '/(^o^)\ こわれたっ'
35
- end
36
- end
37
- end
@@ -1,23 +0,0 @@
1
- require 'nokogiri'
2
-
3
- class URIShorten < Mitten::Plugin
4
- def initialize(*args)
5
- super
6
-
7
- @prefix = @config['prefix'] || 's'
8
- end
9
-
10
- def on_privmsg(prefix, channel, message)
11
- case message
12
- when /^#{@prefix} (http:\/\/.+?)$/
13
- notice(channel, shorten($1))
14
- end
15
- end
16
-
17
- private
18
-
19
- def shorten(target)
20
- uri = URI.escape("http://j.mp/?s=&keyword=&url=#{target}")
21
- Nokogiri::HTML(open(uri).read).at('#shortened-url')['value']
22
- end
23
- end
data/spec/mitten_spec.rb DELETED
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Mitten" do
4
- before(:all) do
5
- @mitten = Mitten::Bot.new
6
- end
7
-
8
- it 'Mitten::Bot Instantiation' do
9
- @mitten.class.should == Mitten::Bot
10
- end
11
- end
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color
data/spec/spec_helper.rb DELETED
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'mitten'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end