tweetwine 0.2.11 → 0.2.12

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/CHANGELOG.rdoc +7 -0
  2. data/{MIT-LICENSE.txt → LICENSE.txt} +1 -1
  3. data/README.md +122 -0
  4. data/Rakefile +59 -78
  5. data/bin/tweetwine +1 -0
  6. data/example/example_helper.rb +3 -1
  7. data/example/search_statuses_example.rb +2 -0
  8. data/example/show_followers_example.rb +2 -0
  9. data/example/show_friends_example.rb +2 -0
  10. data/example/show_home_example.rb +2 -0
  11. data/example/show_mentions_example.rb +2 -0
  12. data/example/show_metadata_example.rb +2 -0
  13. data/example/show_user_example.rb +2 -0
  14. data/example/update_status_example.rb +2 -0
  15. data/example/use_http_proxy_example.rb +2 -0
  16. data/lib/tweetwine/cli.rb +2 -0
  17. data/lib/tweetwine/client.rb +2 -0
  18. data/lib/tweetwine/io.rb +16 -11
  19. data/lib/tweetwine/meta.rb +3 -1
  20. data/lib/tweetwine/options.rb +2 -0
  21. data/lib/tweetwine/retrying_http.rb +2 -0
  22. data/lib/tweetwine/startup_config.rb +2 -0
  23. data/lib/tweetwine/url_shortener.rb +2 -0
  24. data/lib/tweetwine/util.rb +9 -6
  25. data/lib/tweetwine.rb +2 -0
  26. data/man/tweetwine.1 +109 -0
  27. data/man/tweetwine.1.ronn +69 -0
  28. data/man/tweetwine.7 +216 -0
  29. data/man/tweetwine.7.ronn +122 -0
  30. data/test/cli_test.rb +3 -1
  31. data/test/client_test.rb +3 -1
  32. data/test/io_test.rb +38 -31
  33. data/test/options_test.rb +3 -1
  34. data/test/retrying_http_test.rb +11 -11
  35. data/test/startup_config_test.rb +4 -2
  36. data/test/test_helper.rb +57 -47
  37. data/test/url_shortener_test.rb +3 -1
  38. data/test/util_test.rb +10 -3
  39. metadata +145 -20
  40. data/README.rdoc +0 -117
  41. /data/example/{fixtures → fixture}/home.json +0 -0
  42. /data/example/{fixtures → fixture}/mentions.json +0 -0
  43. /data/example/{fixtures → fixture}/search.json +0 -0
  44. /data/example/{fixtures → fixture}/update.json +0 -0
  45. /data/example/{fixtures → fixture}/user.json +0 -0
  46. /data/example/{fixtures → fixture}/users.json +0 -0
  47. /data/test/{fixtures → fixture}/test_config.yaml +0 -0
data/test/test_helper.rb CHANGED
@@ -1,63 +1,66 @@
1
+ # coding: utf-8
2
+
1
3
  require "tweetwine"
2
- require "test/unit"
3
- require "shoulda"
4
+ require "contest"
4
5
  require "mocha"
5
6
 
7
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
8
+
6
9
  module Tweetwine
7
- module TestHelpers
8
- def create_test_twitter_status_records_from_rest_api(*internal_records)
9
- twitter_records = internal_records.map do |internal_record|
10
- {
11
- "user" => { "screen_name" => internal_record[:from_user] },
12
- "created_at" => internal_record[:created_at],
13
- "text" => internal_record[:status],
14
- "in_reply_to_screen_name" => internal_record[:to_user]
15
- }
10
+ module Test
11
+ module Helper
12
+ module_function
13
+
14
+ def create_test_twitter_status_records_from_rest_api(*internal_records)
15
+ twitter_records = internal_records.map do |internal_record|
16
+ {
17
+ "user" => { "screen_name" => internal_record[:from_user] },
18
+ "created_at" => internal_record[:created_at],
19
+ "text" => internal_record[:status],
20
+ "in_reply_to_screen_name" => internal_record[:to_user]
21
+ }
22
+ end
23
+ [twitter_records, internal_records]
16
24
  end
17
- [twitter_records, internal_records]
18
- end
19
25
 
