tit 2.1.5 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/ChangeLog.markdown +29 -1
  2. data/VERSION.yml +1 -1
  3. data/bin/tit +11 -0
  4. data/lib/tit.rb +16 -5
  5. data/tit.gemspec +2 -2
  6. metadata +2 -2
@@ -1,7 +1,35 @@
1
- # tit 2.1.5 2011-09-12
1
+ # tit 2.1.7 2011-09-19
2
+
3
+ *
4
+
5
+ # tit 2.1.6 2011-09-19
2
6
 
3
7
  *
4
8
 
9
+ # tit 2.1.6 2011-09-19
10
+
11
+ *
12
+
13
+ # tit 2.1.6 2011-09-19
14
+
15
+ *
16
+
17
+ # tit 2.1.6 2011-09-19
18
+
19
+ *
20
+
21
+ # tit 2.1.6 2011-09-19
22
+
23
+ *
24
+
25
+ # tit 2.1.6 2011-09-19
26
+
27
+ * added preference as to whether t.co urls should be replaced with the expanded urls
28
+
29
+ # tit 2.1.5 2011-09-12
30
+
31
+ * some bug fixes and code restructuring
32
+
5
33
  # tit 2.1.0 2011-09-10
6
34
 
7
35
  * got direct messaging working -- requires reauthorization
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 2
3
3
  :minor: 1
4
- :patch: 5
4
+ :patch: 7
data/bin/tit CHANGED
@@ -26,14 +26,17 @@ def main
26
26
  options[:action] = :public
27
27
  unchanged = false
28
28
  end
29
+
29
30
  opts.on("-H", "--home", "Show home timeline (default)") do
30
31
  options[:action] = :home
31
32
  unchanged = false
32
33
  end
34
+
33
35
  opts.on("-m", "--mentions", "Show mentions timeline") do
34
36
  options[:action] = :mentions
35
37
  unchanged = false
36
38
  end
39
+
37
40
  opts.on("-u", "--user USERNAME",
38
41
  "Show a particular user's timeline") do |user|
39
42
  unchanged = false
@@ -41,6 +44,7 @@ def main
41
44
  options[:payload] ||= {}
42
45
  options[:payload]["user"] = user
43
46
  end
47
+
44
48
  opts.on("-d", "--dm [USERNAME]", "Read direct messages. Send a direct message if USERNAME is set and -t or --tweet accompanies it") do |user|
45
49
  unchanged = false
46
50
  if not user.nil?
@@ -51,6 +55,7 @@ def main
51
55
  options[:action] = :direct_messages
52
56
  end
53
57
  end
58
+
54
59
  opts.on("-t", "--tweet [STATUS]", "Update status (required when using -G)") do |status|
55
60
  unchanged = false
56
61
  if not options[:action].nil? and options[:action].eql?(:new_direct_message)
@@ -61,6 +66,7 @@ def main
61
66
  options[:payload]["status"] = status
62
67
  end
63
68
  end
69
+
64
70
  opts.on("--pin PIN", ("Set auth pin if this is your first time playing " +
65
71
  "with this tit")) do |pin|
66
72
  unchanged = false
@@ -115,6 +121,11 @@ def main
115
121
  tit.update_count(count)
116
122
  end
117
123
 
124
+ opts.on_tail("-o", "--tco TRUE/FALSE", "Tells tit whether to keep the t.co urls") do |tco|
125
+ unchanged = false
126
+ tit.update_tco(tco)
127
+ end
128
+
118
129
  opts.on_tail("-h", "--help", "Show this message") do
119
130
  unchanged = false
120
131
  puts opts
data/lib/tit.rb CHANGED
@@ -91,7 +91,7 @@ end
91
91
  Why are you reading the documentation, you cunt?
92
92
  =end
93
93
  class Tit
94
- VERSION = [2, 1, 5]
94
+ VERSION = [2, 1, 7]
95
95
 
96
96
  RCFILE = File.join(ENV["HOME"], ".titrc")
97
97
  RTFILE = File.join(ENV["HOME"], ".titrt")
@@ -136,7 +136,7 @@ class Tit
136
136
  YAML.dump(request_token.params, rt)
137
137
  end
138
138
  File.open(RCFILE, "w") do |rc|
139
- YAML.dump({:count => 10}, rc)
139
+ YAML.dump({:count => 10, :tco => true}, rc)
140
140
  end
141
141
  tuts "Please visit '#{request_token.authorize_url}'."
142
142
  tuts "When you finish, provide your pin with `tit --pin PIN'"
@@ -180,16 +180,19 @@ class Tit
180
180
  end
181
181
  api_endpoint.concat("&include_entities=true")
182
182
 
183
+ # I'll use this to decode HTML entities.
183
184
  coder = HTMLEntities.new
184
185
 
185
186
  # Parse XML
186
187
  xmlbody = @access_token.get(api_endpoint).body
188
+
187
189
  # Errors
188
190
  Nokogiri.XML(xmlbody).xpath("//errors").map do |xml|
189
191
  if xml.at_xpath("./error").content == "This application is not allowed to access or delete your direct messages"
190
192
  abort("Your OAuth key is not authorized for direct messaging.\nDelete #{TITAT} and run tit without arguments to reauthorize.")
191
193
  end
192
194
  end
195
+
193
196
  # no errors - get tits
194
197
  if action != :direct_messages
195
198
  Nokogiri.XML(xmlbody).xpath("//status").map do |xml|
@@ -199,8 +202,8 @@ class Tit
199
202
  :text => xml.xpath("./text").map do |n|
200
203
  txt = coder.decode(n.content)
201
204
  if not xml.xpath("./entities/urls").nil?
202
- xml.xpath("./entities/urls/url").map do |url|
203
- txt.replace_with_expanded_url!(url.xpath("./expanded_url").map { |expurl| expurl.content })
205
+ xml.xpath("./entities/urls/url").map do |url|
206
+ txt.replace_with_expanded_url!(url.xpath("./expanded_url").map { |expurl| expurl.content }) unless @prefs[:tco].eql?("TRUE")
204
207
  end
205
208
  end
206
209
  txt
@@ -256,7 +259,6 @@ class Tit
256
259
  end
257
260
 
258
261
  response = @access_token.post(URLS[:new_direct_message], payload)
259
- puts response
260
262
 
261
263
  # Check the response for errors
262
264
  Nokogiri.XML(response).xpath("//hash").map do |xml|
@@ -340,6 +342,15 @@ class Tit
340
342
  end
341
343
  exit(0)
342
344
  end
345
+
346
+ def update_tco(tco)
347
+ @prefs[:tco] = tco
348
+ @prefs["tco"] = tco
349
+ File.open(RCFILE, "w") do |rc|
350
+ YAML.dump(@prefs, rc)
351
+ end
352
+ exit(0)
353
+ end
343
354
 
344
355
  def tuts(*strs)
345
356
  strs.each { |s| puts s.to_s.wrapped(@cols) }
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tit}
8
- s.version = "2.1.5"
8
+ s.version = "2.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leif Walsh", "Parker Moore"]
12
- s.date = %q{2010-01-26}
12
+ s.date = %q{2011-09-19}
13
13
  s.default_executable = %q{tit}
14
14
  s.description = %q{a stupid fucking twitter client}
15
15
  s.email = [%q{leif.walsh@gmail.com}, %q{parkrmoore@gmail.com}]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.5
5
+ version: 2.1.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Leif Walsh
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-01-26 00:00:00 Z
14
+ date: 2011-09-19 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nokogiri