pry-send_tweet.rb 0.13.1 → 1.0.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: 4472ff3991955109ac85b9e5d958797f3ee995f09055797915015560b36003aa
4
- data.tar.gz: 8c35030496b10cd6271a38d56b85de93830030721efc2b91dba5e97e929b9bf6
3
+ metadata.gz: cb50a520bd9d7d87d904352181d1bbdf495be3a947a627994878167df6989be9
4
+ data.tar.gz: c7320bf7d265d5949e35ee9cae98862de3ad58304ffe95ed6ae14d74f5987654
5
5
  SHA512:
6
- metadata.gz: ef03150ab5edcc9e0e88036c7b9851448d98efba1f00a143df89f8f55354520268153500bd5b19af962b7974b49fba627adc0c528cc132896df45353db62bdd0
7
- data.tar.gz: c611456c0762f63f3776859fc67216ccfdf211a34da0893d01af1fe3f4cab50f253ba0cdec5517d85d38144036e9bab3544e13d911e472740a3cd0265a4706e2
6
+ metadata.gz: 57c3a8d2eb322885604eb7dac9d65b5bdeb919b450906dcbbc9c9669cb8486232c0138bec97c15655f4194a1edc06ed8da47ea37f8f2411649aba4133db74300
7
+ data.tar.gz: 900eab4b0719ee16741e705addcb5d23ae3e8401367f4c8611a94a2aaf23aa3ffb45290f71b39075d47e56d1561ce2a6e508bea29ec0f82e9c1e5e462ad2de96
@@ -1,5 +1,28 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## master
4
+
5
+ * Read media contents into memory immediately to avoid the potential for
6
+ tampering between the time tweet is scheduled and its actual creation.
7
+
8
+ * Update `README.md` documentation to include `on-twitter --set-profile-location`.
9
+
10
+ * Include the time of the last and next refresh cycle when rendering
11
+ tweets that are automatically refreshed every `X` seconds.
12
+
13
+ * `TimeAgoInWords` represents a past tense Time object as
14
+ `<number> <unit> before <time>`.
15
+
16
+ * A single instance of `Twitter::REST::Client` shared across potentially
17
+ multiple threads is not going to work, re-create `Twitter::REST::Client`
18
+ instance before each eval, that is local to its Pry instance.
19
+
20
+ * Switch to `Pry#add_sticky_local` for inserting the special local variable,
21
+ `_twitter_`.
22
+
23
+ * Add `config.twitter.default_read_size`, for setting the default number of
24
+ tweets to request from Twitter when reading tweets via its API.
25
+
3
26
  ## v0.13.1
4
27
 
5
28
  * Load `$HOME/.pry-send_tweet.yml` using `YAML.safe_load()`.
@@ -1,22 +1,24 @@
1
- MIT License
1
+ Copyright (c) 2018, Robert McIntyre
2
+ All rights reserved.
2
3
 
3
- Copyright 2017
4
- Robert Gleeson
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the Fry|Pry organisations nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
5
14
 
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,25 @@
1
+ License
2
+ -------
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2011-2019 The Pry Team
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ 'Software'), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be
17
+ included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # pry-send_tweet.rb
1
+ # fry-send_tweet.rb
2
2
 
