pry-send_tweet.rb 0.2.1 → 0.3.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: cdc6280e6a9956b05d10cf4d7385dd9c0591cdb91e44d7f1bce816f59571edf9
4
- data.tar.gz: 4ec587b59b3f4e8c6747d1bdde326bfa07d82b17c5b1418fa12f4f75c50fc0bb
3
+ metadata.gz: 85531325d58b00ce100db9fccfaf9b065c54a120be53dc0ea007e1124203a3fb
4
+ data.tar.gz: de15dd71201380491e4cd2a4e571ca159b4bea2834d4a11364768a5d5053fcf1
5
5
  SHA512:
6
- metadata.gz: '08f21aa24c77b37aee6973d29df1acb51e7f985ba12fff70d0d5e126d7e90ad2e6e68baf480922726a0116a222483d57ae186634049e04a7826bad50b1317159'
7
- data.tar.gz: 45cfe3ffc4067e9d3a2f22ddaac6b88b3f3a9b38b2f18cd42f9c81c345d723f121480f31bf9694d8a1460c01960c792a635b5a28f85e70ac1e4b280f96ac5fdc
6
+ metadata.gz: b4f59a3d61d26ee4439ba8542ca5fb75879f6bd3c6ef5ce8653c35d4a91a80a079da14a622d5c6fc392c3ef80fe9b9359b3004e83e1dacca27bbd64f96f79cd0
7
+ data.tar.gz: 8d79e56d4caeaa08ee870a818eb9051a1d3ee2a9f18b5ad4e95d4119aef835c7f2c76104fa11856eb93ae2c5c0cabea0bea87f1be8ecb6aa7cc23633380b69b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.3.0
4
+
5
+ * Compose a tweet using `pry.editor` instead of a command argument
6
+
3
7
  ## v0.2.1
4
8
 
5
9
  * Don't escape tweet content using 'Shellwords'.
data/README.md CHANGED
@@ -10,7 +10,7 @@ Twitter requires the following keys and tokens to do that:
10
10
 
11
11
  * `consumer_key`, `consumer_secret`, `access_token`, `access_token_secret`
12
12
 
13
- The required keys & tokens can be created on twitter by signing up for a
13
+ The required keys & tokens can be created on Twitter by signing up for a
14
14
  developer account and then creating an "app" for your account. This can be done
15
15
  at [https://developer.twitter.com](https://developer.twitter.com).
16
16
 
@@ -33,15 +33,11 @@ __1.__
33
33
 
34
34
  Sending a tweet:
35
35
 
36
- [1] pry(main)> send-tweet Hello twitter, speaking from #pry
36
+ [1] pry(main)> send-tweet
37
+ # Your editor opens (`_pry_.editor`), compose a tweet then hit save & close.
38
+ # You'll then get the url for your tweet:
37
39
  https://twitter.com/xxx/status/xxx
38
40
 
39
- __2.__
40
-
41
- Sending a tweet, with eval'ed ruby:
42
-
43
- [2] pry(main)> send-tweet #{rand(100)}
44
- https://twitter.com/xxx/status/xxx
45
41
 
46
42
  ## Install
47
43
 
@@ -49,4 +45,4 @@ Sending a tweet, with eval'ed ruby:
49
45
 
50
46
  ## License
51
47
 
52
- [MIT](./LICENSE.txt)
48
+ [MIT](./LICENSE.txt)
@@ -2,24 +2,35 @@ require 'pry' if not defined?(Pry::ClassCommand)
2
2
  Pry.commands.add_command Class.new(Pry::ClassCommand) {
3
3
  require 'twitter'
4
4
  match 'send-tweet'
5
- command_options argument_required: true, shellwords: false
5
+ command_options argument_required: false
6
6
  banner <<-BANNER
7
- send-tweet [tweet]
7
+ send-tweet
8
8
 
9
9
  Send a tweet.
10
10
  BANNER
11
11
 
12
12
  def process(*args)
13
- if _pry_.config.twitter == nil
13
+ if nil == _pry_.config.twitter
14
14
  raise Pry::CommandError, "_pry_.config.twitter is nil!\n" \
15
15
  "Please set the required keys and tokens to send " \
16
16
  "tweets using Twitters API. \n" \
17
17
  "Visit https://github.com/r-obert/pry-send_tweet.rb#readme to learn how."
18
18
  end
19
- tweet = client.update args.join(' ')
20
- _pry_.output.puts tweet.url
19
+ send_tweet_using_editor
21
20
  end
22
21
 
22
+ private
23
+ def send_tweet_using_editor
24
+ tmp_file = Tempfile.new('pry-send_tweet')
25
+ Pry::Editor.new(_pry_).invoke_editor(tmp_file.path, 0)
26
+ tmp_file.rewind
27
+ _pry_.output.puts client.update(tmp_file.read).url
28
+ ensure
29
+ tmp_file.close
30
+ tmp_file.unlink
31
+ end
32
+
33
+
23
34
  def client
24
35
  @client ||= begin
25
36
  Twitter::REST::Client.new {|config|
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pry-send_tweet.rb"
3
- spec.version = "0.2.1"
3
+ spec.version = "0.3.0"
4
4
  spec.authors = ["Robert Gleeson"]
5
5
  spec.email = "trebor.g@protonmail.com"
6
6
  spec.summary = "pry-send_tweet.rb adds a Pry command that can send tweets using your personal twitter account."
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.2.1
4
+ version: 0.3.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: 2018-12-03 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry