inko 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.
- data/bin/inko +11 -11
- data/lib/inko.rb +40 -33
- data/lib/inko/config.rb +34 -32
- data/lib/inko/version.rb +1 -1
- metadata +2 -2
data/bin/inko
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
4
|
def show_usage_and_exit
|
5
|
-
|
5
|
+
puts <<-EOS
|
6
6
|
USAGE:
|
7
7
|
inko [-d | --daemon | -h | --help]
|
8
8
|
|
@@ -12,29 +12,29 @@ DESCRIPTION:
|
|
12
12
|
-d,--daemon Run in deamon-mode. If you want to quit this app, simply kill this app's process.
|
13
13
|
|
14
14
|
--help show this usage.
|
15
|
-
|
16
|
-
|
15
|
+
EOS
|
16
|
+
exit
|
17
17
|
end
|
18
18
|
|
19
19
|
case ARGV.first
|
20
20
|
when '-h', '--help'
|
21
|
-
|
22
|
-
|
21
|
+
ARGV.shift
|
22
|
+
show_usage_and_exit
|
23
23
|
when '-d', '--daemon'
|
24
|
-
|
25
|
-
|
24
|
+
ARGV.shift
|
25
|
+
puts <<-EOS.gsub /^\s+/,''
|
26
26
|
`inko` runs in background.
|
27
27
|
If you want to quit this app, kill process simply.
|
28
|
-
|
29
|
-
|
28
|
+
EOS
|
29
|
+
Process.daemon true,true
|
30
30
|
end
|
31
31
|
|
32
32
|
show_usage_and_exit unless ARGV.empty?
|
33
33
|
|
34
34
|
require 'inko'
|
35
35
|
begin
|
36
|
-
|
36
|
+
Inko::run
|
37
37
|
rescue Interrupt
|
38
|
-
|
38
|
+
puts "Inko is interrupted."
|
39
39
|
end
|
40
40
|
|
data/lib/inko.rb
CHANGED
@@ -8,41 +8,48 @@ require 'shellwords'
|
|
8
8
|
|
9
9
|
module Inko extend self
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
def filter? status
|
12
|
+
!status.user || !status.text
|
13
|
+
end
|
14
|
+
|
15
|
+
# modify screen_name and text to make them easy to pronounce
|
16
|
+
# _,!
|
17
|
+
# cf http://d.hatena.ne.jp/nacookan/20081220/1229745342
|
18
|
+
def pronunciationize status
|
19
|
+
status.user.screen_name = status.user.screen_name.gsub(/_/, ' ')
|
20
|
+
.gsub(/([a-zA-Z]+|[0-9]+)/){$1 + ' '}
|
21
|
+
.gsub(/@/,'@. ')
|
22
|
+
|
23
|
+
status.text = Shellwords::escape( status.text.split(/\n/).join(" ")
|
24
|
+
.gsub(/!/,'!')
|
25
|
+
.gsub(/w+/, ' 笑い ')
|
26
|
+
.gsub(/http:\/\/[^\s]+/, ' URL 略 ')
|
27
|
+
)
|
28
|
+
status
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
begin
|
33
|
+
UserStream.configure do |config|
|
34
|
+
config.consumer_key = Config::ConsumerKey
|
35
|
+
config.consumer_secret = Config::ConsumerSecret
|
36
|
+
config.oauth_token = Config::OAuthToken
|
37
|
+
config.oauth_token_secret = Config::OAuthSecret
|
38
|
+
end
|
39
|
+
rescue UserStream::Unauthorized => e
|
40
|
+
STDERR.puts "contents of #{Config::ConfigFileName} is invalid!"
|
41
|
+
raise e
|
13
42
|
end
|
14
43
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
status
|
22
|
-
|
23
|
-
|
24
|
-
def run
|
25
|
-
begin
|
26
|
-
UserStream.configure do |config|
|
27
|
-
config.consumer_key = Config::ConsumerKey
|
28
|
-
config.consumer_secret = Config::ConsumerSecret
|
29
|
-
config.oauth_token = Config::OAuthToken
|
30
|
-
config.oauth_token_secret = Config::OAuthSecret
|
31
|
-
end
|
32
|
-
rescue UserStream::Unauthorized => e
|
33
|
-
STDERR.puts "contents of #{Config::ConfigFileName} is invalid!"
|
34
|
-
raise e
|
35
|
-
end
|
36
|
-
|
37
|
-
UserStream::client.user do |status|
|
38
|
-
unless filter? status
|
39
|
-
status = pronunciationize status
|
40
|
-
# puts "#{status.user.screen_name}: "
|
41
|
-
# puts status.text
|
42
|
-
`say -v #{Config::VoiceActor} #{status.user.screen_name} さんのツイート}`
|
43
|
-
`say -v #{Config::VoiceActor} #{status.text}`
|
44
|
-
end
|
45
|
-
end
|
44
|
+
UserStream::client.user do |status|
|
45
|
+
unless filter? status
|
46
|
+
status = pronunciationize status
|
47
|
+
# puts "#{status.user.screen_name}: "
|
48
|
+
# puts status.text
|
49
|
+
`say -v #{Config::VoiceActor} #{status.user.screen_name} さんのツイート}`
|
50
|
+
`say -v #{Config::VoiceActor} #{status.text}`
|
51
|
+
end
|
46
52
|
end
|
53
|
+
end
|
47
54
|
|
48
55
|
end
|
data/lib/inko/config.rb
CHANGED
@@ -3,37 +3,39 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
module Inko
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# load configuration from file
|
32
|
-
yaml = YAML.load(File.open(Config::ConfigFileName).read)
|
33
|
-
VoiceActor = yaml['voice_actor']
|
34
|
-
ConsumerKey = yaml['consumer_key']
|
35
|
-
ConsumerSecret = yaml['consumer_secret']
|
36
|
-
OAuthToken = yaml['oauth_token']
|
37
|
-
OAuthSecret = yaml['oauth_token_secret']
|
6
|
+
module Config
|
7
|
+
# file name for credential information
|
8
|
+
ConfigFileName = File.expand_path('~') + '/.inkorc.yml'
|
9
|
+
|
10
|
+
# if file is not found
|
11
|
+
unless File.exist? ConfigFileName
|
12
|
+
File.open ConfigFileName,"w" do |file|
|
13
|
+
file.print <<-EOS.gsub(/^\s+/, '')
|
14
|
+
# Choose voice actor from System Setting.
|
15
|
+
# To call off in Japanese, download voice data (Kyoko).
|
16
|
+
voice_actor: Alex
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
# Get app keys at https://dev.twitter.com/ and write them.
|
21
|
+
consumer_key: YourConsumerKey
|
22
|
+
consumer_secret: YourConsumerSecretKey
|
23
|
+
oauth_token: YourOAuthToken
|
24
|
+
oauth_token_secret: YourOAuthSecretToken
|
25
|
+
EOS
|
26
|
+
|
27
|
+
STDERR.puts "Configuration-keys are not found."
|
28
|
+
STDERR.puts "Write your consumer keys and OAuth keys to #{ConfigFileName}"
|
29
|
+
end
|
30
|
+
system 'bash', '-c', (ENV['EDITOR'] || 'vi')+' "$@"', '--', ConfigFileName
|
38
31
|
end
|
32
|
+
|
33
|
+
# load configuration from file
|
34
|
+
yaml = YAML.load(File.open(Config::ConfigFileName).read)
|
35
|
+
VoiceActor = yaml['voice_actor']
|
36
|
+
ConsumerKey = yaml['consumer_key']
|
37
|
+
ConsumerSecret = yaml['consumer_secret']
|
38
|
+
OAuthToken = yaml['oauth_token']
|
39
|
+
OAuthSecret = yaml['oauth_token_secret']
|
40
|
+
end
|
39
41
|
end
|
data/lib/inko/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Inko(インコ) is Twitter-call-off client for MacOS X.
|
15
15
|
email:
|