twpipe 0.0.2 → 0.0.3
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/twpipe +5 -1
- data/lib/twpipe.rb +6 -0
- data/lib/twpipe/version.rb +1 -1
- data/spec/lib/twpipe_spec.rb +3 -2
- data/twpipe.gemspec +1 -1
- metadata +3 -3
data/bin/twpipe
CHANGED
@@ -29,6 +29,7 @@ Options:
|
|
29
29
|
EOF
|
30
30
|
|
31
31
|
opt.on('-c CONFIG_FILE', '--config CONFIG_FILE', 'path to configuration file') {|v| options['config_path'] = File.expand_path(v) }
|
32
|
+
opt.on('-e [PREFIX]', '--echo-back [PREFIX]', 'echo back your tweet with prefix.') {|v| options['echo_back_with_prefix'] = v }
|
32
33
|
|
33
34
|
opt.permute!
|
34
35
|
end
|
@@ -45,7 +46,10 @@ end
|
|
45
46
|
begin
|
46
47
|
Twpipe.config_path = options['config_path'] if options['config_path']
|
47
48
|
pipe = Twpipe.new
|
48
|
-
pipe.tweet(message)
|
49
|
+
tweet = pipe.tweet(message)
|
50
|
+
if options['echo_back_with_prefix']
|
51
|
+
puts "%s%s" % [options['echo_back_with_prefix'], tweet]
|
52
|
+
end
|
49
53
|
rescue Twpipe::ConfigError => e
|
50
54
|
puts e.message
|
51
55
|
end
|
data/lib/twpipe.rb
CHANGED
@@ -5,6 +5,8 @@ require 'twpipe/version'
|
|
5
5
|
# == Twpipe
|
6
6
|
#
|
7
7
|
class Twpipe
|
8
|
+
MAX_TWEET_LENGTH = 140
|
9
|
+
|
8
10
|
class ConfigError < Exception; end
|
9
11
|
|
10
12
|
class << self
|
@@ -28,8 +30,12 @@ class Twpipe
|
|
28
30
|
#
|
29
31
|
# message: string variable that you would tweet
|
30
32
|
#
|
33
|
+
# return:
|
34
|
+
# * message that truncated first MAX_TWEET_LENGTH characters
|
35
|
+
#
|
31
36
|
def tweet(message)
|
32
37
|
@client.update(message)
|
38
|
+
message.split(//).first(MAX_TWEET_LENGTH).join
|
33
39
|
end
|
34
40
|
|
35
41
|
private
|
data/lib/twpipe/version.rb
CHANGED
data/spec/lib/twpipe_spec.rb
CHANGED
@@ -67,10 +67,11 @@ EOF
|
|
67
67
|
let(:twitter) { mock('Twitter:Base') }
|
68
68
|
|
69
69
|
it 'should receive Twitter::Base#update' do
|
70
|
+
message = 'a' * 141
|
70
71
|
Twpipe.config_path = File.join(File.dirname(__FILE__), '../data/config/valid.yml')
|
71
72
|
twpipe = Twpipe.new
|
72
|
-
twpipe.instance_variable_get(:@client).should_receive(:update).with(
|
73
|
-
twpipe.tweet(
|
73
|
+
twpipe.instance_variable_get(:@client).should_receive(:update).with(message)
|
74
|
+
twpipe.tweet(message).should == 'a' * 140
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
data/twpipe.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twpipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- koshigoe
|