tw 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe3b077a86536aa8cd1cd6d7dfe5ab864d1ab2f0
4
- data.tar.gz: 82693deb9ca828ca9e15748f6361a8967fb68b0b
3
+ metadata.gz: 0cf35055e90ba261fb927c4c51c084d367507ee1
4
+ data.tar.gz: 85edfd86d3c033f7c5611fe75e8738ccb6720811
5
5
  SHA512:
6
- metadata.gz: b273663d301b5465093abdced9b9b30c867b2d384170f720af2d53d7889d523302e04dcc0d8181439cf74fea27d1999031855c4b2f8d81f330114e7c35d21942
7
- data.tar.gz: 8c18f674051f9fd38f03196d76de9aec089d342091e9065d249f2038a67481c401c4da7982f6beff05e17acd8e12bd02e39988e8a5a6a8f7a2ba90a69547d4f9
6
+ metadata.gz: f61c945f1a8c90d77f7376be33cbf4e0c6f89e8a7c4603eb239bb7965f49a090ec7ca1e2fad920fb76280df5bae11af9d9c61942bf611d97c60e210d622bea24
7
+ data.tar.gz: ec55e554f853e275c642293fe06daf90766fc64d4f67794a635acc9b991ebc73efd8fcf8034523b08ea356515fbd920912dfda90417d3541136f40ccad0881bc
@@ -1,3 +1,7 @@
1
+ === 0.5.1 2013-09-18
2
+
3
+ * tweet with file % tw 'yummy!!' --file=food.jpg
4
+
1
5
  === 0.5.0 2013-08-26
2
6
 
3
7
  * show RT/Fav count on % tw --id=1234552234
data/README.md CHANGED
@@ -23,6 +23,7 @@ Tweet
23
23
 
24
24
  % tw hello hello
25
25
  % echo "hello" | tw --pipe
26
+ % tw 'yummy!!' --file=food.jpg
26
27
 
27
28
  read Timeline
28
29
 
@@ -54,6 +54,7 @@ module Tw::App
54
54
  arg :search, 'search public timeline', :alias => :s
55
55
  arg :stream, 'show user stream', :alias => :st
56
56
  arg :status_id, 'show status_id', :alias => :id
57
+ arg :file, 'upload file'
57
58
  arg :pipe, 'pipe tweet'
58
59
  arg :format, 'output format', :default => 'text'
59
60
  arg :silent, 'silent mode'
@@ -72,6 +73,10 @@ module Tw::App
72
73
  validate 'dm:to', 'invalid user name' do |v|
73
74
  v =~ /^[a-zA-Z0-9_]+$/
74
75
  end
76
+
77
+ validate :file, "file does not exists" do |v|
78
+ File.exists? v
79
+ end
75
80
  end
76
81
 
77
82
  if @parser.has_option? :help
@@ -83,6 +88,7 @@ module Tw::App
83
88
  STDERR.puts "e.g."
84
89
  STDERR.puts "tweet tw hello world"
85
90
  STDERR.puts " echo 'hello' | tw --pipe"
91
+ STDERR.puts " tw 'yummy!!' --file=food.jpg"
86
92
  STDERR.puts "read tw @username"
87
93
  STDERR.puts " tw @username @user2 @user2/listname"
88
94
  STDERR.puts " tw --search=ruby"
@@ -140,12 +146,19 @@ module Tw::App
140
146
  tweet_opts[:in_reply_to_status_id] = @parser[:status_id]
141
147
  else
142
148
  puts "tweet \"#{message}\"? (#{len} chars)"
149
+ if @parser.has_param? :file
150
+ puts "upload \"#{@parser[:file]}\"? (#{File.size @parser[:file]} bytes)"
151
+ end
143
152
  end
144
153
  puts '[Y/n]'
145
154
  on_exit if STDIN.gets.strip =~ /^n/i
146
155
  end
147
156
  begin
148
- client.tweet message, tweet_opts
157
+ if @parser.has_param? :file
158
+ client.tweet_with_file message, File.open(@parser[:file]), tweet_opts
159
+ else
160
+ client.tweet message, tweet_opts
161
+ end
149
162
  rescue => e
150
163
  STDERR.puts e.message
151
164
  end
@@ -80,6 +80,13 @@ module Tw
80
80
  puts res.created_at
81
81
  end
82
82
 
83
+ def tweet_with_file(message, file, opts={})
84
+ res = Twitter.update_with_media message, file, opts
85
+ puts res.text
86
+ puts "http://twitter.com/#{res.user.screen_name}/status/#{res.id}"
87
+ puts res.created_at
88
+ end
89
+
83
90
  def direct_message_create(to, message)
84
91
  res = Twitter.direct_message_create to, message
85
92
  puts res.text
@@ -1,3 +1,3 @@
1
1
  module Tw
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-26 00:00:00.000000000 Z
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter