pry-send_tweet.rb 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -1
- data/README.md +141 -69
- data/Vagrantfile +27 -12
- data/art/44-e44743a5bb.jpg +0 -0
- data/art/52-eec4df2edf.jpg +0 -0
- data/lib/pry-send_tweet.rb +3 -1
- data/lib/pry/pager/system_pager.rb +25 -0
- data/lib/pry/send_tweet/commands/base_command.rb +5 -1
- data/lib/pry/send_tweet/commands/read_tweets.rb +5 -1
- data/lib/pry/send_tweet/commands/read_tweets/translate_actions.rb +65 -9
- data/lib/pry/send_tweet/commands/send_tweet.rb +2 -1
- data/lib/pry/send_tweet/commands/twitter_action.rb +2 -2
- data/lib/pry/send_tweet/commands/twitter_action/follow_actions.rb +13 -4
- data/lib/pry/send_tweet/commands/twitter_action/like_actions.rb +1 -1
- data/lib/pry/send_tweet/renderers/tweet_renderer.rb +23 -43
- data/lib/pry/send_tweet/renderers/user_renderer.rb +2 -1
- data/lib/pry/send_tweet/tty-box.rb +1 -2
- data/lib/pry/send_tweet/version.rb +1 -1
- data/lib/time-ago-in-words/lib/time-ago-in-words.rb +35 -0
- data/pry-send_tweet.gemspec +9 -4
- data/samples/freebsd-zshrc +5 -0
- data/samples/tmuxinator-vagrant.yml +4 -9
- data/vms/freebsd.rb +15 -0
- metadata +9 -35
- data/Dockerfile +0 -41
- data/Gemfile +0 -7
- data/dockerize.sh +0 -3
- data/samples/hardenedbsd-zshrc +0 -4
- data/samples/tmuxinator-docker.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 400374f90dfa63fbc17fb9f2b2676ad12c12d080da32d2cac65bd7a2494bcc5f
|
4
|
+
data.tar.gz: 1a436174c9e722ecaba2fe4536bc5cd49c9438e8c257e3165f55169ac83e3a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0571355b013a36706a43cb78b44ea3ae1ee328af23e0aba6697280556b522d57fd48fe51b553c07830b3d3228462842f548395d636e0393eeaec99ea16ae33ab
|
7
|
+
data.tar.gz: b8c588b3816953a0bdcd5a7b1de5de7165472f315e292d9c022f4a577d469a0f712130dfeb296c90c39712d977e53373cada99225584c8b1defa571f5620edaf
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,64 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v0.13.0
|
4
|
+
|
5
|
+
* Remove `Gemfile`, and the Bundler dependency.
|
6
|
+
|
7
|
+
* On the FreeBSD VM, runtime dependencies are installed as FreeBSD packages.
|
8
|
+
|
9
|
+
* Rethink fork + wait logic in `read-tweets`.
|
10
|
+
|
11
|
+
* Configure the default timezone on the FreeBSD VM to be CET (Central European Time).
|
12
|
+
This can be changed by `$VMTZ`. Please see the README for an example.
|
13
|
+
|
14
|
+
* `on-twitter --show-following` and `on-twitter --show-followers` accept an
|
15
|
+
optional regular expression that can filter through the result set.
|
16
|
+
|
17
|
+
* Implement `ruby vms/freebsd.rb --fresh`, for destroying an old VM and
|
18
|
+
spinning up a new one.
|
19
|
+
|
20
|
+
* Implement `time-ago-in-words` without patching the Time class.
|
21
|
+
|
22
|
+
* Remove `spec/`.
|
23
|
+
|
24
|
+
* Timestamps in the future or present are represented as '0 seconds' ago
|
25
|
+
in `lib/time-ago-in-words`.
|
26
|
+
|
27
|
+
* Replace 'time-lord' with 'time-ago-in-words'
|
28
|
+
|
29
|
+
* Print an error when unknown switches are passed to command
|
30
|
+
|
31
|
+
* Switch default editor to 'ee' on FreeBSD VM
|
32
|
+
|
33
|
+
* Add mitigation for RCE bug in apt-get to Dockerfile.
|
34
|
+
|
35
|
+
* `--delay`, and `--self-destruct` assume that a time such as 07:00, which
|
36
|
+
has past on the current day, was meant to mean 07:00, tomorrow.
|
37
|
+
|
38
|
+
* Install FreeBSD-12 with Vagrant due to unresolvable issues with the
|
39
|
+
HardenedBSD vagrant box.
|
40
|
+
|
41
|
+
* Replace `t.co` links with the expanded URL `t.co` redirects to.
|
42
|
+
|
43
|
+
* Collect status of system pager after sending `SIGKILL`.
|
44
|
+
|
45
|
+
* When translating text or a tweet, show the source and destination language.
|
46
|
+
|
47
|
+
* Add `read-tweets -sl=`, `read-tweets --source-lang=` for setting the source
|
48
|
+
language of the text or tweet being translated.
|
49
|
+
|
50
|
+
* Add `read-tweets -tx`, for translating a piece of text using the Yandex
|
51
|
+
translation API.
|
52
|
+
|
53
|
+
* Set CET (Central European Time) as the default timezone for the HardenedBSD VM.
|
54
|
+
|
55
|
+
* Implement a minimum box height of 8, but scale to a larger number if a tweet
|
56
|
+
or user bio is written using a lot of newlines.
|
57
|
+
|
58
|
+
* Remove the `config.box_height` option.
|
59
|
+
|
60
|
+
* Typo fix: rescue `Twitter::Error`, not `Timeout::Error`, when liking a tweet.
|
61
|
+
|
3
62
|
## v0.12.1
|
4
63
|
|
5
64
|
* Correct multiple grammar errors found in the help output of all commands.
|
@@ -13,7 +72,7 @@
|
|
13
72
|
|
14
73
|
## v0.11.0
|
15
74
|
|
16
|
-
* Apply a fix to tty-box for the `on-twitter --show-followers`, and
|
75
|
+
* Apply a fix to tty-box for the `on-twitter --show-followers`, and
|
17
76
|
`on-twitter --show-following` commands.
|
18
77
|
|
19
78
|
* Add unicode support by applying a fix - as a monkey patch - to the `tty-box`
|
data/README.md
CHANGED
@@ -19,8 +19,9 @@
|
|
19
19
|
* [Multi-tasking: tmux / screen](#multi-tasking)
|
20
20
|
* [Install](#install)
|
21
21
|
* [Rubygem](#install-rubygem)
|
22
|
-
* [
|
23
|
-
|
22
|
+
* [Virtual Machines](#vms)
|
23
|
+
* [FreeBSD](#vms-freebsd)
|
24
|
+
* [Screenshots](#screenshots)
|
24
25
|
* [License](#license)
|
25
26
|
|
26
27
|
## <a id='Introduction'>Introduction</a>
|
@@ -29,19 +30,16 @@ A Twitter client for the Pry REPL.
|
|
29
30
|
|
30
31
|
## <a id='api-access'>API Access</a>
|
31
32
|
|
32
|
-
Using the Twitter API requires a developer account.
|
33
|
-
Follow the instructions at
|
34
|
-
|
35
|
-
if you haven't already
|
36
|
-
setup access to the Twitter API.
|
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.
|
37
36
|
|
38
37
|
## <a id='configuration'>Configuration (required)</a>
|
39
38
|
|
40
|
-
The placeholder keys and tokens in the below example can be replaced
|
41
|
-
by those from your developer account.
|
42
|
-
|
43
|
-
pry-send_tweet.
|
44
|
-
through a YAML file located at `$HOME/.pry-send_tweet.yml`
|
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`
|
45
43
|
|
46
44
|
__1. Ruby__
|
47
45
|
|
@@ -59,10 +57,8 @@ Pry.configure do |config|
|
|
59
57
|
# Default is: 'pry-send_tweet.rb vX.Y.Z'.
|
60
58
|
user_agent: 'Custom User-Agent',
|
61
59
|
# Optional configuration
|
62
|
-
# The width
|
63
|
-
# The default width is 100 and the default height is 8.
|
60
|
+
# The width of a box that contains a tweet or user. The default width is 100.
|
64
61
|
box_width: 120,
|
65
|
-
box_height: 10,
|
66
62
|
# Optional configuration
|
67
63
|
# A Yandex API key for translating tweets when using `read-tweets -x`.
|
68
64
|
yandex_key: 'xxx',
|
@@ -85,7 +81,8 @@ access_token: '<access token>'
|
|
85
81
|
access_token_secret: '<access token secret>'
|
86
82
|
# Optional
|
87
83
|
user_agent: 'Your User-Agent string'
|
88
|
-
|
84
|
+
# Optional
|
85
|
+
box_width: 120
|
89
86
|
# Optional
|
90
87
|
yandex_key: xxx
|
91
88
|
yandex_lang: xx
|
@@ -95,17 +92,22 @@ yandex_lang: xx
|
|
95
92
|
|
96
93
|
There are four commands added to Pry by this plugin, those commands are:
|
97
94
|
|
98
|
-
* `send-tweet`
|
95
|
+
* `send-tweet`
|
99
96
|
For sending tweets.
|
100
97
|
|
101
|
-
* `read-tweets`
|
98
|
+
* `read-tweets`
|
102
99
|
For reading tweets.
|
103
100
|
|
104
|
-
* `twitter-action` (aliased as: `on-twitter`)
|
101
|
+
* `twitter-action` (aliased as: `on-twitter`)
|
105
102
|
For performing misc actions on Twitter, such as following, unfollowing, etc.
|
106
103
|
|
107
|
-
* `twitter-search`
|
108
|
-
For searching Twitter.
|
104
|
+
* `twitter-search`
|
105
|
+
For searching Twitter.
|
106
|
+
|
107
|
+
Each command provides help, that can be shown by appending `--help` to the
|
108
|
+
command. Example:
|
109
|
+
|
110
|
+
[1] pry(main)> send-tweet --help
|
109
111
|
|
110
112
|
### <a id='sending-tweets'>Sending tweets</a>
|
111
113
|
|
@@ -123,33 +125,36 @@ There are four commands added to Pry by this plugin, those commands are:
|
|
123
125
|
[1] pry(main)> send-tweet --file #{File.join ENV['HOME'], 'photos', 'image.jpg'}
|
124
126
|
|
125
127
|
|
128
|
+
* Send a tweet with multiple images attached:
|
129
|
+
|
130
|
+
[1] pry(main)> send-tweet --file #{%w[1.jpg 2.jpg 3.jpg].join(',')}
|
131
|
+
|
126
132
|
* Reply to a tweet:
|
127
133
|
|
128
134
|
[1] pry(main)> send-tweet --reply-to https://twitter.com/username/status/1
|
129
135
|
|
130
|
-
* Send a tweet that will self-destruct after 70 seconds.
|
136
|
+
* Send a tweet that will self-destruct after 70 seconds.
|
131
137
|
It's worth adding that if the Pry process exits this operation will be cancelled:
|
132
138
|
|
133
139
|
[1] pry(main)> send-tweet --self-destruct=70
|
134
140
|
|
135
|
-
* Send a tweet that will be published 70 seconds in the future.
|
136
|
-
It's worth adding that if the Pry process exits, this operation will be cancelled:
|
141
|
+
* Send a tweet that will be published 70 seconds in the future.
|
142
|
+
It's worth adding that if the Pry process exits, this operation will be cancelled:
|
137
143
|
|
138
144
|
[1] pry(main)> send-tweet --delay=70
|
139
145
|
|
140
|
-
* Delay sending a tweet until 12AM, today. `--self-destruct` also supports this
|
146
|
+
* Delay sending a tweet until 12AM, today. `--self-destruct` also supports this
|
141
147
|
syntax:
|
142
148
|
|
143
149
|
[1] pry(main)> send-tweet --delay=00:00
|
144
150
|
|
145
151
|
### <a id='reading-tweets'>Reading tweets</a>
|
146
152
|
|
147
|
-
By default the tweets displayed by the `read-tweets` command are automatically
|
153
|
+
By default the tweets displayed by the `read-tweets` command are automatically
|
148
154
|
refreshed every 5 minutes.
|
149
155
|
|
150
|
-
That can be changed to a custom interval by setting `Pry.config.twitter.refresh_interval`
|
151
|
-
to a number of seconds, or to `false` if you want to disable this
|
152
|
-
feature.
|
156
|
+
That can be changed to a custom interval by setting `Pry.config.twitter.refresh_interval`
|
157
|
+
to a number of seconds, or to `false` if you want to disable this feature.
|
153
158
|
|
154
159
|
* Read recent tweets from your timeline:
|
155
160
|
|
@@ -176,18 +181,31 @@ feature.
|
|
176
181
|
[1] pry(main)> read-tweets --replies github
|
177
182
|
|
178
183
|
* Read a translated copy of a tweet, using the
|
179
|
-
[Yandex translation API](https://translate.yandex.com/developers).
|
184
|
+
[Yandex translation API](https://translate.yandex.com/developers).
|
180
185
|
The configuration instructions for Yandex are included in the [configuration section](#configuration).
|
181
186
|
|
182
|
-
[1] pry(main) read-tweets -x https://twitter.com/user/status/1
|
187
|
+
[1] pry(main)> read-tweets -x https://twitter.com/user/status/1
|
183
188
|
|
184
|
-
* Read
|
189
|
+
* Read a translated copy of a piece of text:
|
190
|
+
|
191
|
+
[1] pry(main)> read-tweets -tx='#{File.binread "persian.txt"}'
|
192
|
+
[2] pry(main)> read-tweets -tx='Guten Tag'
|
193
|
+
[3] pry(main)> read-tweets -tx='Hola'
|
194
|
+
|
195
|
+
* Sometimes Yandex cannot detect the language of the text or tweet being
|
196
|
+
translated, or it will guess the source language incorrectly. In case
|
197
|
+
this happens, the source language can be set explicitly:
|
198
|
+
|
199
|
+
[1] pry(main)> read-tweets --source-lang=fa -x https://url/to/farsi/tweet
|
200
|
+
[1] pry(main)> read-tweets --source-lang=sw -tx='Habari yako'
|
201
|
+
|
202
|
+
* Read 100 recent tweets instead of the default 200 recent tweets.
|
185
203
|
**Tip:** `--count` can be combined with all of the options described above.
|
186
204
|
|
187
205
|
[1] pry(main)> read-tweets --count 100
|
188
206
|
|
189
|
-
* By default retweets are not displayed.
|
190
|
-
To display retweets, pass the `--with-retweets` option.
|
207
|
+
* By default retweets are not displayed.
|
208
|
+
To display retweets, pass the `--with-retweets` option.
|
191
209
|
|
192
210
|
[1] pry(main)> read-tweets --with-retweets
|
193
211
|
|
@@ -225,6 +243,15 @@ feature.
|
|
225
243
|
|
226
244
|
[1] pry(main)> on-twitter --show-followers
|
227
245
|
|
246
|
+
* Show the tweeters who you follow:
|
247
|
+
|
248
|
+
[1] pry(main)> on-twitter --show-following
|
249
|
+
|
250
|
+
* Both `--show-following` and `--show-followers` accept an optional argument
|
251
|
+
that can be used to filter the result set.
|
252
|
+
|
253
|
+
[1] pry(main)> on-twitter --show-following=[0-9]$
|
254
|
+
|
228
255
|
### <a id='searching-twitter'>Searching Twitter</a>
|
229
256
|
|
230
257
|
The `twitter-search` command can be used to search Twitter.
|
@@ -251,13 +278,13 @@ The `twitter-search` command can be used to search Twitter.
|
|
251
278
|
# Your profiles bio will be updated after closing the editor.
|
252
279
|
[1] pry(main)> on-twitter --set-profile-bio
|
253
280
|
|
254
|
-
* Set the location visible on your profile:
|
281
|
+
* Set the location visible on your profile:
|
255
282
|
|
256
283
|
# An editor opens (`_pry_.editor`), write your location then hit save &
|
257
284
|
# close. Your profiles location will be updated after closing the editor.
|
258
285
|
[1] pry(main)> on-twitter --set-profile-bio
|
259
286
|
|
260
|
-
* Set the color (as a hex value) of links that appear on your profiles timeline:
|
287
|
+
* Set the color (as a hex value) of links that appear on your profiles timeline:
|
261
288
|
|
262
289
|
[1] pry(main)> on-twitter --set-profile-link-color=#CC0000
|
263
290
|
|
@@ -280,7 +307,7 @@ The `twitter-search` command can be used to search Twitter.
|
|
280
307
|
|
281
308
|
[1] pry(main)> on-twitter --suggested-lang=es --suggested-topics
|
282
309
|
|
283
|
-
* View a list of suggested users from a given topic, optionally restricted to
|
310
|
+
* View a list of suggested users from a given topic, optionally restricted to
|
284
311
|
Spanish:
|
285
312
|
|
286
313
|
[1] pry(main)> on-twitter --suggested-lang=es --suggested-users=<topic>
|
@@ -299,11 +326,10 @@ The `twitter-search` command can be used to search Twitter.
|
|
299
326
|
|
300
327
|
### <a id='special-variable-_twitter_'>Sticky local variable: `_twitter_`</a>
|
301
328
|
|
302
|
-
The local variable `_twitter_` is inserted into the active Binding, providing
|
303
|
-
a programmable API accessible to Ruby code as well as a lower level of access to
|
304
|
-
the Twitter API. It is meant for exploration, development, and debugging.
|
305
|
-
variable is considered reserved
|
306
|
-
in the same Binding, expect unusual behaviour.
|
329
|
+
The local variable `_twitter_` is inserted into the active Binding, providing
|
330
|
+
a programmable API accessible to Ruby code as well as a lower level of access to
|
331
|
+
the Twitter API. It is meant for exploration, development, and debugging.
|
332
|
+
The local variable is considered reserved.
|
307
333
|
|
308
334
|
The local variable returns an instance of `Twitter::REST::Client`:
|
309
335
|
|
@@ -317,8 +343,8 @@ The local variable returns an instance of `Twitter::REST::Client`:
|
|
317
343
|
|
318
344
|
### <a id='tip'>Tip: Command Aliases</a>
|
319
345
|
|
320
|
-
When there are Twitter accounts you read often, it can turn out to be faster
|
321
|
-
to create command aliases for reading those accounts. An example follows, a
|
346
|
+
When there are Twitter accounts you read often, it can turn out to be faster
|
347
|
+
to create command aliases for reading those accounts. An example follows, a
|
322
348
|
hyphen is included in the aliased commands to avoid collisions with Ruby code.
|
323
349
|
|
324
350
|
```ruby
|
@@ -329,47 +355,93 @@ Pry.commands.alias_command "prez-obama", "read-tweets -t barackobama"
|
|
329
355
|
|
330
356
|
## <a id='multi-tasking'>Multi-tasking: tmux / screen</a>
|
331
357
|
|
332
|
-
To get the most out of `pry-send_tweet.rb` I use tmux to manage a pane for reading
|
333
|
-
tweets and another for writing tweets. I've found this to be the best way since
|
358
|
+
To get the most out of `pry-send_tweet.rb` I use tmux to manage a pane for reading
|
359
|
+
tweets and another for writing tweets. I've found this to be the best way since
|
334
360
|
a single shell does not allow for multi tasking but tmux and screen do.
|
335
361
|
|
336
|
-
I use
|
337
|
-
|
338
|
-
|
339
|
-
The tmuxinator configurations I use for Docker / Vagrant are checked into the
|
340
|
-
repo to use yourself or to act as inspiration for your own configuration:
|
362
|
+
I use [tmuxinator](https://github.com/tmuxinator/tmuxinator) to manage my tmux
|
363
|
+
sessions. The tmuxinator configuration I use is checked into the repo in the
|
364
|
+
hope that it might be useful to others.
|
341
365
|
|
342
|
-
* [
|
343
|
-
* [Vagrant (HardenedBSD)](./samples/tmuxinator-vagrant.yml)
|
366
|
+
* [tmuxinator-vagrant.yml](./samples/tmuxinator-vagrant.yml)
|
344
367
|
|
368
|
+
## <a id='vms'>Virtual Machines</a>
|
345
369
|
|
346
|
-
|
370
|
+
Before getting started with a Virtual Machine, download and install the
|
371
|
+
following tools if you didn't already, they're free:
|
347
372
|
|
348
|
-
|
373
|
+
* VirtualBox
|
374
|
+
* Vagrant
|
349
375
|
|
350
|
-
|
376
|
+
Next, configure access to the Twitter API by adding `.pryrc` file to the root of
|
377
|
+
the repository. That's covered in the [configuration](#configuration) section.
|
351
378
|
|
352
|
-
###
|
379
|
+
### Shared space
|
353
380
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
performing tasks that use an editor:
|
381
|
+
While exploring, developing or tweeting on one of the available VMs sometimes
|
382
|
+
you want to bring files from the 'host' machine to the virtual machine, which
|
383
|
+
is known as the guest machine.
|
358
384
|
|
359
|
-
|
360
|
-
|
361
|
-
|
385
|
+
__Syncing files__
|
386
|
+
|
387
|
+
`vagrant rsync-auto` can see edits made to the cloned repo on the host
|
388
|
+
machine and sync those changes back to the guest machine. To set this up, from
|
389
|
+
the root of the repo on the host machine run:
|
390
|
+
|
391
|
+
$ vagrant rsync-auto
|
362
392
|
|
363
|
-
|
393
|
+
__Tweeting media__
|
364
394
|
|
365
|
-
|
366
|
-
|
395
|
+
To tweet media such as an image or video from the VM, what I do is drop those
|
396
|
+
files into `/app/shared-space` and then reference `/app/shared-space` when
|
397
|
+
sharing them, eg `send-tweet -f /app/shared-space/photo.jpg`.
|
398
|
+
|
399
|
+
### <a id='vms-freebsd'>FreeBSD</a>
|
400
|
+
|
401
|
+
[FreeBSD 12](https://freebsd.org) Virtual Machine
|
402
|
+
|
403
|
+
Vagrant will use Amazon to download the box image. Sometimes the download can be
|
404
|
+
slow, sometimes the download can stall..
|
405
|
+
|
406
|
+
Keep trying if this happens, a download should always resume from the point
|
407
|
+
where it finished. FreeBSD is worth the perseverance. :)
|
367
408
|
|
368
409
|
$ git clone https://github.com/r-obert/pry-send_tweet.rb
|
369
410
|
$ cd pry-send_tweet.rb
|
370
|
-
$
|
371
|
-
|
411
|
+
$ ruby vms/freebsd.rb
|
412
|
+
|
413
|
+
Screenshots __#1__, __#2__ in the [screenshots](#screenshots) section show the
|
414
|
+
type of experience to expect when running `ruby vms/freebsd.rb`.
|
415
|
+
|
416
|
+
A virtual machine can be destroyed and a new VM instance created by appending
|
417
|
+
the `--fresh` option:
|
418
|
+
|
419
|
+
$ ruby vms/freebsd.rb --fresh
|
420
|
+
|
421
|
+
The default time settings are set to CET (Central European Time). This can be
|
422
|
+
changed with an environment variable.
|
423
|
+
|
424
|
+
$ VMTZ=Asia/Tehran ruby vms/freebsd.rb
|
425
|
+
|
426
|
+
A complete list of time zones are available in the VM:
|
427
|
+
|
428
|
+
$ ls /usr/share/zoneinfo
|
429
|
+
|
430
|
+
## <a id='install'>Install</a>
|
431
|
+
|
432
|
+
### <a id='install-rubygem'>Rubygem</a>
|
433
|
+
|
434
|
+
$ gem install pry-send_tweet.rb
|
435
|
+
|
436
|
+
## <a id='screenshots'>Screenshots</a>
|
437
|
+
|
438
|
+
__#1__ Running FreeBSD 12 with Vagrant, Tmux
|
439
|
+
|
440
|
+
![FreeBSD-1](/art/44-e44743a5bb.jpg)
|
441
|
+
|
442
|
+
__#2__ Composing a tweet on FreeBSD 12 - with Vagrant, Tmux.
|
372
443
|
|
444
|
+
![FreeBSD-2](/art/52-eec4df2edf.jpg)
|
373
445
|
|
374
446
|
## <a id='license'>License</a>
|
375
447
|
|
data/Vagrantfile
CHANGED
@@ -1,31 +1,46 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
insert_root_path = ->(tmux_conf) {
|
3
|
+
conf = YAML.load(tmux_conf)
|
4
|
+
conf['root'] = '/app'
|
5
|
+
YAML.dump(conf)
|
6
|
+
}
|
7
|
+
|
1
8
|
Vagrant.configure("2") do |config|
|
2
|
-
config.vm.box = "
|
9
|
+
config.vm.box = "generic/freebsd12"
|
3
10
|
config.vm.synced_folder Dir.getwd, "/app", type: "rsync"
|
4
11
|
|
5
12
|
config.vm.provider "virtualbox" do |vb|
|
6
13
|
vb.memory = "1024"
|
7
14
|
end
|
8
15
|
|
16
|
+
# Install useful packages
|
9
17
|
cmds = [
|
10
|
-
"sudo
|
11
|
-
"sudo
|
12
|
-
"sudo chsh -s zsh vagrant",
|
13
|
-
"echo '#{File.binread('./samples/hardenedbsd-zshrc')}' > /home/vagrant/.zshrc"
|
18
|
+
"sudo pkg install -y zsh tmux",
|
19
|
+
"sudo chsh -s zsh vagrant"
|
14
20
|
]
|
15
21
|
config.vm.provision "shell", inline: cmds.join(' && ')
|
16
22
|
|
17
|
-
#
|
23
|
+
# Configure date & time
|
24
|
+
zone = ENV.key?('VMTZ') ? ENV['VMTZ'] : 'CET'
|
18
25
|
cmds = [
|
19
|
-
"
|
20
|
-
"sudo ASSUME_ALWAYS_YES=true pkg install devel/ruby-gems",
|
21
|
-
"sudo ASSUME_ALWAYS_YES=true pkg install rubygem-bundler"
|
26
|
+
"cp /usr/share/zoneinfo/#{zone} /etc/localtime"
|
22
27
|
]
|
23
28
|
config.vm.provision "shell", inline: cmds.join(' && ')
|
24
29
|
|
25
|
-
#
|
30
|
+
# Insert files into VM
|
31
|
+
tmux_conf = insert_root_path.call File.binread('./samples/tmuxinator-vagrant.yml')
|
32
|
+
cmds = [
|
33
|
+
"echo '#{File.binread('./samples/freebsd-zshrc')}' > /home/vagrant/.zshrc",
|
34
|
+
"mkdir -p /home/vagrant/.config/tmuxinator",
|
35
|
+
"echo #{Shellwords.shellescape(tmux_conf)} > /home/vagrant/.config/tmuxinator/pry_send_tweet.yml"
|
36
|
+
]
|
37
|
+
config.vm.provision "shell", inline: cmds.join(' && ')
|
38
|
+
|
39
|
+
# Install Ruby
|
40
|
+
# Install pry-send_tweet dependencies (..as FreeBSD packages)
|
26
41
|
cmds = [
|
27
|
-
"
|
28
|
-
"
|
42
|
+
"sudo pkg install -y ruby rubygem-tmuxinator rubygem-pry rubygem-twitter " \
|
43
|
+
"rubygem-tty-box rubygem-unicode-display_width"
|
29
44
|
]
|
30
45
|
config.vm.provision "shell", inline: cmds.join(' && ')
|
31
46
|
end
|
Binary file
|
Binary file
|
data/lib/pry-send_tweet.rb
CHANGED
@@ -27,7 +27,8 @@ class Pry
|
|
27
27
|
require 'cgi'
|
28
28
|
require 'timeout'
|
29
29
|
require 'yaml'
|
30
|
-
require 'time-
|
30
|
+
require 'time-ago-in-words'
|
31
|
+
require_relative 'pry/pager/system_pager'
|
31
32
|
require_relative 'pry/send_tweet/tty-box'
|
32
33
|
require_relative 'pry/send_tweet/renderers/tweet_renderer'
|
33
34
|
require_relative 'pry/send_tweet/renderers/user_renderer'
|
@@ -37,6 +38,7 @@ class Pry
|
|
37
38
|
require_relative 'pry/send_tweet/commands/read_tweets'
|
38
39
|
require_relative 'pry/send_tweet/commands/twitter_search'
|
39
40
|
require_relative 'pry/send_tweet/commands/twitter_action'
|
41
|
+
require_relative 'pry/send_tweet/version'
|
40
42
|
|
41
43
|
# @api private
|
42
44
|
def self.merge_yaml_file!(config, path)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Pry::Pager::SystemPager
|
2
|
+
def pid
|
3
|
+
pager.pid
|
4
|
+
end
|
5
|
+
|
6
|
+
def fork
|
7
|
+
pager
|
8
|
+
nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def fast_exit!
|
12
|
+
Process.kill 'SIGKILL', pid
|
13
|
+
Process.wait pid
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
# Patch to avoid spawning a shell when launching the pager.
|
18
|
+
def pager
|
19
|
+
@pager ||= begin
|
20
|
+
ary = self.class.default_pager.split(' ')
|
21
|
+
io = IO.popen(ary, 'w')
|
22
|
+
io.tap{|io| io.sync = true}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
class Pry::Slop
|
2
|
+
DEFAULT_OPTIONS.merge!(strict: true)
|
3
|
+
end
|
4
|
+
|
1
5
|
class Pry::SendTweet::BaseCommand < Pry::ClassCommand
|
2
6
|
include Pry::SendTweet::TweetRenderer
|
3
7
|
include Pry::SendTweet::UserRenderer
|
@@ -19,7 +23,7 @@ class Pry::SendTweet::BaseCommand < Pry::ClassCommand
|
|
19
23
|
private
|
20
24
|
|
21
25
|
def box_height
|
22
|
-
|
26
|
+
Pry::SendTweet::DEFAULT_BOX_HEIGHT
|
23
27
|
end
|
24
28
|
|
25
29
|
def box_width
|
@@ -22,13 +22,17 @@ class Pry::SendTweet::ReadTweets < Pry::SendTweet::BaseCommand
|
|
22
22
|
o.on 'r=', 'replies=', 'A username whose replies you want to read.'
|
23
23
|
o.on 'm', 'mentions', 'Read tweets that @mention you.'
|
24
24
|
o.on 'x=', 'translate=', 'Translate a tweet.'
|
25
|
+
o.on 'tx=', nil, 'Translate a string of text.'
|
26
|
+
o.on 'sl=', 'source-lang=', '[optional] The source language of the ' \
|
27
|
+
'text or tweet being translated'
|
25
28
|
o.on 'w', 'with-retweets', 'Include retweets.'
|
26
29
|
end
|
27
30
|
|
28
31
|
def process
|
29
32
|
super
|
30
33
|
case
|
31
|
-
when opts.present?('translate') then translate_tweet(opts['
|
34
|
+
when opts.present?('translate') then translate_tweet(opts['x'], opts['sl'])
|
35
|
+
when opts.present?('tx') then translate_text(opts['tx'], opts['sl'])
|
32
36
|
when opts.present?('replies') then show_replies(user: opts['replies'])
|
33
37
|
when opts.present?('likes') then show_likes(user: opts['likes'])
|
34
38
|
when opts.present?('mentions') then show_mentions
|
@@ -2,14 +2,47 @@ module Pry::SendTweet::ReadTweets::TranslateActions
|
|
2
2
|
YANDEX_ENDPOINT = "https://translate.yandex.net/api/v1.5/tr.json/translate?" \
|
3
3
|
"key=%{key}&text=%{text}&lang=%{lang}"
|
4
4
|
|
5
|
-
|
5
|
+
LANGUAGE_STRINGS = {
|
6
|
+
'ar' => 'Arabic (العربية)',
|
7
|
+
'en' => 'English',
|
8
|
+
'de' => 'German (Deutsch)',
|
9
|
+
'pt' => 'Portuguese (Portuguesa)',
|
10
|
+
'fa' => 'Farsi (دریافت)',
|
11
|
+
'ja' => 'Japanese (日本語)',
|
12
|
+
'he' => 'Hebrew (עברית)',
|
13
|
+
'ga' => 'Irish (Gaeilge)',
|
14
|
+
'es' => 'Spanish (Español)',
|
15
|
+
'it' => 'Italinao (italiano)',
|
16
|
+
'nl' => 'Dutch (Nederlands)',
|
17
|
+
'ru' => 'Russian (русский)',
|
18
|
+
'uk' => 'Ukranian (країнська)',
|
19
|
+
'ko' => 'Korean (한국어)',
|
20
|
+
'fr' => 'French (Français)',
|
21
|
+
'da' => 'Danish (dansk)',
|
22
|
+
'yi' => 'Yiddish (ייִדיש)',
|
23
|
+
'sw' => 'Swahili'
|
24
|
+
}
|
25
|
+
|
26
|
+
def translate_tweet(tweet_url, source_language)
|
6
27
|
tweet = twitter.status(tweet_url)
|
7
|
-
uri_endpoint = __build_yandex_endpoint(tweet)
|
28
|
+
uri_endpoint = __build_yandex_endpoint(tweet, source_language)
|
29
|
+
res = Net::HTTP.get_response(uri_endpoint)
|
30
|
+
case res
|
31
|
+
when Net::HTTPOK
|
32
|
+
tweet.attrs[:full_text] = __translated_text_from(res)
|
33
|
+
render_tweets [tweet], title: "#{__translation_map(res)}: "
|
34
|
+
else
|
35
|
+
raise Pry::CommandError, "Bad response from Yandex (#{res.class})"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def translate_text(text, source_language)
|
40
|
+
uri_endpoint = __build_yandex_endpoint(text, source_language)
|
8
41
|
res = Net::HTTP.get_response(uri_endpoint)
|
9
42
|
case res
|
10
43
|
when Net::HTTPOK
|
11
|
-
|
12
|
-
|
44
|
+
_pry_.output.puts "#{__translation_map(res)}: \n" \
|
45
|
+
"#{__translated_text_from(res)}"
|
13
46
|
else
|
14
47
|
raise Pry::CommandError, "Bad response from Yandex (#{res.class})"
|
15
48
|
end
|
@@ -18,14 +51,37 @@ module Pry::SendTweet::ReadTweets::TranslateActions
|
|
18
51
|
private
|
19
52
|
|
20
53
|
# @api private
|
21
|
-
def
|
54
|
+
def __translation_map(res)
|
55
|
+
b = JSON.parse(res.body)
|
56
|
+
from, to = b['lang'].split('-')
|
57
|
+
from = LANGUAGE_STRINGS[from] || from
|
58
|
+
to = LANGUAGE_STRINGS[to] || to
|
59
|
+
"#{from} => #{to}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# @api private
|
63
|
+
def __translated_text_from(res)
|
64
|
+
JSON.parse(res.body)["text"][0]
|
65
|
+
end
|
66
|
+
|
67
|
+
# @api private
|
68
|
+
def __build_yandex_endpoint(tweet, source_language)
|
22
69
|
URI.parse format(YANDEX_ENDPOINT,
|
23
|
-
lang:
|
24
|
-
key: __yandex_key,
|
25
|
-
text: URI.encode_www_form_component(
|
70
|
+
lang: URI.encode_www_form_component(__yandex_lang_param(source_language)),
|
71
|
+
key: URI.encode_www_form_component(__yandex_key),
|
72
|
+
text: URI.encode_www_form_component(
|
73
|
+
Twitter::Tweet === tweet ? __read_tweet_body(tweet) : tweet
|
74
|
+
)
|
26
75
|
)
|
27
76
|
end
|
28
77
|
|
78
|
+
# @api private
|
79
|
+
def __yandex_lang_param(source_language)
|
80
|
+
from = source_language ? "#{source_language}-" : ""
|
81
|
+
to = _pry_.config.twitter.yandex_lang || "en"
|
82
|
+
from + to
|
83
|
+
end
|
84
|
+
|
29
85
|
# @api private
|
30
86
|
def __yandex_key
|
31
87
|
k = _pry_.config.twitter.yandex_key
|
@@ -33,6 +89,6 @@ module Pry::SendTweet::ReadTweets::TranslateActions
|
|
33
89
|
raise Pry::CommandError,
|
34
90
|
"fatal: _pry_.config.twitter.yandex_key is nil, false or empty"
|
35
91
|
end
|
36
|
-
|
92
|
+
k
|
37
93
|
end
|
38
94
|
end
|
@@ -127,9 +127,10 @@ class Pry::SendTweet::SendTweet < Pry::SendTweet::BaseCommand
|
|
127
127
|
sleep_seconds = Integer(str)
|
128
128
|
elsif str =~ /\A\d{2}:\d{2}\z/ || str =~ /\A\d{2}:\d{2}:\d{2}\z/
|
129
129
|
time_obj = Time.parse(str)
|
130
|
+
time_obj += 3600*24 if time_obj <= Time.now
|
130
131
|
sleep_seconds = Integer(time_obj - Time.now)
|
131
132
|
else
|
132
|
-
raise Pry::CommandError, "
|
133
|
+
raise Pry::CommandError, "--delay='#{str}' or --self-destruct='#{str}' is not " \
|
133
134
|
"something I understand."
|
134
135
|
end
|
135
136
|
[time_obj, sleep_seconds]
|
@@ -91,8 +91,8 @@ class Pry::SendTweet::TwitterAction < Pry::SendTweet::BaseCommand
|
|
91
91
|
when opts.present?('suggested-users') then suggested_users(opts['suggested-users'])
|
92
92
|
when opts.present?('mute-user') then mute_user(opts['mute-user'])
|
93
93
|
when opts.present?('unmute-user') then unmute_user(opts['unmute-user'])
|
94
|
-
when opts.present?('show-followers') then show_followers
|
95
|
-
when opts.present?('show-following') then show_following
|
94
|
+
when opts.present?('show-followers') then show_followers(opts['show-followers'])
|
95
|
+
when opts.present?('show-following') then show_following(opts['show-following'])
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -23,8 +23,9 @@ module Pry::SendTweet::TwitterAction::FollowActions
|
|
23
23
|
page_error(e)
|
24
24
|
end
|
25
25
|
|
26
|
-
def show_followers
|
27
|
-
followers = twitter.followers(follow_request_options)
|
26
|
+
def show_followers(pattern)
|
27
|
+
followers = Array twitter.followers(follow_request_options)
|
28
|
+
__follow_filter!(followers, pattern) if pattern
|
28
29
|
page numbered_list("Followers", followers) {|follower, index|
|
29
30
|
render_user(follower)
|
30
31
|
}
|
@@ -32,8 +33,9 @@ module Pry::SendTweet::TwitterAction::FollowActions
|
|
32
33
|
page_error(e)
|
33
34
|
end
|
34
35
|
|
35
|
-
def show_following
|
36
|
-
followings = twitter.following(follow_request_options)
|
36
|
+
def show_following(pattern)
|
37
|
+
followings = Array twitter.following(follow_request_options)
|
38
|
+
__follow_filter!(followings, pattern) if pattern
|
37
39
|
page numbered_list("Following", followings) {|following, index|
|
38
40
|
render_user(following)
|
39
41
|
}
|
@@ -43,6 +45,13 @@ module Pry::SendTweet::TwitterAction::FollowActions
|
|
43
45
|
|
44
46
|
private
|
45
47
|
|
48
|
+
# @api private
|
49
|
+
def __follow_filter!(users, pattern)
|
50
|
+
users.select! do |u|
|
51
|
+
u.screen_name =~ /#{pattern}/
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
46
55
|
# @api private
|
47
56
|
def follow_request_options
|
48
57
|
{skip_status: true, include_user_entities: true}
|
@@ -1,35 +1,27 @@
|
|
1
1
|
module Pry::SendTweet::TweetRenderer
|
2
2
|
include Timeout
|
3
|
+
include TimeAgoInWords
|
3
4
|
|
4
5
|
def render_tweets(tweet_fetcher, title: nil, timeout: _pry_.config.twitter.refresh_interval)
|
5
|
-
|
6
|
-
|
6
|
+
pager = Pry::Pager::SystemPager.new(_pry_.output).tap(&:fork)
|
7
|
+
interval = __choose_render_interval(timeout)
|
8
|
+
timeout(interval) do
|
7
9
|
tweets = __fetch_tweets(tweet_fetcher)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
rescue Interrupt
|
12
|
-
|
10
|
+
tweets.empty? ? pager.write("No tweets to show.") :
|
11
|
+
pager.write(__render_tweets(title || "Twitter", tweets))
|
12
|
+
end
|
13
|
+
rescue Pry::Pager::StopPaging, Interrupt
|
14
|
+
pager.fast_exit!
|
13
15
|
system 'reset'
|
14
16
|
rescue Timeout::Error
|
15
|
-
|
17
|
+
pager.fast_exit!
|
16
18
|
system 'reset'
|
17
19
|
retry
|
20
|
+
ensure
|
21
|
+
pager.close
|
18
22
|
end
|
19
23
|
|
20
24
|
private
|
21
|
-
# @api private
|
22
|
-
def __fork_pager(title, tweets)
|
23
|
-
Kernel.fork do
|
24
|
-
_pry_.pager.open do |pager|
|
25
|
-
__trap_signal_in_fork(pager)
|
26
|
-
tweets.empty? ? pager.write("No tweets to show.") :
|
27
|
-
pager.write(__render_tweets(title || "Twitter", tweets))
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
25
|
# @api private
|
34
26
|
def __render_tweets(title, tweets)
|
35
27
|
title = bright_blue(bold((" " * 40) + title) + "\n\n")
|
@@ -39,11 +31,11 @@ module Pry::SendTweet::TweetRenderer
|
|
39
31
|
# @api private
|
40
32
|
def __render_tweet(tweet)
|
41
33
|
contents = __read_tweet_body(tweet)
|
42
|
-
|
34
|
+
body = "#{tweet.url}\n--\n#{contents}\n"
|
35
|
+
height = body.lines.count > box_height ? body.lines.count : box_height
|
36
|
+
TTY::Box.frame(height: height,
|
43
37
|
width: box_width,
|
44
|
-
title: {top_left: __render_tweet_title(tweet)})
|
45
|
-
"#{tweet.url}\n--\n#{contents}\n"
|
46
|
-
end.to_s
|
38
|
+
title: {top_left: __render_tweet_title(tweet)}) {body}.to_s
|
47
39
|
end
|
48
40
|
|
49
41
|
# @api private
|
@@ -51,7 +43,7 @@ module Pry::SendTweet::TweetRenderer
|
|
51
43
|
user, created_at = tweet.user, tweet.created_at.getlocal
|
52
44
|
title = [
|
53
45
|
bold("@#{user.screen_name}"),
|
54
|
-
created_at
|
46
|
+
time_ago_in_words(created_at),
|
55
47
|
created_at.strftime(time_format)
|
56
48
|
].join bright_blue(" | ")
|
57
49
|
" #{title} "
|
@@ -59,8 +51,14 @@ module Pry::SendTweet::TweetRenderer
|
|
59
51
|
|
60
52
|
# @api private
|
61
53
|
def __read_tweet_body(tweet)
|
54
|
+
uris = tweet.uris
|
62
55
|
text = tweet.attrs[:full_text] ? tweet.attrs[:full_text] :
|
63
56
|
tweet.full_text
|
57
|
+
# 'text' might be a frozen string
|
58
|
+
text = text.dup
|
59
|
+
uris.each do |uri|
|
60
|
+
text.gsub!(uri.attrs[:url], uri.attrs[:expanded_url])
|
61
|
+
end
|
64
62
|
CGI.unescapeHTML(text).strip
|
65
63
|
end
|
66
64
|
|
@@ -82,22 +80,4 @@ module Pry::SendTweet::TweetRenderer
|
|
82
80
|
timeout || (60*5)
|
83
81
|
end
|
84
82
|
end
|
85
|
-
|
86
|
-
# @api private
|
87
|
-
def __kill_pager!(pid)
|
88
|
-
Process.kill('SIGINT', pid)
|
89
|
-
Process.wait(pid) rescue nil
|
90
|
-
end
|
91
|
-
|
92
|
-
# @api private
|
93
|
-
def __trap_signal_in_fork(pager)
|
94
|
-
trap('SIGINT') {
|
95
|
-
if Pry::Pager::SystemPager === pager
|
96
|
-
syspager = pager.send(:pager)
|
97
|
-
pid = syspager.pid
|
98
|
-
Process.kill('SIGKILL', pid) rescue nil
|
99
|
-
end
|
100
|
-
Process.kill('SIGKILL', Process.pid)
|
101
|
-
}
|
102
|
-
end
|
103
83
|
end
|
@@ -7,8 +7,9 @@ module Pry::SendTweet::UserRenderer
|
|
7
7
|
#{bold("Following")} #{user.friends_count}
|
8
8
|
#{user.description}
|
9
9
|
USER
|
10
|
+
height = body.lines.count > box_height ? body.lines.count : box_height
|
10
11
|
TTY::Box.frame(
|
11
|
-
height:
|
12
|
+
height: height,
|
12
13
|
width: box_width,
|
13
14
|
title: {top_left: title}
|
14
15
|
) { body }.to_s
|
@@ -5,7 +5,6 @@
|
|
5
5
|
module Pry::SendTweet::TTYPatch
|
6
6
|
require 'tty-box'
|
7
7
|
require 'unicode/display_width'
|
8
|
-
require 'unicode/emoji'
|
9
8
|
# Create a frame
|
10
9
|
#
|
11
10
|
# @api public
|
@@ -44,7 +43,7 @@ module Pry::SendTweet::TTYPatch
|
|
44
43
|
unless content[i].nil?
|
45
44
|
output << bg.(fg.(content[i]))
|
46
45
|
plain_content = Pry::Helpers::Text.strip_color(content[i])
|
47
|
-
content_size -= Unicode::DisplayWidth.of(plain_content, 1, {}
|
46
|
+
content_size -= Unicode::DisplayWidth.of(plain_content, 1, {})
|
48
47
|
end
|
49
48
|
if style[:fg] || style[:bg] || !position # something to color
|
50
49
|
output << bg.(fg.(' ' * content_size))
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module TimeAgoInWords
|
2
|
+
require 'time'
|
3
|
+
VERSION = "0.0.5"
|
4
|
+
|
5
|
+
module Units
|
6
|
+
Second = 1
|
7
|
+
Minute = Second * 60
|
8
|
+
Hour = Minute * 60
|
9
|
+
Day = Hour * 24
|
10
|
+
Week = Day * 7
|
11
|
+
Month = Week * 4
|
12
|
+
Year = Day * 365
|
13
|
+
Decade = Year * 10
|
14
|
+
Century = Decade * 10
|
15
|
+
Millennium = Century * 10
|
16
|
+
Eon = 1.0/0
|
17
|
+
end
|
18
|
+
|
19
|
+
module_function
|
20
|
+
def time_ago_in_words(time)
|
21
|
+
time_difference = Time.now.to_i - time.to_i
|
22
|
+
return "0 seconds ago" if time_difference <= 0
|
23
|
+
unit = get_unit(time_difference)
|
24
|
+
unit_rep = time_difference > 1 ? "#{unit.to_s.downcase}s" : unit.to_s.downcase
|
25
|
+
unit_difference = time_difference / Units.const_get(unit.capitalize)
|
26
|
+
"#{unit_difference} #{unit_rep} ago"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def get_unit(time_difference)
|
31
|
+
Units.constants.each_cons(2) do |con|
|
32
|
+
return con.first if (Units.const_get(con[0])...Units.const_get(con[1])) === time_difference
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/pry-send_tweet.gemspec
CHANGED
@@ -8,12 +8,17 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.description = spec.summary
|
9
9
|
spec.homepage = "https://github.com/r-obert/pry-send_tweet.rb"
|
10
10
|
spec.licenses = ["MIT"]
|
11
|
-
spec.require_paths = ["lib"]
|
12
|
-
spec.files = Dir[
|
11
|
+
spec.require_paths = ["lib", "lib/time-ago-in-words/lib"]
|
12
|
+
spec.files = Dir[
|
13
|
+
"*file",
|
14
|
+
"art/*",
|
15
|
+
"vms/*",
|
16
|
+
"samples/*",
|
17
|
+
"*.{txt,gemspec,md,sh}",
|
18
|
+
"lib/**/*.rb"
|
19
|
+
]
|
13
20
|
spec.add_runtime_dependency "pry", "~> 0.12"
|
14
21
|
spec.add_runtime_dependency "twitter", "~> 6.0"
|
15
|
-
spec.add_runtime_dependency "time-lord", "~> 1.0"
|
16
22
|
spec.add_runtime_dependency "tty-box", "= 0.3.0"
|
17
23
|
spec.add_runtime_dependency "unicode-display_width", "~> 1.4"
|
18
|
-
spec.add_runtime_dependency "unicode-emoji", "~> 1.1"
|
19
24
|
end
|
@@ -1,16 +1,11 @@
|
|
1
|
-
name:
|
1
|
+
name: pry_send_tweet
|
2
2
|
root: /path/to/pry-send_tweet.rb
|
3
3
|
|
4
|
-
on_project_start:
|
5
|
-
- vagrant up
|
6
|
-
|
7
4
|
windows:
|
8
5
|
- twitter:
|
9
6
|
layout: even-horizontal
|
10
7
|
panes:
|
11
|
-
-
|
12
|
-
-
|
8
|
+
- source ~/.zshrc && cd /app && pry -r pry-send_tweet -e read-tweets
|
9
|
+
- source ~/.zshrc && cd /app && pry -r pry-send_tweet
|
13
10
|
- sh:
|
14
|
-
-
|
15
|
-
- sync:
|
16
|
-
- vagrant rsync-auto
|
11
|
+
-
|
data/vms/freebsd.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
def run(*cmd)
|
2
|
+
Process.wait Kernel.spawn(*cmd)
|
3
|
+
if !$?.success?
|
4
|
+
raise cmd.join(' ') + " failed."
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
ARGV.each do |argument|
|
9
|
+
case argument
|
10
|
+
when '--fresh' then run('vagrant', 'destroy', '--force')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
run 'vagrant', 'up'
|
15
|
+
run 'vagrant', 'ssh', '-c', 'tmuxinator start pry_send_tweet'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-send_tweet.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Gleeson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '6.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: time-lord
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: tty-box
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '1.4'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: unicode-emoji
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.1'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.1'
|
97
69
|
description: A Twitter client for the Pry REPL.
|
98
70
|
email: trebor.g@protonmail.com
|
99
71
|
executables: []
|
@@ -101,13 +73,13 @@ extensions: []
|
|
101
73
|
extra_rdoc_files: []
|
102
74
|
files:
|
103
75
|
- CHANGELOG.md
|
104
|
-
- Dockerfile
|
105
|
-
- Gemfile
|
106
76
|
- LICENSE.txt
|
107
77
|
- README.md
|
108
78
|
- Vagrantfile
|
109
|
-
-
|
79
|
+
- art/44-e44743a5bb.jpg
|
80
|
+
- art/52-eec4df2edf.jpg
|
110
81
|
- lib/pry-send_tweet.rb
|
82
|
+
- lib/pry/pager/system_pager.rb
|
111
83
|
- lib/pry/send_tweet/commands/base_command.rb
|
112
84
|
- lib/pry/send_tweet/commands/paging/paging_support.rb
|
113
85
|
- lib/pry/send_tweet/commands/read_tweets.rb
|
@@ -125,10 +97,11 @@ files:
|
|
125
97
|
- lib/pry/send_tweet/renderers/user_renderer.rb
|
126
98
|
- lib/pry/send_tweet/tty-box.rb
|
127
99
|
- lib/pry/send_tweet/version.rb
|
100
|
+
- lib/time-ago-in-words/lib/time-ago-in-words.rb
|
128
101
|
- pry-send_tweet.gemspec
|
129
|
-
- samples/
|
130
|
-
- samples/tmuxinator-docker.yml
|
102
|
+
- samples/freebsd-zshrc
|
131
103
|
- samples/tmuxinator-vagrant.yml
|
104
|
+
- vms/freebsd.rb
|
132
105
|
homepage: https://github.com/r-obert/pry-send_tweet.rb
|
133
106
|
licenses:
|
134
107
|
- MIT
|
@@ -137,6 +110,7 @@ post_install_message:
|
|
137
110
|
rdoc_options: []
|
138
111
|
require_paths:
|
139
112
|
- lib
|
113
|
+
- lib/time-ago-in-words/lib
|
140
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
115
|
requirements:
|
142
116
|
- - ">="
|
data/Dockerfile
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
FROM ruby:2.6.0-stretch
|
2
|
-
|
3
|
-
# Add regular user
|
4
|
-
RUN groupadd -g 999 appuser
|
5
|
-
RUN useradd -d /home/appuser -r -u 999 -g appuser appuser
|
6
|
-
RUN mkdir -p /home/appuser
|
7
|
-
WORKDIR /home/appuser/
|
8
|
-
|
9
|
-
# Bundle
|
10
|
-
ADD Gemfile pry-send_tweet.gemspec /home/appuser/
|
11
|
-
ADD lib /home/appuser/lib/
|
12
|
-
RUN gem install bundler
|
13
|
-
# FIXME: During 'bundle install', i got: Could not find gem 'buftok (~> 0.2.0)'
|
14
|
-
# Installing twitter as a gem first fixes that.
|
15
|
-
RUN gem install twitter
|
16
|
-
RUN bundle install
|
17
|
-
|
18
|
-
# Install packages
|
19
|
-
RUN apt-get update
|
20
|
-
RUN apt-get install -y --no-install-recommends locales emacs24-nox less
|
21
|
-
|
22
|
-
# Configure locale
|
23
|
-
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
24
|
-
RUN locale-gen
|
25
|
-
RUN echo 'Europe/Zurich' > /etc/timezone
|
26
|
-
RUN rm /etc/localtime
|
27
|
-
RUN dpkg-reconfigure -f noninteractive tzdata
|
28
|
-
ENV LANG en_US.UTF-8
|
29
|
-
ENV LANGUAGE en_US:en
|
30
|
-
ENV LC_ALL en_US.UTF-8
|
31
|
-
|
32
|
-
# Configure editor
|
33
|
-
ENV EDITOR emacs
|
34
|
-
|
35
|
-
# Add files to container
|
36
|
-
ADD . /home/appuser/
|
37
|
-
|
38
|
-
# Finally, drop root permissions to regular user
|
39
|
-
RUN chown appuser /home/appuser
|
40
|
-
RUN chown -R appuser /home/appuser/*
|
41
|
-
USER appuser
|
data/Gemfile
DELETED
data/dockerize.sh
DELETED
data/samples/hardenedbsd-zshrc
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
name: send_tweets
|
2
|
-
root: /path/to/pry/send/tweet
|
3
|
-
|
4
|
-
on_project_start: docker build -t send_tweets .
|
5
|
-
|
6
|
-
windows:
|
7
|
-
- twitter:
|
8
|
-
layout: even-horizontal
|
9
|
-
panes:
|
10
|
-
- docker run -v $PWD/tweets/:/app/tweets -i -t send_tweets bundle exec pry -e "read-tweets"
|
11
|
-
- docker run -v $PWD/tweets/:/app/tweets -i -t send_tweets bundle exec pry
|
12
|
-
- sh:
|
13
|
-
- docker run -v $PWD/tweets/:/app/tweets -i -t send_tweets bash
|
14
|
-
|
15
|
-
on_project_start: docker build -t send_tweets .
|