fry-send_tweet.rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +282 -0
  3. data/LICENSE.txt +24 -0
  4. data/PRY_LICENSE.txt +25 -0
  5. data/README.md +456 -0
  6. data/Vagrantfile +46 -0
  7. data/art/44-e44743a5bb.jpg +0 -0
  8. data/art/52-eec4df2edf.jpg +0 -0
  9. data/lib/pry-send_tweet.rb +75 -0
  10. data/lib/pry/pager/system_pager.rb +25 -0
  11. data/lib/pry/send_tweet/commands/base_command.rb +70 -0
  12. data/lib/pry/send_tweet/commands/easter_eggs.rb +184 -0
  13. data/lib/pry/send_tweet/commands/paging/paging_support.rb +16 -0
  14. data/lib/pry/send_tweet/commands/read_tweets.rb +93 -0
  15. data/lib/pry/send_tweet/commands/read_tweets/translate_actions.rb +94 -0
  16. data/lib/pry/send_tweet/commands/send_tweet.rb +151 -0
  17. data/lib/pry/send_tweet/commands/twitter_action.rb +118 -0
  18. data/lib/pry/send_tweet/commands/twitter_action/delete_tweet_actions.rb +19 -0
  19. data/lib/pry/send_tweet/commands/twitter_action/follow_actions.rb +66 -0
  20. data/lib/pry/send_tweet/commands/twitter_action/like_actions.rb +23 -0
  21. data/lib/pry/send_tweet/commands/twitter_action/mute_actions.rb +23 -0
  22. data/lib/pry/send_tweet/commands/twitter_action/profile_actions.rb +60 -0
  23. data/lib/pry/send_tweet/commands/twitter_action/suggested_actions.rb +20 -0
  24. data/lib/pry/send_tweet/commands/twitter_search.rb +36 -0
  25. data/lib/pry/send_tweet/renderers/tweet_renderer.rb +103 -0
  26. data/lib/pry/send_tweet/renderers/user_renderer.rb +17 -0
  27. data/lib/pry/send_tweet/tty-box.rb +73 -0
  28. data/lib/pry/send_tweet/twitter_io.rb +26 -0
  29. data/lib/pry/send_tweet/version.rb +5 -0
  30. data/lib/time-ago-in-words/README.md +14 -0
  31. data/lib/time-ago-in-words/lib/time-ago-in-words.rb +37 -0
  32. data/lib/time-ago-in-words/time-ago-in-words.gemspec +14 -0
  33. data/pry-send_tweet.gemspec +23 -0
  34. data/samples/freebsd-zshrc +5 -0
  35. data/samples/tmuxinator-vagrant.yml +11 -0
  36. data/vms/freebsd.rb +15 -0
  37. metadata +123 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ff77de5abd98525df5babd93cfb108c6e1fd60612ed29d2f508a213eeb46d527