3
3
  * [Introduction](#introduction)
4
4
  * [API Access](#api-access)
@@ -26,7 +26,7 @@
26
26
 
27
27
  ## <a id='Introduction'>Introduction</a>
28
28
 
29
- A Twitter client for the Pry REPL.
29
+ An extensible Twitter client that lives inside the Pry and Fry REPLs.
30
30
 
31
31
  ## <a id='api-access'>API Access</a>
32
32
 
@@ -47,21 +47,27 @@ __1. Ruby__
47
47
  # .pryrc
48
48
  Pry.configure do |config|
49
49
  config.twitter = Pry::Config.from_hash({
50
- # Required configuration
50
+ # Required
51
51
  consumer_key: '<consumer key>',
52
52
  consumer_secret: '<consumer secret>',
53
53
  access_token: '<access token>',
54
54
  access_token_secret: '<access token secret>',
55
- # Optional configuration
55
+ # Optional
56
+ # The number of tweets to request from Twitter when reading tweets via
57
+ # its API. The default is 200, a lower number could speed up requests if
58
+ # you find them to be slow.
59
+ default_read_size: 100,
60
+ # Optional
56
61
  # The User-Agent to use when making requests to the Twitter API.
57
62
  # Default is: 'pry-send_tweet.rb vX.Y.Z'.
58
63
  user_agent: 'Custom User-Agent',
59
- # Optional configuration
64
+ # Optional
60
65
  # The width of a box that contains a tweet or user. The default width is 100.
61
66
  box_width: 120,
62
- # Optional configuration
67
+ # Optional
63
68
  # A Yandex API key for translating tweets when using `read-tweets -x`.
64
69
  yandex_key: 'xxx',
70
+ # Optional
65
71
  # The language tweets should be translated to, the default is 'en' (English).
66
72
  yandex_lang: 'ru'
67
73
  })
@@ -80,6 +86,8 @@ consumer_secret: '<consumer secret>'
80
86
  access_token: '<access token>'
81
87
  access_token_secret: '<access token secret>'
82
88
  # Optional
89
+ default_read_size: 100
90
+ # Optional
83
91
  user_agent: 'Your User-Agent string'
84
92
  # Optional
85
93
  box_width: 120
@@ -280,9 +288,9 @@ The `twitter-search` command can be used to search Twitter.
280
288
 
281
289
  * Set the location visible on your profile:
282
290
 
283
- # An editor opens (`_pry_.editor`), write your location then hit save &
284
- # close. Your profiles location will be updated after closing the editor.
285
- [1] pry(main)> on-twitter --set-profile-bio
291
+ # An editor opens (`_pry_.editor`), write a location then hit save & close.
292
+ # Your profiles location will be updated after closing the editor.
293
+ [1] pry(main)> on-twitter --set-profile-location
286
294
 
287
295
  * Set the color (as a hex value) of links that appear on your profiles timeline:
288
296
 
Binary file
Binary file
@@ -28,6 +28,7 @@ class Pry
28
28
  require 'timeout'
29
29
  require 'yaml'
30
30
  require 'time-ago-in-words'
31
+ require_relative 'pry/send_tweet/twitter_io'
31
32
  require_relative 'pry/pager/system_pager'
32
33
  require_relative 'pry/send_tweet/tty-box'
33
34
  require_relative 'pry/send_tweet/renderers/tweet_renderer'
@@ -38,6 +39,7 @@ class Pry
38
39
  require_relative 'pry/send_tweet/commands/read_tweets'
39
40
  require_relative 'pry/send_tweet/commands/twitter_search'
40
41
  require_relative 'pry/send_tweet/commands/twitter_action'
42
+ require_relative 'pry/send_tweet/commands/easter_eggs'
41
43
  require_relative 'pry/send_tweet/version'
42
44
 
43
45
  # @api private
@@ -54,22 +56,19 @@ class Pry
54
56
  end
55
57
 
56
58
  Pry.configure do |config|
57
- twitter = nil
58
59
  b = lambda do |*ary|
59
60
  pry = ary[-1]
60
- twitter ||= Twitter::REST::Client.new {|config|
61
+ twitter = Twitter::REST::Client.new do |config|
61
62
  Pry::SendTweet.merge_yaml_file! pry.config,
62
63
  File.join(ENV['HOME'], '.pry-send_tweet.yml')
63
64
  config.consumer_key = pry.config.twitter.consumer_key
64
65
  config.consumer_secret = pry.config.twitter.consumer_secret
65
66
  config.access_token = pry.config.twitter.access_token
66
67
  config.access_token_secret = pry.config.twitter.access_token_secret
67
- }.tap {|twitter|
68
- twitter.user_agent = pry.config.twitter.user_agent ||
69
- "pry-send_tweet.rb v#{Pry::SendTweet::VERSION}"
70
- }
71
- target = pry.binding_stack[-1]
72
- target.local_variable_set :_twitter_, twitter
68
+ end
69
+ twitter.user_agent = pry.config.twitter.user_agent ||
70
+ "pry-send_tweet.rb v#{Pry::SendTweet::VERSION}"
71
+ pry.add_sticky_local(:_twitter_) { twitter }
73
72
  end
74
73
  config.hooks.add_hook(:before_eval, 'pry_send_tweets_before_eval', b)
75
74
  config.hooks.add_hook(:before_session, 'pry_send_tweets_before_session', b)
@@ -16,12 +16,16 @@ class Pry::SendTweet::BaseCommand < Pry::ClassCommand
16
16
  raise Pry::CommandError, "_pry_.config.twitter is nil!\n" \
17
17
  "Please set the required keys and tokens to send " \
18
18
  "tweets using Twitters API. \n" \
19
- "Visit https://github.com/r-obert/pry-send_tweet.rb#readme to learn how."
19
+ "Visit https://gitlab/trebor8/fry-send_tweet.rb to learn how."
20
20
  end
21
21
  end
22
22
 
23
23
  private
24
24
 
25
+ def default_read_size
26
+ _pry_.config.twitter.default_read_size || Pry::SendTweet::DEFAULT_READ_SIZE
27
+ end
28
+
25
29
  def box_height
26
30
  Pry::SendTweet::DEFAULT_BOX_HEIGHT
27
31
  end
@@ -0,0 +1,185 @@
1
+ Pry.commands.instance_eval do
2
+ command(/[Bb]ismillah/, "") {
3
+ _pry_.pager.page [
4
+ "The ِBeneficient / All-Compassionate / Most Gracious",
5
+ "The Most Merciful / Ever-Merciful / Merciful / Most Clement",
6
+ 'The King / Lord / Sovereign / Dominion / Master [also means "the God/ Lord, the One and Only", "Possessor of Supreme Power or Authority"]',
7
+ "The Holy / All-Holy / All-Pure / Sacred / All-Sacred",
8
+ "The Giver of Peace / Peace / All-Calm / Ever-Tranquil",
9
+ "The Granter of Security / the Giver / Faith / Supreme Believer (of Belief) / Giver of Belief / All-Assurer",
10
+ "The Controller / Absolute Authority Over All / Guardian Over All / Absolute Master / Eternal Dominating",
11
+ "The Exalted in Might and Power / Exalted / Powerful / Almighty / Mighty",
12
+ "The Omnipotent / Supreme Power / Possessor of Having All Power / Strong",
13
+ "The Possessor of Greatness / Supreme / Justly Proud",
14
+ "The Creator / Creator of the Universe / Maker / True Originator / Absolute Author",
15
+ "The Initiator / Evolver/ Eternal Spirit Worshipped By All, Have Absolute Power Over All Matters, Nature and Events",
16
+ "The Fashioner / Shaper / Designer / Artist",
17
+ "The Repeatedly Forgiving / Absolute Forgiver / Pardoner / Condoner [He Who is Ready to Pardon and Forgive]",
18
+ "The Subduer / Overcomer / Conqueror / Absolute Vanquisher [Possessor of Who Subdues Evil and Oppression]",
19
+ "The ِِAbsolute Bestower / Giver / Grantor / Great Donor",
20
+ "The Provider / Sustainer / Bestower of Sustenance / All-Provider",
21
+ "The Opener / Opener of the Gates of Profits / Reliever / The Victory Giver",
22
+ "The Knowing / All-Knower / Omniscient / All-Knowledgeable / Possessor of Knowing Much of Ever Thing / All-Knowing",
23
+ "The Restrainer / Withholder / Straightener / Absolute Seizer",
24
+ "The Extender / Expander / Generous Provider",
25
+ "The Abaser / Humiliator / Downgrader [Possessor of Giving Comfort, Free from Pain Anxiety or Troubles]",
26
+ "The Exalter / Upgrader [of Ranks]",
27
+ "The Giver of Honor / Bestower of Honor / Empowerer",
28
+ "The Giver of Dishonor / the Giver of Disgrace",
29
+ "The Hearing / All-Hearing / Hearer of Invocation",
30
+ "The All-Seeing / All-Seer / Ever-Clairvoyant / Clear-Sighted / Clear-Seeing",
31
+ "The Judge / Arbitrator / Arbiter / All-Decree / Possessor of Authority of Decisions and Judgment",
32
+ "The Just / Authorized and Straightforward Judge of Dealing Justly",
33
+ "The Gentle / Benignant / Subtly Kind / All-Subtle",
34
+ "The All-Aware / Well-Acquainted / Ever-Adept",
35
+ "The Forbearing / Indulgent / Oft Forbearing / All-Enduring (of Suffering Pain with Patience)",
36
+ "The Most Great / Ever-Magnificent / Most Supreme / Exalted / Absolute Dignified",
37
+ "The Ever-Forgiving / Oft-Forgiving",
38
+ "The Grateful / Appreciative / Multiplier of Rewards",
39
+ "The Sublime / Ever-Exalted / Supreme / Most High / Most Lofty",
40
+ "The Great/ Ever-Great / Grand / Most Great / Greatly Abundant of Extent, Capacity and Importance",
41
+ "The Preserver / Ever-Preserving / All-Watching / Protector / Guardian / Oft-Conservator",
42
+ "The Nourisher / Feeder",
43
+ "The Bringer of Judgment / Ever-Reckoner [the One Who Takes Account of All Matters]",
44
+ "The Majestic / Exalted / Oft-Important / Splendid",
45
+ "The Noble / Bountiful / Generous / Precious / Honored / Benefactor",
46
+ "The Watchful / Observer / Ever-Watchful / Watcher",
47
+ "The Responsive / Answerer / Supreme Answerer / Accepter of Invocation",
48
+ "The Vast/ All-Embracing / Omnipresent / Boundless / All-Encompassing",
49
+ "The Wise/ Ever-Wise / Endowed with Sound Judgment",
50
+ "The Affectionate / Ever-Affectionate/ Loving One/ Loving/ the One Who Tenders and Warm Hearts",
51
+ "The All-Glorious / Majestic / Ever-Illustrious [Oft-Brilliant in Dignity, Achievements or Actions]",
52
+ "The Resurrector / Awakener / Arouser / Dispatcher",
53
+ "The Witness / Testifier / Ever-Witnessing",
54
+ "The Truth / Reality / the Only One Certainly Sound and Genuine in Truth",
55
+ "The Trustee, The Dependable, The Advocate",
56
+ "The Strong",
57
+ "The Firm, The Steadfast",
58
+ "The Friend, Helper",
59
+ "The All Praiseworthy",
60
+ "The Accounter, The Numberer of All",
61
+ "The Originator, The Producer, The Initiator",
62
+ "The Restorer, The Reinstater Who Brings Back All",
63
+ "The Giver of Life",
64
+ "The Bringer of Death",
65
+ "The Living",
66
+ "The Subsisting, The Independent",
67
+ "The Perceiver, The Finder, The Unfailing",
68
+ "The Illustrious, The Magnificent",
69
+ "The Unique, The Single",
70
+ "The One, The Indivisible",
71
+ "The Eternal, The Absolute, The Self-Sufficient",
72
+ "The All-Powerful, He Who is able to do Everything",
73
+ "The Determiner, The Dominant",
74
+ "The Expediter, He Who Brings Forward",
75
+ "The Delayer, He Who Puts Far Away",
76
+ "The First, The Beginning-less",
77
+ "The Last, The Endless",
78
+ "The Manifest, The Evident, The Outer",
79
+ "The Hidden, The Unmanifest, The Inner",
80
+ "The Patron, The Protecting Friend, The Friendly Lord",
81
+ "The Supremely Exalted, The Most High",
82
+ "The Good, The Beneficent",
83
+ "The Ever-Returning, Ever-Relenting",
84
+ "The Avenger",
85
+ "The Pardoner, The Effacer, The Forgiver",
86
+ "The Kind, The Pitying",
87
+ "The Owner of all Sovereignty",
88
+ "The Owner, Lord of Majesty and Honour",
89
+ "The Equitable, The Requiter",
90
+ "The Gatherer, The Unifier",
91
+ "The Rich, The Independent",
92
+ "The Enricher, The Emancipator",
93
+ "The Preventer, The Withholder, The Shielder, The Defender",
94
+ "The Distressor, The Harmer, The Afflictor",
95
+ "The Propitious, The Benefactor, The Source of Good",
96
+ "The Light",
97
+ "The Guide, The Way",
98
+ "The Originator, The Incomparable, The Unattainable, The Beautiful",
99
+ "The Immutable, The Infinite, The Everlasting",
100
+ "The Heir, The Inheritor of All",
101
+ "The Guide to the Right Path",
102
+ "The Timeless, The Patient"
103
+ ].sample
104
+ }
105
+ alias_command '99', 'bismillah'
106
+
107
+ DISCO_BISCUITS = {
108
+ 'Steve Miller Band - Abracadabra (12" Version) (Vinyl)' => 'https://www.youtube.com/watch?v=YqloCj1ZNSw',
109
+ 'Billy Joel Piano Man Lyrics' => 'https://www.youtube.com/watch?v=ErEzQOFzPXU',
110
+ '6IX9INE - STOOPID FT. BOBBY SHMURDA (Official Music Video)' => 'https://www.youtube.com/watch?v=VDa5iGiPgGs',
111
+ 'NOOP DOGG - O M G (3RIS D3D3 REMIX)' => 'https://www.youtube.com/watch?v=PJL8-DZEscs',
112
+ 'The Frames - Star Star **' => 'https://www.youtube.com/watch?v=eMccPJqyg0o',
113
+ '6ix9ine, Nicki Minaj, Murda Beatz - “FEFE” (Official Music Video)' => 'https://www.youtube.com/watch?v=V_MXGdSBbAI',
114
+ 'Breaking Bad - Jesse\'s emotional speech' => 'https://www.youtube.com/watch?v=aL9aI4JPtPQ',
115
+ 'The Frames - Revelate with lyrics' => 'https://www.youtube.com/watch?v=SPC0sRQbJ98',
116
+ 'The Way I Am' => 'https://www.youtube.com/watch?v=82lB-gI-uuQ',
117
+ 'Coldplay - Fix You' => 'https://www.youtube.com/watch?v=k4V3Mo61fJM',
118
+ 'O Ri Chiraiya lyrics' => 'https://www.youtube.com/watch?v=56bdi4AJFFo',
119
+ 'Will Smith - Fresh Prince of Bel Air (Le Boeuf Remix)' => 'https://www.youtube.com/watch?v=LPvCeNxsG-w',
120
+ 'Midnight Oil - Beds Are Burning' => 'https://www.youtube.com/watch?v=ejorQVy3m8E',
121
+ 'Lenny Kravitz - Are You Gonna Go My Way' => 'https://www.youtube.com/watch?v=8LhCd1W2V0Q',
122
+ 'Yes - Owner Of A Lonely Heart (vinyl)' => 'https://www.youtube.com/watch?v=5mYMFcnOURs',
123
+ 'Toto - Africa (vinyl)' => 'https://www.youtube.com/watch?v=-M0m5mB_q0Y',
124
+ 'Bill Withers - Just The Two Of Us (Doumëa Remix ft. Kevin Cohen)' => 'https://www.youtube.com/watch?v=5mYMFcnOURs',
125
+ 'Pink Floyd - Money (master tape)' => 'https://www.youtube.com/watch?v=gmV9iX-Q754',
126
+ 'Pink Floyd - Wish You Were Here' => 'https://www.youtube.com/watch?v=IXdNnw99-Ic',
127
+ 'CHIEF KEEF - 3HUNNA / shot by @DJKENN_AON' => 'https://www.youtube.com/watch?v=QFEhJfUcD1Q',
128
+ 'Lil Boosie: We Out Chea' => 'https://www.youtube.com/watch?v=tOYnJv3ztKM',
129
+ 'John Legend All Of Me Lyrics' => 'https://www.youtube.com/watch?v=Mk7-GRWq7wA',
130
+ 'Im a trumpsta motherfucker' => 'https://www.youtube.com/watch?v=WhGsq9X1VZM',
131
+ 'Big Man Tyrone Shills Terry Davis\' TempleOS' => 'https://www.youtube.com/watch?v=HFPM-R_d44M',
132
+ 'Sam Song..... Celtic Storm' => 'https://www.youtube.com/watch?v=TjJR-fvGOXc',
133
+ 'Johnny Cash Reads The New Testament: Matthew Chapter 7' => 'https://www.youtube.com/watch?v=27TfH3hvqAQ',
134
+ 'Tina Turner - Golden Eye (HD)' => 'https://www.youtube.com/watch?v=4hGQ97tCTOs',
135
+ 'Red Hot Chili Peppers - By The Way (Lukas Grinys Remix)' => 'https://www.youtube.com/watch?v=lESwb2mU04M',
136
+ 'Avril Lavigne - I Love You' => 'https://www.youtube.com/watch?v=Q0-omvd2u1s',
137
+ 'RIGGA x DXTR - Город не спит 🔥' => 'https://www.youtube.com/watch?v=d3zQTHbEpkM',
138
+ '2017 11 26T18 46 30+00 00 171126WorshipWorkPlay' => 'https://www.youtube.com/watch?v=i-Re-PbqNRg',
139
+ 'Black Eyed Peas - Where Is The Love (BCX ft. Ellena Soule Rework)' => 'https://www.youtube.com/watch?v=0_Ro2ifLRpw',
140
+ 'Charlie Puth - Attention (D33pSoul Remix)' => 'https://www.youtube.com/watch?v=IMj7bSSOEAk',
141
+ 'Bob Marley - Three little birds(Video Oficial)(HQ)' => 'https://www.youtube.com/watch?v=4k2PJFPu57Y',
142
+ 'War veteran: "Please don\'t talk about leaving"' => 'https://www.youtube.com/watch?v=1jGnaPrjeh4',
143
+ 'Sunshine by Matisyahu Lyrics' => 'https://www.youtube.com/watch?v=xmQ2QrNnZIE',
144
+ 'Martin Garrix - Animals (Official Video)' => 'https://www.youtube.com/watch?v=gCYcHz2k5x0',
145
+ 'DVBBS & Borgeous - TSUNAMI (Original Mix)' => 'https://www.youtube.com/watch?v=0EWbonj7f18',
146
+ 'We Were Soldiers Broken Arrow' => 'https://www.youtube.com/watch?v=ctnK7wdJmAo',
147
+ '✵ Жизнь дает свое ✵ (2018)' => 'https://www.youtube.com/watch?v=Z2ozs8-W4H4',
148
+ 'Vladimir Putin Style - True Leader 2017' => 'https://www.youtube.com/watch?v=_A4MmpJV94I',
149
+ 'Survivor - Eye Of The Tiger (Rocky OST)' => 'https://www.youtube.com/watch?v=FLZS3jQPn',
150
+ 'Ноггано, AK 47 - Russian Paradise' => 'https://www.youtube.com/watch?v=Z0s1RTZUAqQ',
151
+ 'Meiko - Lights On(Mellen Gi Remix)' => 'https://www.youtube.com/watch?v=HVzL0XjdFfI',
152
+ '2Pac - Real Talk (2019)' => 'https://www.youtube.com/watch?v=_3LuY9isL_Y',
153
+ 'Девочка верна только одному..♛' => 'https://www.youtube.com/watch?v=UGmRumCtCrc',
154
+ 'Linkin Park - Numb (Areon Remix) /Chester Bennington/' => 'https://www.youtube.com/watch?v=-g29i6IOzUQ',
155
+ 'Steve Miller Band - Abracadabra (12" Version) (Vinyl)' => 'https://www.youtube.com/watch?v=YqloCj1ZNSw',
156
+ 'Gorillaz - Clint Eastwood (Godlips Remix)' => 'https://www.youtube.com/watch?v=JfJLyuXgjOc',
157
+ 'Narwhals song swimming in the ocean !' => 'https://www.youtube.com/watch?v=dP2lyc53qtI',
158
+ 'Justin Bieber - Sorry (D33pSoul Remix) /Tayler Buono Cover/' => 'https://www.youtube.com/watch?v=r5IO6ReMWXE',
159
+ 'Tupac Ft Elton John Ghetto Gospel Lyrics' => 'https://www.youtube.com/watch?v=eC3F1uZJ2jc',
160
+ 'SWAY - STILL SPEEDIN\' (With Lyrics) OUT NOW!!!!' => 'https://www.youtube.com/watch?v=tRldCYkU8nA',
161
+ 'Chief Keef is 300 years old' => 'https://www.youtube.com/watch?v=VWUg1fgYPiE',
162
+ 'DJ Fresh ft Sian Evans - \'Louder\' (Official Video)' => 'https://www.youtube.com/watch?v=eE-dwpWpscU',
163
+ '50 Cent - Realest Niggaz (ft. 2Pac & The Notorious B.I.G) 2018' => 'https://www.youtube.com/watch?v=QI_7C3dUgqw',
164
+ 'Tupac - Last Muthafucka Breathin\'' => 'https://www.youtube.com/watch?v=F3kN5x51wjE',
165
+ 'Rihanna - Work ft. Drake (Koni Remix) /Emma & Shaun Cover/' => 'https://www.youtube.com/watch?v=ipjXYtoVG-Q',
166
+ 'Money Gang - 2Pac Ft. Notorious B.I.G (HD)' => 'https://www.youtube.com/watch?v=R96NrNdAzQE',
167
+ 'MKJ - Robot /Frank Sinatra/' => 'https://www.youtube.com/watch?v=bGT1SbFW9OQ',
168
+ 'D33pSoul - La Richesse (Original Mix) "My richness is life" /Bob Marley/' => 'https://www.youtube.com/watch?v=tCXqm8EQtWQ',
169
+ 'Damo & Ivor \'Maniac 2012\' (Official Video)' => 'https://www.youtube.com/watch?v=js-Yet5kskA',
170
+ '6IX9INE "Kooda" (WSHH Exclusive - Official Music Video)' => 'https://www.youtube.com/watch?v=yz7Cn3pHibo'
171
+ }
172
+ command '🎧', '' do
173
+ key = DISCO_BISCUITS.keys.uniq.sample
174
+ _pry_.output.puts [key, DISCO_BISCUITS[key]].join("\n")
175
+ end
176
+ alias_command 'disco-biscuits', '🎧'
177
+
178
+ command '300', '' do
179
+ _pry_.output.puts 'https://www.youtube.com/watch?v=VWUg1fgYPiE'
180
+ end
181
+
182
+ command '8', '' do
183
+ _pry_.output.puts 'https://www.jesuschristsavior.net/Beatitudes.html'
184
+ end
185
+ end
@@ -15,7 +15,7 @@ class Pry::SendTweet::ReadTweets < Pry::SendTweet::BaseCommand
15
15
  'A username whose timeline you want to read.'
16
16
  o.on 'c=', 'count=',
17
17
  "The number of tweets to read. The maximum is 200, and the default is " \
18
- "#{Pry::SendTweet::DEFAULT_READ_SIZE}."
18
+ "#{default_read_size}."
19
19
  o.on 'l=', 'likes=',
20
20
  'Read tweets you or another user have liked.',
21
21
  argument: :optional
@@ -57,10 +57,10 @@ class Pry::SendTweet::ReadTweets < Pry::SendTweet::BaseCommand
57
57
  def show_likes(user:)
58
58
  if user
59
59
  user = search_str_for_users(user).first
60
- render_tweets lambda { twitter.favorites(user, count: opts['count'] || Pry::SendTweet::DEFAULT_READ_SIZE)},
60
+ render_tweets lambda { twitter.favorites(user, count: opts['count'] || default_read_size)},
61
61
  title: "#{'@'+user} likes"
62
62
  else
63
- render_tweets lambda { twitter.favorites(count: opts['count'] || Pry::SendTweet::DEFAULT_READ_SIZE) },
63
+ render_tweets lambda { twitter.favorites(count: opts['count'] || default_read_size) },
64
64
  title: "Your likes"
65
65
  end
66
66
  end
@@ -85,7 +85,7 @@ class Pry::SendTweet::ReadTweets < Pry::SendTweet::BaseCommand
85
85
  {
86
86
  tweet_mode: 'extended',
87
87
  include_rts: opts.present?('with-retweets'),
88
- count: opts.present?('count') ? opts['count'] : Pry::SendTweet::DEFAULT_READ_SIZE
88
+ count: opts.present?('count') ? opts['count'] : default_read_size
89
89
  }
90
90
  end
91
91
 
@@ -29,33 +29,36 @@ class Pry::SendTweet::SendTweet < Pry::SendTweet::BaseCommand
29
29
 
30
30
  def process(args)
31
31
  super
32
- tweet_contents = compose_tweet_with_editor
33
- create_tweet = opts.present?(:file) ? lambda { send_tweet_with_media(tweet_contents) } :
34
- lambda { send_textual_tweet(tweet_contents) }
32
+ tweet_creator = create_tweet_creator(compose_tweet_with_editor)
35
33
  if opts.present?('delay')
36
34
  time_obj, sleep_seconds = parse_duration_str(opts['delay'])
37
35
  Thread.new {
38
36
  sleep sleep_seconds
39
- create_tweet.call
37
+ tweet_creator.call
40
38
  }
41
39
  publish_time = (time_obj ? time_obj : Time.now + sleep_seconds)
42
40
  .getlocal
43
41
  .strftime(time_format)
44
42
  page_ok bold("Tweet will be published at approximately #{publish_time}.")
45
43
  else
46
- tweet = create_tweet.call
44
+ tweet = tweet_creator.call
47
45
  page_ok tweet.url
48
46
  end
49
47
  end
50
48
 
51
49
  private
52
50
 
51
+ def paths_to_twitterio(paths)
52
+ paths.map do |path|
53
+ Pry::SendTweet::TwitterIO.new File.binread(path), File.basename(path)
54
+ end
55
+ end
56
+
53
57
  def no_newline?
54
58
  opts.present?('no-newline')
55
59
  end
56
60
 
57
- def send_tweet_with_media(tweet_contents)
58
- medias = opts['file'].map{|p| File.new p, 'r'}
61
+ def send_tweet_with_media(tweet_contents, medias)
59
62
  tweet = twitter.update_with_media(tweet_contents, medias, tweet_options)
60
63
  tweet.tap {|t| self_destruct! t.id, opts['self-destruct'] }
61
64
  ensure
@@ -102,6 +105,15 @@ class Pry::SendTweet::SendTweet < Pry::SendTweet::BaseCommand
102
105
  tweet
103
106
  end
104
107
 
108
+ def create_tweet_creator(tweet_contents)
109
+ if opts.present?(:file)
110
+ medias = paths_to_twitterio(opts[:file])
111
+ lambda { send_tweet_with_media(tweet_contents, medias) }
112
+ else
113
+ lambda { send_textual_tweet(tweet_contents) }
114
+ end
115
+ end
116
+
105
117
  def validate_tweet!(tweet)
106
118
  if tweet.strip.empty?
107
119
  raise Pry::CommandError, "Can't post an empty tweet."
@@ -10,7 +10,7 @@ class Pry::SendTweet::TwitterSearch < Pry::SendTweet::BaseCommand
10
10
 
11
11
  def options(o)
12
12
  o.on 'c=', 'count=', "The number of tweets to show. Default is " \
13
- "#{Pry::SendTweet::DEFAULT_READ_SIZE}."
13
+ "#{default_read_size}."
14
14
  end
15
15
 
16
16
  def process(query)
@@ -29,7 +29,7 @@ class Pry::SendTweet::TwitterSearch < Pry::SendTweet::BaseCommand
29
29
  end
30
30
 
31
31
  private def search_options
32
- {count: opts['count'] || Pry::SendTweet::DEFAULT_READ_SIZE, tweet_mode: 'extended'}
32
+ {count: opts['count'] || default_read_size, tweet_mode: 'extended'}
33
33
  end
34
34
 
35
35
  Pry.commands.add_command self
@@ -6,9 +6,11 @@ module Pry::SendTweet::TweetRenderer
6
6
  pager = Pry::Pager::SystemPager.new(_pry_.output).tap(&:fork)
7
7
  interval = __choose_render_interval(timeout)
8
8
  timeout(interval) do
9
+ began_at, refresh_at = __find_timeout_range(interval)
10
+ rendered_title = __choose_title(title, began_at, refresh_at)
9
11
  tweets = __fetch_tweets(tweet_fetcher)
10
12
  tweets.empty? ? pager.write("No tweets to show.") :
11
- pager.write(__render_tweets(title || "Twitter", tweets))
13
+ pager.write(__render_tweets(rendered_title, tweets))
12
14
  end
13
15
  rescue Pry::Pager::StopPaging, Interrupt
14
16
  pager.fast_exit!
@@ -24,8 +26,9 @@ module Pry::SendTweet::TweetRenderer
24
26
  private
25
27
  # @api private
26
28
  def __render_tweets(title, tweets)
27
- title = bright_blue(bold((" " * 40) + title) + "\n\n")
28
- title + tweets.map.with_index {|tweet, i| __render_tweet(tweet)}.join("\n")
29
+ title + tweets.map {|tweet|
30
+ __render_tweet(tweet)
31
+ }.join("\n")
29
32
  end
30
33
 
31
34
  # @api private
@@ -42,10 +45,9 @@ module Pry::SendTweet::TweetRenderer
42
45
  def __render_tweet_title(tweet)
43
46
  user, created_at = tweet.user, tweet.created_at.getlocal
44
47
  title = [
45
- bold("@#{user.screen_name}"),
46
- time_ago_in_words(created_at),
47
- created_at.strftime(time_format)
48
- ].join bright_blue(" | ")
48
+ red("@#{user.screen_name}"),
49
+ "Around " + time_ago_in_words(created_at) + " before Last Refresh"
50
+ ].join green(" | ")
49
51
  " #{title} "
50
52
  end
51
53
 
@@ -72,12 +74,30 @@ module Pry::SendTweet::TweetRenderer
72
74
  end
73
75
  end
74
76
 
77
+ # @api private
78
+ def __choose_title(title, began_at, refresh_at)
79
+ title = bold green(title || "Twitter")
80
+ timestamps = [bold("Last Refresh: "), began_at.strftime(time_format), "\n"]
81
+ timestamps.concat [
82
+ bold("Next Refresh: "),
83
+ refresh_at.strftime(time_format),
84
+ "\n"
85
+ ] if refresh_at
86
+ title = "#{title}\n\n"
87
+ title += timestamps.join
88
+ title << "\n\n"
89
+ title
90
+ end
91
+
75
92
  # @api private
76
93
  def __choose_render_interval(timeout)
77
- if timeout == false
78
- nil
79
- else
80
- timeout || (60*5)
81
- end
94
+ return nil if timeout == false
95
+ timeout || (60*5)
96
+ end
97
+
98
+ # @api private
99
+ def __find_timeout_range(seconds)
100
+ seconds ? [Time.now.getlocal, (Time.now + seconds).getlocal] :
101
+ [Time.now.getlocal, nil]
82
102
  end
83
103
  end
@@ -0,0 +1,26 @@
1
+ #
2
+ # TwitterIO is a child of StringIO that implements an interface compatible
3
+ # with the expectations of the Twitter gem. The twitter gem expects a File object
4
+ # when uploading media, not an in-memory string as we would like.
5
+ #
6
+ class Pry::SendTweet::TwitterIO < StringIO
7
+ def initialize(str, basename)
8
+ super(str)
9
+ @basename = basename
10
+ end
11
+
12
+ def basename
13
+ @basename
14
+ end
15
+
16
+ #
17
+ # For compatibility with File.basename, which attempts String coercion when
18
+ # given an object other than a String.
19
+ #
20
+ # @example
21
+ # File.basename(twitter_io) => {TwitterIO#basename}
22
+ #
23
+ def to_str
24
+ basename
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  class Pry
2
2
  module SendTweet
3
- VERSION = '0.13.1'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -19,11 +19,13 @@ module TimeAgoInWords
19
19
  module_function
20
20
  def time_ago_in_words(time)
21
21
  time_difference = Time.now.to_i - time.to_i
22
- return "0 seconds ago" if time_difference <= 0
22
+ if time_difference <= 0
23
+ return "0 seconds since Last Refresh"
24
+ end
23
25
  unit = get_unit(time_difference)
24
26
  unit_rep = time_difference > 1 ? "#{unit.to_s.downcase}s" : unit.to_s.downcase
25
27
  unit_difference = time_difference / Units.const_get(unit.capitalize)
26
- "#{unit_difference} #{unit_rep} ago"
28
+ "#{unit_difference} #{unit_rep}"
27
29
  end
28
30
 
29
31
  private
@@ -2,12 +2,12 @@ Kernel.require_relative 'lib/pry/send_tweet/version'
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "pry-send_tweet.rb"
4
4
  spec.version = Pry::SendTweet::VERSION
5
- spec.authors = ["Robert Gleeson"]
5
+ spec.authors = ["Pry developers", "Fry developers", "trebor8"]
6
6
  spec.email = "trebor.g@protonmail.com"
7
- spec.summary = "A Twitter client for the Pry REPL."
7
+ spec.summary = "An extensible Twitter client living inside the Pry and Fry REPLs."
8
8
  spec.description = spec.summary
9
- spec.homepage = "https://github.com/r-obert/pry-send_tweet.rb"
10
- spec.licenses = ["MIT"]
9
+ spec.homepage = "https://gitlab.com/trebor8/fry-send_tweet.rb"
10
+ spec.licenses = ["BSD (3-Clause)"]
11
11
  spec.require_paths = ["lib", "lib/time-ago-in-words/lib"]
12
12
  spec.files = Dir[
13
13
  "*file",
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  "*.{txt,gemspec,md,sh}",
18
18
  "lib/**/*.{rb,gemspec,md}"
19
19
  ]
20
- spec.add_runtime_dependency "pry", "~> 0.12"
21
20
  spec.add_runtime_dependency "twitter", "~> 6.0"
22
21
  spec.add_runtime_dependency "tty-box", "= 0.3.0"
23
22
  spec.add_runtime_dependency "unicode-display_width", "~> 1.4"
metadata CHANGED
@@ -1,29 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-send_tweet.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Robert Gleeson
7
+ - Pry developers
8
+ - Fry developers
9
+ - trebor8
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2019-01-28 00:00:00.000000000 Z
13
+ date: 2019-02-15 00:00:00.000000000 Z
12
14
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: pry
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.12'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.12'
27
15
  - !ruby/object:Gem::Dependency
28
16
  name: twitter
29
17
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +54,7 @@ dependencies:
66
54
  - - "~>"
67
55
  - !ruby/object:Gem::Version
68
56
  version: '1.4'
69
- description: A Twitter client for the Pry REPL.
57
+ description: An extensible Twitter client living inside the Pry and Fry REPLs.
70
58
  email: trebor.g@protonmail.com
71
59
  executables: []
72
60
  extensions: []
@@ -74,6 +62,7 @@ extra_rdoc_files: []
74
62
  files:
75
63
  - CHANGELOG.md
76
64
  - LICENSE.txt
65
+ - PRY_LICENSE.txt
77
66
  - README.md
78
67
  - Vagrantfile
79
68
  - art/44-e44743a5bb.jpg
@@ -81,6 +70,7 @@ files:
81
70
  - lib/pry-send_tweet.rb
82
71
  - lib/pry/pager/system_pager.rb
83
72
  - lib/pry/send_tweet/commands/base_command.rb
73
+ - lib/pry/send_tweet/commands/easter_eggs.rb
84
74
  - lib/pry/send_tweet/commands/paging/paging_support.rb
85
75
  - lib/pry/send_tweet/commands/read_tweets.rb
86
76
  - lib/pry/send_tweet/commands/read_tweets/translate_actions.rb
@@ -96,6 +86,7 @@ files:
96
86
  - lib/pry/send_tweet/renderers/tweet_renderer.rb
97
87
  - lib/pry/send_tweet/renderers/user_renderer.rb
98
88
  - lib/pry/send_tweet/tty-box.rb
89
+ - lib/pry/send_tweet/twitter_io.rb
99
90
  - lib/pry/send_tweet/version.rb
100
91
  - lib/time-ago-in-words/README.md
101
92
  - lib/time-ago-in-words/lib/time-ago-in-words.rb
@@ -104,9 +95,9 @@ files:
104
95
  - samples/freebsd-zshrc
105
96
  - samples/tmuxinator-vagrant.yml
106
97
  - vms/freebsd.rb
107
- homepage: https://github.com/r-obert/pry-send_tweet.rb
98
+ homepage: https://gitlab.com/trebor8/fry-send_tweet.rb
108
99
  licenses:
109
- - MIT
100
+ - BSD (3-Clause)
110
101
  metadata: {}
111
102
  post_install_message:
112
103
  rdoc_options: []
@@ -128,5 +119,5 @@ rubyforge_project:
128
119
  rubygems_version: 2.7.8
129
120
  signing_key:
130
121
  specification_version: 4
131
- summary: A Twitter client for the Pry REPL.
122
+ summary: An extensible Twitter client living inside the Pry and Fry REPLs.
132
123
  test_files: []