20
- def create_test_twitter_user_records_from_rest_api(*internal_records)
21
- twitter_records = internal_records.map do |internal_record|
22
- twitter_record = { "screen_name" => internal_record[:from_user] }
23
- if internal_record[:status]
24
- twitter_record.merge!({
25
- "status" => {
26
- "created_at" => internal_record[:created_at],
27
- "text" => internal_record[:status],
28
- "in_reply_to_screen_name" => internal_record[:to_user],
29
- }
30
- })
26
+ def create_test_twitter_user_records_from_rest_api(*internal_records)
27
+ twitter_records = internal_records.map do |internal_record|
28
+ twitter_record = { "screen_name" => internal_record[:from_user] }
29
+ if internal_record[:status]
30
+ twitter_record.merge!({
31
+ "status" => {
32
+ "created_at" => internal_record[:created_at],
33
+ "text" => internal_record[:status],
34
+ "in_reply_to_screen_name" => internal_record[:to_user],
35
+ }
36
+ })
37
+ end
38
+ twitter_record
31
39
  end
32
- twitter_record
40
+ [twitter_records, internal_records]
33
41
  end
34
- [twitter_records, internal_records]
35
- end
36
42
 
37
- def create_test_twitter_records_from_search_api(*internal_records)
38
- twitter_search_records = internal_records.map do |internal_record|
39
- {
40
- "from_user" => internal_record[:from_user],
41
- "created_at" => internal_record[:created_at],
42
- "text" => internal_record[:status],
43
- "to_user" => internal_record[:to_user]
43
+ def create_test_twitter_records_from_search_api(*internal_records)
44
+ twitter_search_records = internal_records.map do |internal_record|
45
+ {
46
+ "from_user" => internal_record[:from_user],
47
+ "created_at" => internal_record[:created_at],
48
+ "text" => internal_record[:status],
49
+ "to_user" => internal_record[:to_user]
50
+ }
51
+ end
52
+ twitter_records = {
53
+ "results" => twitter_search_records
44
54
  }
55
+ [twitter_records, internal_records]
45
56
  end
46
- twitter_records = {
47
- "results" => twitter_search_records
48
- }
49
- [twitter_records, internal_records]
50
- end
51
- end
52
- end
53
-
54
- Mocha::Configuration.prevent(:stubbing_non_existent_method)
55
57
 
56
- module Test
57
- module Unit
58
- class TestCase
59
- include Tweetwine::TestHelpers
58
+ def fixture_file(filename)
59
+ File.dirname(__FILE__) << "/fixture/" << filename
60
+ end
61
+ end
60
62
 
63
+ module Assertion
61
64
  def assert_full_match(regex, str, msg = "")
62
65
  match_data = regex.match(str)
63
66
  assert(str == match_data.to_s, msg)
@@ -69,4 +72,11 @@ module Test
69
72
  end
70
73
  end
71
74
  end
75
+
76
+ class TweetwineTestCase < ::Test::Unit::TestCase
77
+ include Tweetwine
78
+ include Test
79
+ include Test::Helper
80
+ include Test::Assertion
81
+ end
72
82
  end
@@ -1,8 +1,10 @@
1
+ # coding: utf-8
2
+
1
3
  require "test_helper"
2
4
 
3
5
  module Tweetwine
4
6
 
5
- class UrlShortenerTest < Test::Unit::TestCase
7
+ class UrlShortenerTest < TweetwineTestCase
6
8
  context "An UrlShortener instance" do
7
9
  setup do
8
10
  @http_client = mock()
data/test/util_test.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # coding: utf-8
2
+
1
3
  require "test_helper"
2
4
  require "time"
3
5
 
4
6
  module Tweetwine
5
7
 
6
- class UtilTest < Test::Unit::TestCase
8
+ class UtilTest < TweetwineTestCase
7
9
  context "for humanizing time differences" do
8
10
  should "use second granularity for time differences smaller than a minute" do
9
11
  assert_equal [1, "sec"], Util.humanize_time_diff(Time.parse("2009-01-01 00:00:59").to_s, Time.parse("2009-01-01 00:01:00"))
@@ -77,14 +79,14 @@ class UtilTest < Test::Unit::TestCase
77
79
  should "replace the contents of the string by using a single matching group of the regexp" do
78
80
  assert_equal "hEllo", Util.str_gsub_by_group("hello", /.+(e)/) { |s| s.upcase }
79
81
  assert_equal "hEllO", Util.str_gsub_by_group("hello", /([aeio])/) { |s| s.upcase }
80
- assert_equal "hEEllOO", Util.str_gsub_by_group("hello", /([aeio])/) { |s| s.upcase * 2 }
82
+ assert_equal "h<b>e</b>ll<b>o</b>", Util.str_gsub_by_group("hello", /([aeio])/) { |s| "<b>#{s}</b>" }
81
83
  assert_equal "hll", Util.str_gsub_by_group("hello", /([aeio])/) { |s| "" }
82
84
  assert_equal "hell", Util.str_gsub_by_group("hello", /.+([io])/) { |s| "" }
83
85
  end
84
86
 
85
87
  should "replace the contents of the string by using multiple matching groups of the regexp" do
86
88
  assert_equal "hEllO", Util.str_gsub_by_group("hello", /([ae]).+([io])/) { |s| s.upcase }
87
- assert_equal "hXEXllXOX", Util.str_gsub_by_group("hello", /([ae]).+([io])/) { |s| "X" + s.upcase + "X" }
89
+ assert_equal "h<b>e</b>ll<b>o</b>", Util.str_gsub_by_group("hello", /([ae]).+([io])/) { |s| "<b>#{s}</b>" }
88
90
  assert_equal "hll", Util.str_gsub_by_group("hello", /.+([ae]).+([io])/) { |s| "" }
89
91
  assert_equal "hll", Util.str_gsub_by_group("hello", /([ae]).+([io])/) { |s| "" }
90
92
  assert_equal "hEllo", Util.str_gsub_by_group("hello", /^(a)|.+(e)/) { |s| s.upcase }
@@ -93,6 +95,7 @@ class UtilTest < Test::Unit::TestCase
93
95
  should "replace the contents of the string by using the whole regexp if there are no groups in the regexp an the regexp matches" do
94
96
  assert_equal "", Util.str_gsub_by_group("", /el/) { |s| s.upcase }
95
97
  assert_equal "hELlo", Util.str_gsub_by_group("hello", /el/) { |s| s.upcase }
98
+ assert_equal "h<b>e</b>ll<b>o</b>", Util.str_gsub_by_group("hello", /e|o/) { |s| "<b>#{s}</b>" }
96
99
  end
97
100
 
98
101
  should "not change the contents of the string if the regexp does not match" do
@@ -108,6 +111,10 @@ class UtilTest < Test::Unit::TestCase
108
111
  assert_equal "hello", org_str
109
112
  assert_equal "hEllo", new_str
110
113
  end
114
+
115
+ should "work with UTF-8 input" do
116
+ assert_equal "Ali<b>en</b>³,<b>Pre</b>dator", Util.str_gsub_by_group("Alien³,Predator", /(en).+(Pre)/) { |s| "<b>#{s}</b>" }
117
+ end
111
118
  end
112
119
 
113
120
  context "for percent-encoding strings" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 11
9
- version: 0.2.11
8
+ - 12
9
+ version: 0.2.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tuomas Kareinen
@@ -31,6 +31,131 @@ dependencies:
31
31
  version: 1.0.0
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: contest
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 1
44
+ - 2
45
+ version: 0.1.2
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: coulda
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 5
58
+ - 3
59
+ version: 0.5.3
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: fakeweb
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 2
72
+ - 8
73
+ version: 1.2.8
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: gem-man
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ - 2
86
+ - 0
87
+ version: 0.2.0
88
+ type: :development
89
+ version_requirements: *id005
90
+ - !ruby/object:Gem::Dependency
91
+ name: matchy
92
+ prerelease: false
93
+ requirement: &id006 !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
99
+ - 3
100
+ - 3
101
+ version: 0.3.3
102
+ type: :development
103
+ version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
105
+ name: mocha
106
+ prerelease: false
107
+ requirement: &id007 !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ segments:
112
+ - 0
113
+ - 9
114
+ - 8
115
+ version: 0.9.8
116
+ type: :development
117
+ version_requirements: *id007
118
+ - !ruby/object:Gem::Dependency
119
+ name: open4
120
+ prerelease: false
121
+ requirement: &id008 !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ segments:
126
+ - 1
127
+ - 0
128
+ version: "1.0"
129
+ type: :development
130
+ version_requirements: *id008
131
+ - !ruby/object:Gem::Dependency
132
+ name: ronn
133
+ prerelease: false
134
+ requirement: &id009 !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ segments:
139
+ - 0
140
+ - 5
141
+ - 0
142
+ version: 0.5.0
143
+ type: :development
144
+ version_requirements: *id009
145
+ - !ruby/object:Gem::Dependency
146
+ name: timecop
147
+ prerelease: false
148
+ requirement: &id010 !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ segments:
153
+ - 0
154
+ - 3
155
+ - 4
156
+ version: 0.3.4
157
+ type: :development
158
+ version_requirements: *id010
34
159
  description: A simple but tasty Twitter agent for command line use, made for fun.
35
160
  email: tkareine@gmail.com
36
161
  executables:
@@ -38,23 +163,22 @@ executables:
38
163
  extensions: []
39
164
 
40
165
  extra_rdoc_files:
41
- - MIT-LICENSE.txt
42
166
  - CHANGELOG.rdoc
43
- - README.rdoc
167
+ - LICENSE.txt
44
168
  files:
45
- - Rakefile
46
- - MIT-LICENSE.txt
47
169
  - CHANGELOG.rdoc
48
- - README.rdoc
170
+ - LICENSE.txt
171
+ - Rakefile
172
+ - README.md
49
173
  - bin/tweetwine
50
174
  - contrib/tweetwine-completion.bash
51
175
  - example/example_helper.rb
52
- - example/fixtures/home.json
53
- - example/fixtures/mentions.json
54
- - example/fixtures/search.json
55
- - example/fixtures/update.json
56
- - example/fixtures/user.json
57
- - example/fixtures/users.json
176
+ - example/fixture/home.json
177
+ - example/fixture/mentions.json
178
+ - example/fixture/search.json
179
+ - example/fixture/update.json
180
+ - example/fixture/user.json
181
+ - example/fixture/users.json
58
182
  - example/search_statuses_example.rb
59
183
  - example/show_followers_example.rb
60
184
  - example/show_friends_example.rb
@@ -76,7 +200,7 @@ files:
76
200
  - lib/tweetwine.rb
77
201
  - test/cli_test.rb
78
202
  - test/client_test.rb
79
- - test/fixtures/test_config.yaml
203
+ - test/fixture/test_config.yaml
80
204
  - test/io_test.rb
81
205
  - test/options_test.rb
82
206
  - test/retrying_http_test.rb
@@ -84,6 +208,10 @@ files:
84
208
  - test/test_helper.rb
85
209
  - test/url_shortener_test.rb
86
210
  - test/util_test.rb
211
+ - man/tweetwine.1
212
+ - man/tweetwine.7
213
+ - man/tweetwine.1.ronn
214
+ - man/tweetwine.7.ronn
87
215
  has_rdoc: true
88
216
  homepage: http://github.com/tuomas/tweetwine
89
217
  licenses: []
@@ -91,12 +219,9 @@ licenses: []
91
219
  post_install_message:
92
220
  rdoc_options:
93
221
  - --title
94
- - tweetwine 0.2.11
95
- - --main
96
- - README.rdoc
222
+ - tweetwine 0.2.12
97
223
  - --exclude
98
224
  - test
99
- - --line-numbers
100
225
  require_paths:
101
226
  - lib
102
227
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -118,7 +243,7 @@ requirements: []
118
243
  rubyforge_project:
119
244
  rubygems_version: 1.3.6
120
245
  signing_key:
121
- specification_version: 3
122
- summary: A simple Twitter agent for command line use
246
+ specification_version: 2
247
+ summary: A simple Twitter command line agent
123
248
  test_files: []
124
249
 
data/README.rdoc DELETED
@@ -1,117 +0,0 @@
1
- = Tweetwine
2
-
3
- A simple but tasty Twitter agent for command line use, made for fun.
4
-
5
- == Features
6
-
7
- * Simple to use command line interface, with Bash completion support
8
- * ANSI coloring of statuses, but in discreet manner
9
- * Supports shortening URLs in a status update with a configurable shortening
10
- service
11
- * Configuration file for preferred settings
12
-
13
- == Installation
14
-
15
- Install Tweetwine as a RubyGem:
16
-
17
- $ gem install tweetwine
18
-
19
- The program is compatible with both Ruby 1.8 and 1.9.
20
-
21
- The program requires <b>rest_client</b> gem to be installed. In addition, the program needs <b>json</b> gem on Ruby 1.8.
22
-
23
- == Usage
24
-
25
- In the command line, run the program by entering
26
-
27
- $ tweetwine [global_options...] [command] [command_options...]
28
-
29
- The program needs the user's username and password for authentication. This
30
- information can be supplied either via a configuration file or as an option
31
- (<tt>-a USERNAME:PASSWORD</tt>) to the program. It is recommended to use the
32
- former method over the latter.
33
-
34
- The configuration file, in <tt>~/.tweetwine</tt>, is in YAML syntax. The
35
- program recognizes the following basic settings:
36
-
37
- username: <your_username>
38
- password: <your_password>
39
- colors: true|false
40
-
41
- The program supports showing the home timeline of the authenticated user, the
42
- latest statuses of friends and followers, and the latest statuses that mention
43
- the user. If that's not enough, statuses can be searched with arbitrary terms.
44
- In addition, new statuses can be sent.
45
-
46
- For all the global options and commands, see:
47
-
48
- $ tweetwine help
49
-
50
- For information about a specific command and its options, use:
51
-
52
- $ tweetwine help command
53
-
54
- === URL shortening for status update
55
-
56
- Before actually sending a status update, it is possible for the software to
57
- shorten the URLs in the update by using an external web service. This can be
58
- enabled via the <tt>shorten_urls</tt> key in configuration file; for
59
- example:
60
-
61
- username: spoonman
62
- password: withyourhands
63
- colors: true
64
- shorten_urls:
65
- enable: true
66
- service_url: http://is.gd/create.php
67
- method: post
68
- url_param_name: URL
69
- xpath_selector: //input[@id='short_url']/@value
70
-
71
- The supported methods are <tt>get</tt> and <tt>post</tt>. The method chosen
72
- affects whether parameters are passed as URL query parameters or as payload
73
- in the HTTP request, respectively. Extra parameters can be given via
74
- <tt>extra_params</tt> key, as a hash.
75
-
76
- The <tt>xpath_selector</tt> is needed to extract the shortened URL from the
77
- result.
78
-
79
- The feature can be disabled by
80
-
81
- * not defining <tt>shorten_urls</tt> key in the configuration file,
82
- * setting key <tt>enable</tt> to <tt>false</tt>, or
83
- * using the command line option <tt>--no-url-shorten</tt>.
84
-
85
- The use of the feature requires <b>nokogiri</b> gem to be installed.
86
-
87
- === HTTP proxy setting
88
-
89
- If <tt>$http_proxy</tt> environment variable is set, Tweetwine attempts to use
90
- the URL in the environment variable as HTTP proxy for all its HTTP
91
- connections. This setting can be overridden with <tt>--http-proxy</tt> and
92
- <tt>--no-http-proxy</tt> command line options.
93
-
94
- === Bash command line completion support
95
-
96
- Bash shell supports command line completion via tab character. If you want to
97
- enable Tweetwine specific completion with Bash, source the file
98
- <tt>tweetwine-completion.bash</tt>, located in <tt>contrib</tt> directory:
99
-
100
- . contrib/tweetwine-completion.bash
101
-
102
- In order to do this automatically when your shell starts, insert the following
103
- snippet to your Bash initialization script (such as <tt>~/.bashrc</tt>):
104
-
105
- if [ -f <path_to_tweetwine>/contrib/tweetwine-completion.bash ]; then
106
- . <path_to_tweetwine>/contrib/tweetwine-completion.bash
107
- fi
108
-
109
- == Contacting
110
-
111
- Please send feedback by email to Tuomas Kareinen < tkareine (at) gmail (dot)
112
- com >.
113
-
114
- == Legal notes
115
-
116
- Copyright (c) 2009-2010 Tuomas Kareinen. See MIT-LICENSE.txt in this
117
- directory.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes