pry-send_tweet.rb 0.10.0 → 0.10.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/README.md +18 -11
- data/lib/pry-send_tweet.rb +8 -2
- data/lib/pry/send_tweet/commands/base_command.rb +8 -4
- data/lib/pry/send_tweet/renderers/tweet_renderer.rb +26 -18
- data/lib/pry/send_tweet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4464a0e5487676221d3f0809dab2dcdb2ac192d84ded42dbbae6cb9d8593e459
|
4
|
+
data.tar.gz: 4944d0716568bb7687a5ca0917cd2df1772b4af5cb2bb25117a51d79a8ea9a45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39cca7be237772f1ee3e4ad9c60d4db9bd35a7e96a23274c3d1bb852b838879b20dffe8a7c63568980e3ab022d67b2ae04c2615afea4e99f1fb6469c87bc2509
|
7
|
+
data.tar.gz: 71ffdc012830a01ceb5a03b1b9ada4bb8899e7422a0e74e6824ff19296cea032fabca05d511dbdcbd202baf37816547414c89b01ad68806f2a083be8e46b5156
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
##
|
3
|
+
## v0.10.1
|
4
|
+
|
5
|
+
* Improve forking implementation in `Pry::SendTweet::TweetRenderer`.
|
6
|
+
|
7
|
+
* Improve the workaround for weak unicode support in tty-box.
|
8
|
+
|
9
|
+
* Add `Pry.config.twitter.box_height` - for defining the height of the box that
|
10
|
+
contains a tweet or user.
|
11
|
+
|
12
|
+
* Add `Pry.config.twitter.box_width`, formerly `Pry.config.twitter.line_width`.
|
13
|
+
|
14
|
+
## v0.10.0
|
4
15
|
|
5
16
|
* Avoid a negative argument error when following / unfollowing other user(s) by
|
6
17
|
bypassing tty-box for those operations.
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
* [Tip: Command Aliases](#tip)
|
19
19
|
* [Multi-tasking: tmux / screen](#multi-tasking)
|
20
20
|
* [Install](#install)
|
21
|
+
* [Rubygem](#install-rubygem)
|
22
|
+
* [Docker](#install-docker)
|
21
23
|
* [License](#license)
|
22
24
|
|
23
25
|
## <a id='Introduction'>Introduction</a>
|
@@ -27,8 +29,10 @@ A Twitter client for the Pry REPL.
|
|
27
29
|
## <a id='api-access'>API Access</a>
|
28
30
|
|
29
31
|
Using the Twitter API requires a developer account.
|
30
|
-
Follow the instructions at
|
31
|
-
|
32
|
+
Follow the instructions at
|
33
|
+
[https://developer.twitter.com](https://developer.twitter.com)
|
34
|
+
if you haven't already
|
35
|
+
setup access to the Twitter API.
|
32
36
|
|
33
37
|
## <a id='configuration'>Configuration (required)</a>
|
34
38
|
|
@@ -51,10 +55,12 @@ Pry.configure do |config|
|
|
51
55
|
access_token_secret: '<access token secret>'
|
52
56
|
# Optional configuration
|
53
57
|
# The User-Agent to use when making requests to the Twitter API.
|
54
|
-
# Default is: 'pry-send_tweet.rb vX.Y.Z'
|
58
|
+
# Default is: 'pry-send_tweet.rb vX.Y.Z'.
|
55
59
|
user_agent: 'Custom User-Agent',
|
56
|
-
# The width of a
|
57
|
-
|
60
|
+
# The width & height of a box that contains a tweet or user.
|
61
|
+
# The default width is 100 and the default height is 8.
|
62
|
+
box_width: 120,
|
63
|
+
box_height: 10
|
58
64
|
})
|
59
65
|
end
|
60
66
|
```
|
@@ -238,7 +244,7 @@ The `twitter-search` command can be used to search Twitter.
|
|
238
244
|
* Set the color (as a hex value) of links that appear on your profiles timeline:
|
239
245
|
|
240
246
|
[1] pry(main)> on-twitter --set-profile-link-color=#CC0000
|
241
|
-
|
247
|
+
|
242
248
|
* Set the URL visible on your profile:
|
243
249
|
|
244
250
|
[1] pry(main)> on-twitter --set-profile-url=https://github.com/you
|
@@ -321,14 +327,15 @@ as inspiration for your own configuration.
|
|
321
327
|
|
322
328
|
## <a id='install'>Install</a>
|
323
329
|
|
324
|
-
|
330
|
+
### <a id='install-rubygem'>Rubygem</a>
|
325
331
|
|
326
332
|
$ gem install pry-send_tweet.rb
|
327
333
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
334
|
+
### <a id='install-docker'>Docker</a>
|
335
|
+
|
336
|
+
This method is how I install and use `pry-send_tweet.rb`, I recommend giving it
|
337
|
+
a try - especially if on Windows. The Docker container is configured to use `emacs`
|
338
|
+
when sending tweets and when using other commands that open an editor.
|
332
339
|
|
333
340
|
$ git clone https://github.com/r-obert/pry-send_tweet.rb
|
334
341
|
$ cd pry-send_tweet.rb
|
data/lib/pry-send_tweet.rb
CHANGED
@@ -2,11 +2,17 @@ class Pry
|
|
2
2
|
module SendTweet
|
3
3
|
#
|
4
4
|
# @return [Integer]
|
5
|
-
# The
|
5
|
+
# The default width of a box that contains a tweet or user.
|
6
6
|
#
|
7
7
|
# @api private
|
8
8
|
#
|
9
|
-
|
9
|
+
DEFAULT_BOX_WIDTH = 100
|
10
|
+
|
11
|
+
#
|
12
|
+
# @return [Integer]
|
13
|
+
# The default height of a box that contains a tweet or user.
|
14
|
+
#
|
15
|
+
DEFAULT_BOX_HEIGHT = 8
|
10
16
|
|
11
17
|
#
|
12
18
|
# @return [Integer]
|
@@ -18,6 +18,14 @@ class Pry::SendTweet::BaseCommand < Pry::ClassCommand
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
def box_height
|
22
|
+
_pry_.config.twitter.box_height || Pry::SendTweet::DEFAULT_BOX_HEIGHT
|
23
|
+
end
|
24
|
+
|
25
|
+
def box_width
|
26
|
+
_pry_.config.twitter.box_width || Pry::SendTweet::DEFAULT_BOX_WIDTH
|
27
|
+
end
|
28
|
+
|
21
29
|
def search_str_for_users(*ary)
|
22
30
|
ary.map do |str|
|
23
31
|
if str.start_with?('https://twitter.com')
|
@@ -46,10 +54,6 @@ class Pry::SendTweet::BaseCommand < Pry::ClassCommand
|
|
46
54
|
"%-d %b %Y, %-I:%M:%S %p"
|
47
55
|
end
|
48
56
|
|
49
|
-
def line_width
|
50
|
-
_pry_.config.twitter.line_width || Pry::SendTweet::DEFAULT_LINE_WIDTH
|
51
|
-
end
|
52
|
-
|
53
57
|
def twitter
|
54
58
|
@twitter ||= _pry_.binding_stack[-1].eval('_twitter_')
|
55
59
|
end
|
@@ -2,20 +2,12 @@ module Pry::SendTweet::TweetRenderer
|
|
2
2
|
include Timeout
|
3
3
|
|
4
4
|
def render_tweets(tweet_fetcher, title:, timeout: _pry_.config.twitter.refresh_interval)
|
5
|
-
interval = __choose_render_interval(timeout)
|
6
5
|
pid = nil
|
7
|
-
timeout(
|
8
|
-
|
9
|
-
|
10
|
-
__trap_signal(pager)
|
11
|
-
tweets = __fetch_tweets(tweet_fetcher)
|
12
|
-
tweets.empty? ? pager.write("No tweets to show.") :
|
13
|
-
pager.write(__render_tweets(title, tweets))
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
6
|
+
timeout(__choose_render_interval(timeout)) {
|
7
|
+
tweets = __fetch_tweets(tweet_fetcher)
|
8
|
+
pid = __fork_pager(tweets)
|
17
9
|
Process.wait(pid)
|
18
|
-
|
10
|
+
}
|
19
11
|
rescue Interrupt
|
20
12
|
__kill_pager!(pid)
|
21
13
|
system 'reset'
|
@@ -26,6 +18,18 @@ module Pry::SendTweet::TweetRenderer
|
|
26
18
|
end
|
27
19
|
|
28
20
|
private
|
21
|
+
# @api private
|
22
|
+
def __fork_pager(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("Twitter", tweets))
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
29
33
|
# @api private
|
30
34
|
def __render_tweets(title, tweets)
|
31
35
|
title = bright_blue(bold((" " * 40) + title) + "\n\n")
|
@@ -35,8 +39,8 @@ module Pry::SendTweet::TweetRenderer
|
|
35
39
|
# @api private
|
36
40
|
def __render_tweet(tweet)
|
37
41
|
contents = __get_tweet_contents(tweet)
|
38
|
-
TTY::Box.frame(height:
|
39
|
-
width:
|
42
|
+
TTY::Box.frame(height: box_height,
|
43
|
+
width: box_width,
|
40
44
|
title: {top_left: __render_tweet_title(tweet)}) do
|
41
45
|
"#{tweet.url}\n--\n#{contents}\n"
|
42
46
|
end.to_s
|
@@ -58,7 +62,7 @@ module Pry::SendTweet::TweetRenderer
|
|
58
62
|
text = tweet.attrs[:full_text] ? tweet.attrs[:full_text] :
|
59
63
|
tweet.full_text
|
60
64
|
text = __tty_box_sanitize(CGI.unescapeHTML(text)).strip
|
61
|
-
text.size == 0 || text
|
65
|
+
text.size == 0 || text !~ /[a-z0-9]{1,}/i ? "\n[ Outside ASCII charset ]\n" : text
|
62
66
|
end
|
63
67
|
|
64
68
|
# @api private
|
@@ -71,6 +75,7 @@ module Pry::SendTweet::TweetRenderer
|
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
78
|
+
# @api private
|
74
79
|
def __choose_render_interval(timeout)
|
75
80
|
if timeout == false
|
76
81
|
nil
|
@@ -82,13 +87,16 @@ module Pry::SendTweet::TweetRenderer
|
|
82
87
|
# @api private
|
83
88
|
def __kill_pager!(pid)
|
84
89
|
Process.kill('SIGINT', pid)
|
90
|
+
Process.wait(pid) rescue nil
|
85
91
|
end
|
86
92
|
|
87
93
|
# @api private
|
88
|
-
def
|
94
|
+
def __trap_signal_in_fork(pager)
|
89
95
|
trap('SIGINT') {
|
90
|
-
|
91
|
-
|
96
|
+
if Pry::Pager::SystemPager === pager
|
97
|
+
syspager = pager.send(:pager)
|
98
|
+
Process.kill('SIGKILL', syspager.pid) rescue nil
|
99
|
+
end
|
92
100
|
Process.kill('SIGKILL', Process.pid)
|
93
101
|
}
|
94
102
|
end
|
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.10.
|
4
|
+
version: 0.10.1
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|