4
+ data.tar.gz: cb1b6beafceec98a3622f5650d403a09006fa4dbf80092c5b3cc86c9a2cdab88
5
+ SHA512:
6
+ metadata.gz: fc75531a52115c92e6e171edebc4eafeb87f844ca0860f2e8a28d08f7e043c551095a72e80afa712fec2e3eacd8af1d1b2e6e9f95a9edbc9c7a01c48ced16412
7
+ data.tar.gz: 81684f84db430dc7cf1acf044e2991a02359fde085a2ff570cb838698872715669fce7072acaec2e430d91dc42b379b28776c2f0e1550db8c04015f7d28c144c
@@ -0,0 +1,282 @@
1
+ # CHANGELOG
2
+
3
+ ## master
4
+
5
+ * Read media contents into memory immediately to avoid the potential for
6
+ tampering between the time tweet is scheduled and its actual creation.
7
+
8
+ * Update `README.md` documentation to include `on-twitter --set-profile-location`.
9
+
10
+ * Include the time of the last and next refresh cycle when rendering
11
+ tweets that are automatically refreshed every `X` seconds.
12
+
13
+ * `TimeAgoInWords` represents a past tense Time object as
14
+ `<number> <unit> before <time>`.
15
+
16
+ * A single instance of `Twitter::REST::Client` shared across potentially
17
+ multiple threads is not going to work, re-create `Twitter::REST::Client`
18
+ instance before each eval, that is local to its Pry instance.
19
+
20
+ * Switch to `Pry#add_sticky_local` for inserting the special local variable,
21
+ `_twitter_`.
22
+
23
+ * Add `config.twitter.default_read_size`, for setting the default number of
24
+ tweets to request from Twitter when reading tweets via its API.
25
+
26
+ ## v0.13.1
27
+
28
+ * Load `$HOME/.pry-send_tweet.yml` using `YAML.safe_load()`.
29
+
30
+ * Add `time-ago-in-words` README and gemspec to Rubygem package.
31
+
32
+ ## v0.13.0
33
+
34
+ * Remove `Gemfile`, and the Bundler dependency.
35
+
36
+ * On the FreeBSD VM, runtime dependencies are installed as FreeBSD packages.
37
+
38
+ * Rethink fork + wait logic in `read-tweets`.
39
+
40
+ * Configure the default timezone on the FreeBSD VM to be CET (Central European Time).
41
+ This can be changed by `$VMTZ`. Please see the README for an example.
42
+
43
+ * `on-twitter --show-following` and `on-twitter --show-followers` accept an
44
+ optional regular expression that can filter through the result set.
45
+
46
+ * Implement `ruby vms/freebsd.rb --fresh`, for destroying an old VM and
47
+ spinning up a new one.
48
+
49
+ * Implement `time-ago-in-words` without patching the Time class.
50
+
51
+ * Remove `spec/`.
52
+
53
+ * Timestamps in the future or present are represented as '0 seconds' ago
54
+ in `lib/time-ago-in-words`.
55
+
56
+ * Replace 'time-lord' with 'time-ago-in-words'
57
+
58
+ * Print an error when unknown switches are passed to command
59
+
60
+ * Switch default editor to 'ee' on FreeBSD VM
61
+
62
+ * Add mitigation for RCE bug in apt-get to Dockerfile.
63
+
64
+ * `--delay`, and `--self-destruct` assume that a time such as 07:00, which
65
+ has past on the current day, was meant to mean 07:00, tomorrow.
66
+
67
+ * Install FreeBSD-12 with Vagrant due to unresolvable issues with the
68
+ HardenedBSD vagrant box.
69
+
70
+ * Replace `t.co` links with the expanded URL `t.co` redirects to.
71
+
72
+ * Collect status of system pager after sending `SIGKILL`.
73
+
74
+ * When translating text or a tweet, show the source and destination language.
75
+
76
+ * Add `read-tweets -sl=`, `read-tweets --source-lang=` for setting the source
77
+ language of the text or tweet being translated.
78
+
79
+ * Add `read-tweets -tx`, for translating a piece of text using the Yandex
80
+ translation API.
81
+
82
+ * Set CET (Central European Time) as the default timezone for the HardenedBSD VM.
83
+
84
+ * Implement a minimum box height of 8, but scale to a larger number if a tweet
85
+ or user bio is written using a lot of newlines.
86
+
87
+ * Remove the `config.box_height` option.
88
+
89
+ * Typo fix: rescue `Twitter::Error`, not `Timeout::Error`, when liking a tweet.
90
+
91
+ ## v0.12.1
92
+
93
+ * Correct multiple grammar errors found in the help output of all commands.
94
+
95
+ ## v0.12.0
96
+
97
+ * Add `Vagrantfile` & related files to spawn a VirtualBox VM running
98
+ [HardenedBSD](https://hardenedbsd.org).
99
+
100
+ * Distribute `samples/*` as part of the Rubygem package.
101
+
102
+ ## v0.11.0
103
+
104
+ * Apply a fix to tty-box for the `on-twitter --show-followers`, and
105
+ `on-twitter --show-following` commands.
106
+
107
+ * Add unicode support by applying a fix - as a monkey patch - to the `tty-box`
108
+ gem.
109
+
110
+ * Add `unicode-display_width`, and `unicode-emoji` as runtime dependencies.
111
+
112
+ * Add `read-tweets -x`, `read-tweets --translate` - for translating tweets,
113
+ using the Yandex translation API.
114
+
115
+ * `on-twitter --follow` & `on-twitter --unfollow` understand a string such as
116
+ `https://twitter.com/StephenKing/media` to mean `@StephenKing`.
117
+
118
+ * Include a URL to a users profile when following or unfollowing them.
119
+
120
+ * Remove duplicate username when replying to a tweet. This could happen when the
121
+ tweet author and the person replying to the tweet are the same.
122
+
123
+ * Update `Pry::SendTweet::UserRenderer` to use `config.box_width`, and
124
+ `config.box_height`.
125
+
126
+ * Use `page_ok()` from `send-tweet` command.
127
+
128
+ ## v0.10.1
129
+
130
+ * Improve forking implementation in `Pry::SendTweet::TweetRenderer`.
131
+
132
+ * Improve the workaround for weak unicode support in tty-box.
133
+
134
+ * Add `Pry.config.twitter.box_height` - for defining the height of the box that
135
+ contains a tweet or user.
136
+
137
+ * Add `Pry.config.twitter.box_width`, formerly `Pry.config.twitter.line_width`.
138
+
139
+ ## v0.10.0
140
+
141
+ * Avoid a negative argument error when following / unfollowing other user(s) by
142
+ bypassing tty-box for those operations.
143
+
144
+ * Improve the title that appears above tweets when using the `read-tweets`
145
+ command.
146
+
147
+ * Add support for `read-tweets -t https://twitter.com/username`.
148
+
149
+ * Add `--set-profile-location`, and `--set-profile-link-color=` to the
150
+ `on-twitter` command.
151
+
152
+ ## v0.9.0
153
+
154
+ * Render `Twitter::Tweet` and `Twitter::User` objects using `TTY::Box` - with the
155
+ knowledge that it has bugs and limitations that will need to be fixed in the
156
+ future.
157
+
158
+ * Improve `send-tweet --reply-to` by writing the tweet owners screen name
159
+ and all other user mentions in their tweet to the temp file created
160
+ to compose a reply.
161
+
162
+ * Add `on-twitter --show-following` to show the newest tweeters you have started d
163
+ to follow.
164
+
165
+ * Add `on-twitter --show-followers` to show the newest tweeters to have followed
166
+ you.
167
+
168
+ * Add the option to configure pry-send_tweet through a YAML file.
169
+
170
+ * Add `dockerize.sh` to gem package.
171
+
172
+ * Add README documentation for following related actions.
173
+
174
+ * Add README documentation for all `on-twitter` actions related to a users
175
+ profile.
176
+
177
+ ## v0.8.0ddd
178
+
179
+ * Add sticky local variable `_twitter_` to the active Binding.
180
+
181
+ ## v0.7.0
182
+
183
+ * Add `send-tweet -n`, `send-tweet --no-newline`, for removing newlines from a
184
+ tweet before sending it.
185
+
186
+ * Add `twitter-action --mute-user=`
187
+
188
+ * Add `twitter-action --suggested-users=`, `twitter-action --suggested-topics`
189
+ and `twitter-action --suggested-lang`.
190
+
191
+ * Add configuration option, `Pry.config.twitter.line_width`, for choosing the
192
+ a lines width before word wrapping occurs. Default line width is 200.
193
+
194
+ * Add pre-post tweet validation that catches empty tweets, and tweets who use
195
+ too many characters.
196
+
197
+ * Add `send-tweet --delay=xx` for delaying the creation of a tweet by a number
198
+ of seconds.
199
+
200
+ * Add `send-tweet --self-destruct=xx` for automatically deleting a tweet after
201
+ a number of seconds.
202
+
203
+ * Add `twitter-search`.
204
+
205
+ * Add `read-tweets --tweeter=`, a longer version of `read-tweets -t`.
206
+
207
+ * Add `read-tweets --replies <user>`.
208
+
209
+ * Add short hand variants for all `read-tweets` options.
210
+
211
+ * Combine the `read-tweets` options `--my-likes` and `--liked-by` into
212
+ one option, `--likes`.
213
+
214
+ * Rename `read-tweets --that-mention-me` to `read-tweets --mentions`.
215
+
216
+ * Don't hit the Twitter API if a composed tweet is entirely whitespace.
217
+
218
+ * `send-tweet --file` accepts a comma separated list for attaching multiple
219
+ images to a tweet.
220
+
221
+ * Like, unlike, and delete actions accept a comma separated list for performing
222
+ an action on multiple tweets.
223
+
224
+ ## v0.6.0
225
+
226
+ * Fix a bug where the auto refresh feature could not be disabled.
227
+ `Pry.config.twitter.refresh_interval` should be set to `false` instead of
228
+ `nil` to disable this feature.
229
+
230
+ * Modify `render_tweets()` to accept the optional keyword argument, 'timeout'.
231
+
232
+ * Render liked, unliked, and deleted (re)tweets via `render_tweets()`.
233
+
234
+ * Change default User-Agent sent with requests to the Twitter API to `pry-send_tweet vX.Y.Z`
235
+
236
+ * Add the option to configure the `User-Agent` sent with requests to the Twitter API,
237
+ via `Pry.config.twitter.user_agent`.
238
+
239
+ * Add `Pry::SendTweet::VERSION`.
240
+
241
+ ## v0.5.3
242
+
243
+ * Fix another NoMethodError
244
+
245
+ ## v0.5.2
246
+
247
+ * Fix a NoMethodError when following a user.
248
+
249
+ * Update gemspec to include all files checked into git.
250
+
251
+ ## v0.5.1
252
+
253
+ * Update an outdated description for the `read-tweets` command.
254
+
255
+ * Group the `send-tweet` command under the `Twitter` group, it was previously
256
+ grouped as '(other)'.
257
+
258
+ ## v0.5.0
259
+
260
+ * Automatically refresh the tweets on display every 4 minutes.
261
+
262
+ * `Pry.config.twitter.refresh_interval` can be used for setting a custom refresh
263
+ interval. The default is 240 seconds, or 4 minutes.
264
+
265
+ * Add the command `read-tweets`.
266
+
267
+ * Add the command `twitter-action`, aliased as `on-twitter`.
268
+
269
+ ## v0.4.0
270
+
271
+ * Add support for attaching an image to a tweet with
272
+ the optional `-f` / `--file` switch:
273
+
274
+ `send-tweet --file /path/to/image.jpg`
275
+
276
+ ## v0.3.0
277
+
278
+ * Compose a tweet using `pry.editor`
279
+
280
+ ## v0.2.1
281
+
282
+ * Don't escape tweet content using 'Shellwords'.
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2018, Robert Gleeson
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Fry organization nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,25 @@
1
+ License
2
+ -------
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2011-2019 The Pry Team
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,456 @@
1
+ # fry-send_tweet.rb
2
+
3
+ * [Introduction](#introduction)
4
+ * [API Access](#api-access)
5
+ * [Configuration - required](#configuration)
6
+ * [Usage](#usage)
7
+ * [Sending Tweets](#sending-tweets)
8
+ * [Reading Tweets](#reading-tweets)
9
+ * [Deleting Tweets](#deleting-tweets)
10
+ * [Liking Tweets](#liking-tweets)
11
+ * [Following / unfollowing](#following-unfollowing)
12
+ * [Searching Twitter](#searching-twitter)
13
+ * [Retweets](#retweets)
14
+ * [Profile Actions](#profile-actions)
15
+ * [Twitter Suggestions](#twitter-suggestions)
16
+ * [Muting other users](#muting-other-users)
17
+ * [Sticky local variable: `_twitter_` ](#special-variable-_twitter_)
18
+ * [Tip: Command Aliases](#tip)
19
+ * [Multi-tasking: tmux / screen](#multi-tasking)
20
+ * [Install](#install)
21
+ * [Rubygem](#install-rubygem)
22
+ * [Virtual Machines](#vms)
23
+ * [FreeBSD](#vms-freebsd)
24
+ * [Screenshots](#screenshots)
25
+ * [License](#license)
26
+
27
+ ## <a id='Introduction'>Introduction</a>
28
+
29
+ An extensible Twitter client that lives inside the Pry and Fry REPLs.
30
+
31
+ ## <a id='api-access'>API Access</a>
32
+
33
+ Using the Twitter API requires a developer account.
34
+ Follow the instructions at [https://developer.twitter.com](https://developer.twitter.com)
35
+ if you haven't already setup access to the Twitter API.
36
+
37
+ ## <a id='configuration'>Configuration (required)</a>
38
+
39
+ The placeholder keys and tokens in the below example can be replaced
40
+ by those from your developer account. pry-send_tweet.rb can be configured from
41
+ a `.pryrc` file using Ruby, or through a YAML file located at
42
+ `$HOME/.pry-send_tweet.yml`
43
+
44
+ __1. Ruby__
45
+
46
+ ```ruby
47
+ # .pryrc
48
+ Pry.configure do |config|
49
+ config.twitter = Pry::Config.from_hash({
50
+ # Required
51
+ consumer_key: '<consumer key>',
52
+ consumer_secret: '<consumer secret>',
53
+ access_token: '<access token>',
54
+ access_token_secret: '<access token secret>',
55
+ # Optional
56
+ # The number of tweets to request from Twitter when reading tweets via
57
+ # its API. The default is 200, a lower number could speed up requests if
58
+ # you find them to be slow.
59
+ default_read_size: 100,
60
+ # Optional
61
+ # The User-Agent to use when making requests to the Twitter API.
62
+ # Default is: 'pry-send_tweet.rb vX.Y.Z'.
63
+ user_agent: 'Custom User-Agent',
64
+ # Optional
65
+ # The width of a box that contains a tweet or user. The default width is 100.
66
+ box_width: 120,
67
+ # Optional
68
+ # A Yandex API key for translating tweets when using `read-tweets -x`.
69
+ yandex_key: 'xxx',
70
+ # Optional
71
+ # The language tweets should be translated to, the default is 'en' (English).
72
+ yandex_lang: 'ru'
73
+ })
74
+ end
75
+ ```
76
+
77
+ __2. YAML__
78
+
79
+ `$HOME/.pry-send_tweet.yml`:
80
+
81
+ ```yaml
82
+ ---
83
+ # Required
84
+ consumer_key: '<consumer key>'
85
+ consumer_secret: '<consumer secret>'
86
+ access_token: '<access token>'
87
+ access_token_secret: '<access token secret>'
88
+ # Optional
89
+ default_read_size: 100
90
+ # Optional
91
+ user_agent: 'Your User-Agent string'
92
+ # Optional
93
+ box_width: 120
94
+ # Optional
95
+ yandex_key: xxx
96
+ yandex_lang: xx
97
+ ```
98
+
99
+ ## <a id='usage'>Usage</a>
100
+
101
+ There are four commands added to Pry by this plugin, those commands are:
102
+
103
+ * `send-tweet`
104
+ For sending tweets.
105
+
106
+ * `read-tweets`
107
+ For reading tweets.
108
+
109
+ * `twitter-action` (aliased as: `on-twitter`)
110
+ For performing misc actions on Twitter, such as following, unfollowing, etc.
111
+
112
+ * `twitter-search`
113
+ For searching Twitter.
114
+
115
+ Each command provides help, that can be shown by appending `--help` to the
116
+ command. Example:
117
+
118
+ [1] pry(main)> send-tweet --help
119
+
120
+ ### <a id='sending-tweets'>Sending tweets</a>
121
+
122
+
123
+ * Send a tweet:
124
+
125
+ # Your editor opens (`_pry_.editor`), compose a tweet then hit save & close.
126
+ # You'll then get the url for your tweet:
127
+ [1] pry(main)> send-tweet
128
+ https://twitter.com/xxx/status/xxx
129
+
130
+
131
+ * Send a tweet with an image attached:
132
+
133
+ [1] pry(main)> send-tweet --file #{File.join ENV['HOME'], 'photos', 'image.jpg'}
134
+
135
+
136
+ * Send a tweet with multiple images attached:
137
+
138
+ [1] pry(main)> send-tweet --file #{%w[1.jpg 2.jpg 3.jpg].join(',')}
139
+
140
+ * Reply to a tweet:
141
+
142
+ [1] pry(main)> send-tweet --reply-to https://twitter.com/username/status/1
143
+
144
+ * Send a tweet that will self-destruct after 70 seconds.
145
+ It's worth adding that if the Pry process exits this operation will be cancelled:
146
+
147
+ [1] pry(main)> send-tweet --self-destruct=70
148
+
149
+ * Send a tweet that will be published 70 seconds in the future.
150
+ It's worth adding that if the Pry process exits, this operation will be cancelled:
151
+
152
+ [1] pry(main)> send-tweet --delay=70
153
+
154
+ * Delay sending a tweet until 12AM, today. `--self-destruct` also supports this
155
+ syntax:
156
+
157
+ [1] pry(main)> send-tweet --delay=00:00
158
+
159
+ ### <a id='reading-tweets'>Reading tweets</a>
160
+
161
+ By default the tweets displayed by the `read-tweets` command are automatically
162
+ refreshed every 5 minutes.
163
+
164
+ That can be changed to a custom interval by setting `Pry.config.twitter.refresh_interval`
165
+ to a number of seconds, or to `false` if you want to disable this feature.
166
+
167
+ * Read recent tweets from your timeline:
168
+
169
+ [1] pry(main)> read-tweets
170
+
171
+ * Read recent tweets from the timeline of another user:
172
+
173
+ [1] pry(main)> read-tweets -t rubygems
174
+
175
+ * Read recent tweets that `@mention` you:
176
+
177
+ [1] pry(main)> read-tweets --mentions
178
+
179
+ * Read recent tweets that you've liked:
180
+
181
+ [1] pry(main) read-tweets --likes
182
+
183
+ * Read recent tweets liked by another user:
184
+
185
+ [1] pry(main)> read-tweets --likes ladygaga
186
+
187
+ * Read recent tweets sent as replies by a given user, the example uses `@github`:
188
+
189
+ [1] pry(main)> read-tweets --replies github
190
+
191
+ * Read a translated copy of a tweet, using the
192
+ [Yandex translation API](https://translate.yandex.com/developers).
193
+ The configuration instructions for Yandex are included in the [configuration section](#configuration).
194
+
195
+ [1] pry(main)> read-tweets -x https://twitter.com/user/status/1
196
+
197
+ * Read a translated copy of a piece of text:
198
+
199
+ [1] pry(main)> read-tweets -tx='#{File.binread "persian.txt"}'
200
+ [2] pry(main)> read-tweets -tx='Guten Tag'
201
+ [3] pry(main)> read-tweets -tx='Hola'
202
+
203
+ * Sometimes Yandex cannot detect the language of the text or tweet being
204
+ translated, or it will guess the source language incorrectly. In case
205
+ this happens, the source language can be set explicitly:
206
+
207
+ [1] pry(main)> read-tweets --source-lang=fa -x https://url/to/farsi/tweet
208
+ [1] pry(main)> read-tweets --source-lang=sw -tx='Habari yako'
209
+
210
+ * Read 100 recent tweets instead of the default 200 recent tweets.
211
+ **Tip:** `--count` can be combined with all of the options described above.
212
+
213
+ [1] pry(main)> read-tweets --count 100
214
+
215
+ * By default retweets are not displayed.
216
+ To display retweets, pass the `--with-retweets` option.
217
+
218
+ [1] pry(main)> read-tweets --with-retweets
219
+
220
+ ### <a id='deleting-tweets'>Deleting tweets</a>
221
+
222
+ * Delete one or more tweets with a comma separated list:
223
+
224
+ [1] pry(main)> on-twitter --delete-tweet https://twitter.com/username/status/1,https://twitter.com/username/status/2
225
+
226
+ * Delete one or more retweets with a comma separated list:
227
+
228
+ [1] pry(main)> on-twitter --delete-retweet https://twitter.com/username/status/1,https://twitter.com/username/status/2
229
+
230
+ ### <a id='liking-tweets'>Liking tweets</a>
231
+
232
+ * Like one or more tweets with a comma separated list:
233
+
234
+ [1] pry(main)> on-twitter --like https://twitter.com/user/status/1,https://twitter.com/user/status/2
235
+
236
+ * Unlike one or more tweets with a comma separated list:
237
+
238
+ [1] pry(main)> on-twitter --unlike https://twitter.com/user/status/1,https://twitter.com/user/status/2
239
+
240
+ ### <a id='following-unfollowing'> Following / unfollowing </a>
241
+
242
+ * Follow one or more tweeters with a comma separated list:
243
+
244
+ [1] pry(main)> on-twitter --follow user1,user2,user3
245
+
246
+ * Unfollow one or more tweeters with a comma separated list:
247
+
248
+ [1] pry(main)> on-twitter --unfollow user1,user2,user3,user4
249
+
250
+ * Show the tweeters who are following you:
251
+
252
+ [1] pry(main)> on-twitter --show-followers
253
+
254
+ * Show the tweeters who you follow:
255
+
256
+ [1] pry(main)> on-twitter --show-following
257
+
258
+ * Both `--show-following` and `--show-followers` accept an optional argument
259
+ that can be used to filter the result set.
260
+
261
+ [1] pry(main)> on-twitter --show-following=[0-9]$
262
+
263
+ ### <a id='searching-twitter'>Searching Twitter</a>
264
+
265
+ The `twitter-search` command can be used to search Twitter.
266
+
267
+ * Search Twitter using a given hashtag:
268
+
269
+ [1] pry(main)> twitter-search #ruby
270
+
271
+ ### <a id='retweets'>Retweets</a>
272
+
273
+ * Retweet one or more tweets with a comma separated list:
274
+
275
+ [1] pry(main)> on-twitter --retweet https://twitter.com/user/status/1,https://twitter.com/user/status/2
276
+
277
+ ### <a id='profile-actions'>Profile actions</a>
278
+
279
+ * Set the name visible on your profile:
280
+
281
+ [1] pry(main)> on-twitter --set-profile-name=<name>
282
+
283
+ * Set the profile bio / description visible on your profile:
284
+
285
+ # An editor opens (`_pry_.editor`), write your bio then hit save & close.
286
+ # Your profiles bio will be updated after closing the editor.
287
+ [1] pry(main)> on-twitter --set-profile-bio
288
+
289
+ * Set the location visible on your profile:
290
+
291
+ # An editor opens (`_pry_.editor`), write a location then hit save & close.
292
+ # Your profiles location will be updated after closing the editor.
293
+ [1] pry(main)> on-twitter --set-profile-location
294
+
295
+ * Set the color (as a hex value) of links that appear on your profiles timeline:
296
+
297
+ [1] pry(main)> on-twitter --set-profile-link-color=#CC0000
298
+
299
+ * Set the URL visible on your profile:
300
+
301
+ [1] pry(main)> on-twitter --set-profile-url=https://github.com/you
302
+
303
+ * Set profile image:
304
+
305
+ [1] pry(main)> on-twitter --set-profile-image /path/to/image.jpg
306
+
307
+ * Set the banner image visible on your profile:
308
+
309
+ [1] pry(main)> on-twitter --set-profile-banner-image /path/to/image.jpg
310
+
311
+
312
+ ### <a id='twitter-suggestions'>Twitter Suggestions</a>
313
+
314
+ * View a list of suggested topics, optionally restricted to Spanish:
315
+
316
+ [1] pry(main)> on-twitter --suggested-lang=es --suggested-topics
317
+
318
+ * View a list of suggested users from a given topic, optionally restricted to
319
+ Spanish:
320
+
321
+ [1] pry(main)> on-twitter --suggested-lang=es --suggested-users=<topic>
322
+
323
+
324
+ ### <a id='muting-other-users'>Muting other users</a>
325
+
326
+ * Mute one or more users with a comma separated list:
327
+
328
+ [1] pry(main)> on-twitter --mute-user=user1,user2,user3
329
+
330
+ * Unmute one or more users with a comma separated list:
331
+
332
+ [1] pry(main)> on-twitter --unmute-user=user1,user2,user3,user4
333
+
334
+
335
+ ### <a id='special-variable-_twitter_'>Sticky local variable: `_twitter_`</a>
336
+
337
+ The local variable `_twitter_` is inserted into the active Binding, providing
338
+ a programmable API accessible to Ruby code as well as a lower level of access to
339
+ the Twitter API. It is meant for exploration, development, and debugging.
340
+ The local variable is considered reserved.
341
+
342
+ The local variable returns an instance of `Twitter::REST::Client`:
343
+
344
+ [1] pry(main)> _twitter_
345
+ => #<Twitter::REST::Client:0x00007ff44cd6dce0
346
+ @access_token="xxx",
347
+ @access_token_secret="xxx",
348
+ @consumer_key="xxx",
349
+ @consumer_secret="xxx",
350
+ @user_agent="pry-send_tweet.rb v0.7.0">
351
+
352
+ ### <a id='tip'>Tip: Command Aliases</a>
353
+
354
+ When there are Twitter accounts you read often, it can turn out to be faster
355
+ to create command aliases for reading those accounts. An example follows, a
356
+ hyphen is included in the aliased commands to avoid collisions with Ruby code.
357
+
358
+ ```ruby
359
+ # .pryrc
360
+ Pry.commands.alias_command "prez-trump", "read-tweets -t realdonaldtrump"
361
+ Pry.commands.alias_command "prez-obama", "read-tweets -t barackobama"
362
+ ```
363
+
364
+ ## <a id='multi-tasking'>Multi-tasking: tmux / screen</a>
365
+
366
+ To get the most out of `pry-send_tweet.rb` I use tmux to manage a pane for reading
367
+ tweets and another for writing tweets. I've found this to be the best way since
368
+ a single shell does not allow for multi tasking but tmux and screen do.
369
+
370
+ I use [tmuxinator](https://github.com/tmuxinator/tmuxinator) to manage my tmux
371
+ sessions. The tmuxinator configuration I use is checked into the repo in the
372
+ hope that it might be useful to others.
373
+
374
+ * [tmuxinator-vagrant.yml](./samples/tmuxinator-vagrant.yml)
375
+
376
+ ## <a id='vms'>Virtual Machines</a>
377
+
378
+ Before getting started with a Virtual Machine, download and install the
379
+ following tools if you didn't already, they're free:
380
+
381
+ * VirtualBox
382
+ * Vagrant
383
+
384
+ Next, configure access to the Twitter API by adding `.pryrc` file to the root of
385
+ the repository. That's covered in the [configuration](#configuration) section.
386
+
387
+ ### Shared space
388
+
389
+ While exploring, developing or tweeting on one of the available VMs sometimes
390
+ you want to bring files from the 'host' machine to the virtual machine, which
391
+ is known as the guest machine.
392
+
393
+ __Syncing files__
394
+
395
+ `vagrant rsync-auto` can see edits made to the cloned repo on the host
396
+ machine and sync those changes back to the guest machine. To set this up, from
397
+ the root of the repo on the host machine run:
398
+
399
+ $ vagrant rsync-auto
400
+
401
+ __Tweeting media__
402
+
403
+ To tweet media such as an image or video from the VM, what I do is drop those
404
+ files into `/app/shared-space` and then reference `/app/shared-space` when
405
+ sharing them, eg `send-tweet -f /app/shared-space/photo.jpg`.
406
+
407
+ ### <a id='vms-freebsd'>FreeBSD</a>
408
+
409
+ [FreeBSD 12](https://freebsd.org) Virtual Machine
410
+
411
+ Vagrant will use Amazon to download the box image. Sometimes the download can be
412
+ slow, sometimes the download can stall..
413
+
414
+ Keep trying if this happens, a download should always resume from the point
415
+ where it finished. FreeBSD is worth the perseverance. :)
416
+
417
+ $ git clone https://github.com/r-obert/pry-send_tweet.rb
418
+ $ cd pry-send_tweet.rb
419
+ $ ruby vms/freebsd.rb
420
+
421
+ Screenshots __#1__, __#2__ in the [screenshots](#screenshots) section show the
422
+ type of experience to expect when running `ruby vms/freebsd.rb`.
423
+
424
+ A virtual machine can be destroyed and a new VM instance created by appending
425
+ the `--fresh` option:
426
+
427
+ $ ruby vms/freebsd.rb --fresh
428
+
429
+ The default time settings are set to CET (Central European Time). This can be
430
+ changed with an environment variable.
431
+
432
+ $ VMTZ=Asia/Tehran ruby vms/freebsd.rb
433
+
434
+ A complete list of time zones are available in the VM:
435
+
436
+ $ ls /usr/share/zoneinfo
437
+
438
+ ## <a id='install'>Install</a>
439
+
440
+ ### <a id='install-rubygem'>Rubygem</a>
441
+
442
+ $ gem install pry-send_tweet.rb
443
+
444
+ ## <a id='screenshots'>Screenshots</a>
445
+
446
+ __#1__ Running FreeBSD 12 with Vagrant, Tmux
447
+
448
+ ![FreeBSD-1](/art/44-e44743a5bb.jpg)
449
+
450
+ __#2__ Composing a tweet on FreeBSD 12 - with Vagrant, Tmux.
451
+
452
+ ![FreeBSD-2](/art/52-eec4df2edf.jpg)
453
+
454
+ ## <a id='license'>License</a>
455
+
456
+ This project uses the MIT license, see [LICENSE.txt](./LICENSE.txt) for details.