pry-send_tweet.rb 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8feaa382edf88c8b48066b7cbfc2c2d08b0fcb34a3d6f976e639041af51d4820
4
- data.tar.gz: ac72cdd37aee73e2aeefc7dea74b596ba62e40c23238734be1fad90f06a1d063
3
+ metadata.gz: 3ce2553fea351dc038a90454aab0c8fea7ba8a68116f20732d1f4ac06287e241
4
+ data.tar.gz: 8d7a7a9a77a2ed1c392d508ac64cbfa7daaafa7975c0667fa72b8257fdd595f3
5
5
  SHA512:
6
- metadata.gz: 9e6ab0d98689c9e3f101f1e9f5afa0389afdaaf5041ec3eacc939452bd058ed7834d7c4b60ed1887a0eb7c54bbeb1cad7337393946b27abc92e938889841306e
7
- data.tar.gz: 5f019e2cdbf53d8598c09abebaf0f930075f3f9f8df0b5e38b9834901f313caae0a88969f958cea077c80eebccba193020a3b3e53c21992f78eb74982baa453d
6
+ metadata.gz: a8ce626ae62a433641ae6939e61ae8e8ff597d88e881c0e722786ca3d180c44c7bf4712e2e8f265f62952189b6f13afbb68d7aba2c62c9ba00a358d31746c4ec
7
+ data.tar.gz: 000dca566ec219b81d8ce3470e38b3d6f3a46688032c8831bb1f409dac235d339884b4e9686258cadc5046206d7de661b71f5eddadae9223df9da26eead6270c
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
- ## master
3
+ ## v0.8.0
4
+
5
+ * Add sticky local variable `_twitter_` to the active Binding.
6
+
7
+ ## v0.7.0
4
8
 
5
9
  * Add `send-tweet -n`, `send-tweet --no-newline`, for removing newlines from a
6
10
  tweet before sending it.
data/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  * [Profile Actions](#profile-actions)
14
14
  * [Twitter Suggestions](#twitter-suggestions)
15
15
  * [Muting other users](#muting-other-users)
16
+ * [Sticky local variable: `_twitter_` ](#special-variable-_twitter_)
16
17
  * [Tip: Command Aliases](#tip)
17
18
  * [Multi-tasking: tmux / screen](#multi-tasking)
18
19
  * [Install](#install)
@@ -218,6 +219,25 @@ The `twitter-search` command can be used to search Twitter.
218
219
 
219
220
  [1] pry(main)> on-twitter --unmute-user=user1,user2,user3
220
221
 
222
+
223
+ ### <a id='special-variable-_twitter_'>Sticky local variable: `_twitter_`</a>
224
+
225
+ The local variable `_twitter_` is inserted into the active Binding, providing
226
+ a programmable API accessible to Ruby code as well as a lower level of access to
227
+ the Twitter API. It is meant for exploration, development, and debugging. The local
228
+ variable is considered reserved, if another local variable of the same name is set
229
+ in the same Binding, expect unusual behaviour.
230
+
231
+ The local variable returns an instance of `Twitter::REST::Client`:
232
+
233
+ [1] pry(main)> _twitter_
234
+ => #<Twitter::REST::Client:0x00007ff44cd6dce0
235
+ @access_token="xxx",
236
+ @access_token_secret="xxx",
237
+ @consumer_key="xxx",
238
+ @consumer_secret="xxx",
239
+ @user_agent="pry-send_tweet.rb v0.7.0">
240
+
221
241
  ### <a id='tip'>Tip: Command Aliases</a>
222
242
 
223
243
  When there are Twitter accounts you read often, it can turn out to be faster
@@ -30,3 +30,22 @@ class Pry
30
30
  require_relative 'pry/send_tweet/commands/twitter_action'
31
31
  end
32
32
  end
33
+
34
+ Pry.configure do |config|
35
+ b = lambda do |*ary|
36
+ pry = ary[-1]
37
+ twitter = Twitter::REST::Client.new {|config|
38
+ config.consumer_key = pry.config.twitter.consumer_key
39
+ config.consumer_secret = pry.config.twitter.consumer_secret
40
+ config.access_token = pry.config.twitter.access_token
41
+ config.access_token_secret = pry.config.twitter.access_token_secret
42
+ }.tap {|twitter|
43
+ twitter.user_agent = pry.config.twitter.user_agent ||
44
+ "pry-send_tweet.rb v#{Pry::SendTweet::VERSION}"
45
+ }
46
+ target = pry.binding_stack[-1]
47
+ target.local_variable_set :_twitter_, twitter
48
+ end
49
+ config.hooks.add_hook(:before_eval, 'pry_send_tweets_before_eval', b)
50
+ config.hooks.add_hook(:before_session, 'pry_send_tweets_before_session', b)
51
+ end
@@ -56,14 +56,6 @@ class Pry::SendTweet::BaseCommand < Pry::ClassCommand
56
56
  end
57
57
 
58
58
  def twitter
59
- @twitter ||= Twitter::REST::Client.new { |config|
60
- config.consumer_key = _pry_.config.twitter.consumer_key
61
- config.consumer_secret = _pry_.config.twitter.consumer_secret
62
- config.access_token = _pry_.config.twitter.access_token
63
- config.access_token_secret = _pry_.config.twitter.access_token_secret
64
- }.tap {|twitter|
65
- twitter.user_agent = _pry_.config.twitter.user_agent ||
66
- "pry-send_tweet.rb v#{Pry::SendTweet::VERSION}"
67
- }
59
+ @twitter ||= _pry_.binding_stack[-1].eval('_twitter_')
68
60
  end
69
61
  end
@@ -1,5 +1,5 @@
1
1
  class Pry
2
2
  module SendTweet
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  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.7.0
4
+ version: 0.8.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-08 00:00:00.000000000 Z
11
+ date: 2019-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry