pry-send_tweet.rb 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85531325d58b00ce100db9fccfaf9b065c54a120be53dc0ea007e1124203a3fb
4
- data.tar.gz: de15dd71201380491e4cd2a4e571ca159b4bea2834d4a11364768a5d5053fcf1
3
+ metadata.gz: a1ea12e85df53a86fb132f2742e161b385c3d3fcecd8d2be8a5d46ed5c17e303
4
+ data.tar.gz: 551b008e811ba767defb60ec07ef8760e3b11e9f1e3b014ece1364ce1cbddf27
5
5
  SHA512:
6
- metadata.gz: b4f59a3d61d26ee4439ba8542ca5fb75879f6bd3c6ef5ce8653c35d4a91a80a079da14a622d5c6fc392c3ef80fe9b9359b3004e83e1dacca27bbd64f96f79cd0
7
- data.tar.gz: 8d79e56d4caeaa08ee870a818eb9051a1d3ee2a9f18b5ad4e95d4119aef835c7f2c76104fa11856eb93ae2c5c0cabea0bea87f1be8ecb6aa7cc23633380b69b5
6
+ metadata.gz: 1f049151c4f2ae0e2cc620f4ac00407a9cdeb640926173889a18d4bd0b49e3ba8b6b9462cf59ec13b5124fbfd02118fa6a6238260701cb04ead4bcf61fa0bcd4
7
+ data.tar.gz: 5a371218f0153b93afc3b16c95aa034ef801072658efa339cdf8bf12c1adaa09cd496ea20043fec155adc56342d36518a343795f9b3f11942b25e2b0659eee61
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.4.0
4
+
5
+ * Add support for attaching an image to a tweet with the optional `-f` switch:
6
+ `send-tweet -f /path/to/image.jpg`
7
+
3
8
  ## v0.3.0
4
9
 
5
10
  * Compose a tweet using `pry.editor` instead of a command argument
data/README.md CHANGED
@@ -31,13 +31,18 @@ end
31
31
 
32
32
  __1.__
33
33
 
34
- Sending a tweet:
34
+ Send a tweet:
35
35
 
36
36
  [1] pry(main)> send-tweet
37
37
  # Your editor opens (`_pry_.editor`), compose a tweet then hit save & close.
38
38
  # You'll then get the url for your tweet:
39
39
  https://twitter.com/xxx/status/xxx
40
40
 
41
+ __2.__
42
+
43
+ Send a tweet with an image attached:
44
+
45
+ [1] pry(main)> send-tweet -f #{File.join ENV['HOME'], 'photos', 'WinnieThePooh.jpg'}
41
46
 
42
47
  ## Install
43
48
 
@@ -4,11 +4,18 @@ Pry.commands.add_command Class.new(Pry::ClassCommand) {
4
4
  match 'send-tweet'
5
5
  command_options argument_required: false
6
6
  banner <<-BANNER
7
- send-tweet
7
+ send-tweet [options]
8
8
 
9
9
  Send a tweet.
10
10
  BANNER
11
11
 
12
+ def options(opts)
13
+ opts.on :f,
14
+ :file,
15
+ 'A path to an image or other media to attach to a tweet',
16
+ argument: true
17
+ end
18
+
12
19
  def process(*args)
13
20
  if nil == _pry_.config.twitter
14
21
  raise Pry::CommandError, "_pry_.config.twitter is nil!\n" \
@@ -24,7 +31,13 @@ Pry.commands.add_command Class.new(Pry::ClassCommand) {
24
31
  tmp_file = Tempfile.new('pry-send_tweet')
25
32
  Pry::Editor.new(_pry_).invoke_editor(tmp_file.path, 0)
26
33
  tmp_file.rewind
27
- _pry_.output.puts client.update(tmp_file.read).url
34
+ if opts.f?
35
+ file = File.new opts[:f], 'r'
36
+ _pry_.output.puts client.update_with_media(tmp_file.read, file).url
37
+ file.close
38
+ else
39
+ _pry_.output.puts client.update(tmp_file.read).url
40
+ end
28
41
  ensure
29
42
  tmp_file.close
30
43
  tmp_file.unlink
@@ -33,7 +46,7 @@ Pry.commands.add_command Class.new(Pry::ClassCommand) {
33
46
 
34
47
  def client
35
48
  @client ||= begin
36
- Twitter::REST::Client.new {|config|
49
+ Twitter::REST::Client.new { |config|
37
50
  config.consumer_key = _pry_.config.twitter.consumer_key
38
51
  config.consumer_secret = _pry_.config.twitter.consumer_secret
39
52
  config.access_token = _pry_.config.twitter.access_token
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pry-send_tweet.rb"
3
- spec.version = "0.3.0"
3
+ spec.version = "0.4.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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-send_tweet.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gleeson