pry-emoji 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +58 -7
- data/lib/pry-emoji.rb +83 -55
- data/lib/pry-emoji/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2134d491fbe1e4616303ea0e97aab193b20851d5
|
4
|
+
data.tar.gz: d643ff1d3d37f86fce1bc72626efb6f390d6f087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d5a462f698835aa7d86724ac546fcf404cda450ed1104f08348ee5e6bb2f940fe38c541ca454a865ee5b5e5894beed3d88ac61932f6ef462b732523623475f
|
7
|
+
data.tar.gz: f3d7b7bb836bd438d448f3688f0f05b2443723a45cd7d89c29109a1be82973ec678891076bc0838c5f6769739cf302c978e3f4f04a196c16f606ea5a27c97c11
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,34 +1,85 @@
|
|
1
1
|
pry-emoji
|
2
2
|
===========
|
3
3
|
|
4
|
-
Clutter up your shell with some emoji.
|
4
|
+
Clutter up your shell with some emoji. Why not? You already have all that pry crap mucking everything up.
|
5
5
|
|
6
6
|
|
7
7
|
Usage
|
8
8
|
--------
|
9
9
|
|
10
|
+
add `pry-emoji` to your gemfile
|
11
|
+
|
12
|
+
group :development do
|
13
|
+
gem 'pry-emoji'
|
14
|
+
end
|
15
|
+
|
10
16
|
set your `Pry.config.prompt` customization setting to use the `pry-emoji` prompt in your `.pryrc` file, or wherever you do your customization
|
11
17
|
|
12
18
|
Pry.config.prompt = PryEmoji::Prompt.new
|
13
19
|
|
14
20
|
|
21
|
+
Configuration
|
22
|
+
--------
|
23
|
+
|
24
|
+
use some different emoji, because some jerks are offended when the two men holding hands or the beer emoji appears in their console
|
25
|
+
|
26
|
+
Pry.config.prompt = PryEmoji::Prompt.new(emoji: %i[roll_eyes middle_finger -1 ng])
|
27
|
+
|
28
|
+
|
15
29
|
Games
|
16
30
|
--------
|
17
31
|
|
18
|
-
play a game with `pry-emoji`, because working in the console is boring and a bunch of extraneous characters all over the place is certain to not be disruptive.
|
32
|
+
play a game with `pry-emoji`, because working in the console is boring and a bunch of extraneous characters all over the place is certain to not be disruptive. You should know, you're already using pry.
|
19
33
|
|
20
34
|
Pry.config.prompt = PryEmoji::Prompt.slots
|
21
35
|
|
22
36
|
Pry.config.prompt = PryEmoji::Prompt.match
|
23
37
|
|
24
38
|
|
25
|
-
|
26
|
-
|
39
|
+
faq
|
40
|
+
===========
|
27
41
|
|
28
|
-
|
42
|
+
### My console announced I was a winner, please explain
|
29
43
|
|
44
|
+
You're not.
|
30
45
|
|
31
|
-
|
32
|
-
|
46
|
+
|
47
|
+
### This gem is fantastic! When can I expect new games to be added?
|
48
|
+
|
49
|
+
Idk. Never? Tomorrow? Don't hold your breath. Or do. Whatever floats your boat.
|
50
|
+
|
51
|
+
|
52
|
+
### How can I add even more emoji to my console? I know Pry already makes everything less readable, but I don't think it goes too far enough.
|
53
|
+
|
54
|
+
Great question! I'll work on adding some more options to accommodate your masochistic desires.
|
55
|
+
|
56
|
+
|
57
|
+
### Can I use this gem in production?
|
58
|
+
|
59
|
+
My production configuration uses only the `racing_car` emoji.
|
60
|
+
|
61
|
+
|
62
|
+
### This gem isn't fun at all
|
63
|
+
|
64
|
+
You will never be happy if you continue to search for what happiness consists of. You will never live if you are looking for the meaning of life.
|
65
|
+
|
66
|
+
|
67
|
+
### Everything is broken
|
68
|
+
|
69
|
+
I think I fixed that now.
|
70
|
+
|
71
|
+
|
72
|
+
### Your gem is stupid
|
33
73
|
|
34
74
|
Alright.
|
75
|
+
|
76
|
+
|
77
|
+
### Stop making fun of Pry
|
78
|
+
|
79
|
+
As soon as it stops sucking.
|
80
|
+
|
81
|
+
|
82
|
+
### A different question
|
83
|
+
|
84
|
+
No, you.
|
85
|
+
|
data/lib/pry-emoji.rb
CHANGED
@@ -4,20 +4,25 @@ require 'emoji'
|
|
4
4
|
module PryEmoji
|
5
5
|
module PromptConfig
|
6
6
|
class Base
|
7
|
-
attr_accessor :config
|
8
|
-
attr_accessor :emoji
|
9
|
-
attr_accessor :emoji_array
|
10
|
-
attr_accessor :title
|
7
|
+
attr_accessor :config, :emoji, :title
|
11
8
|
|
12
9
|
def initialize(config)
|
13
10
|
@config = config
|
14
|
-
@emoji_array = PryEmoji::Config.emoji_array
|
15
11
|
@title = 'irb'
|
16
12
|
randomize_emoji
|
17
13
|
end
|
18
|
-
|
14
|
+
|
15
|
+
def emoji_array
|
16
|
+
config.emoji_array
|
17
|
+
end
|
18
|
+
|
19
19
|
def randomize_emoji
|
20
|
-
@emoji =
|
20
|
+
@emoji = random_emoji
|
21
|
+
end
|
22
|
+
|
23
|
+
def random_emoji(advantage = [])
|
24
|
+
advantage_emoji_array = emoji_array + Array(advantage)
|
25
|
+
advantage_emoji_array.shuffle[Random.rand(advantage_emoji_array.length)]
|
21
26
|
end
|
22
27
|
|
23
28
|
def line_number(pry)
|
@@ -33,22 +38,41 @@ module PryEmoji
|
|
33
38
|
"#{title} #{print_emoji} > "
|
34
39
|
end
|
35
40
|
|
36
|
-
def
|
37
|
-
|
41
|
+
def print_emoji
|
42
|
+
emoji.raw.strip
|
38
43
|
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Game < Base
|
47
|
+
attr_accessor :advantage, :winner_emoji
|
39
48
|
|
40
|
-
def
|
41
|
-
|
49
|
+
def initialize(config)
|
50
|
+
@winner_emoji = :boom
|
51
|
+
super(config)
|
42
52
|
end
|
43
53
|
|
44
|
-
def
|
45
|
-
|
54
|
+
def randomize_emoji
|
55
|
+
announce_winner if winner?
|
56
|
+
end
|
57
|
+
|
58
|
+
def announce_winner
|
59
|
+
puts "\033[1L\033[34m\033[1m #{print_winner_emoji} WINNER #{print_winner_message} WINNER #{print_winner_emoji}\033[0m\033[39m"
|
60
|
+
end
|
61
|
+
|
62
|
+
def winner?
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
66
|
+
def print_winner_message
|
67
|
+
print_emoji
|
68
|
+
end
|
69
|
+
|
70
|
+
def print_winner_emoji
|
71
|
+
::Emoji.find_by_alias(winner_emoji.to_s).raw.strip
|
46
72
|
end
|
47
73
|
end
|
48
|
-
|
49
|
-
class Slots <
|
50
|
-
# include PryEmoji::PromptConfig::Game
|
51
|
-
attr_accessor :advantage
|
74
|
+
|
75
|
+
class Slots < Game
|
52
76
|
attr_accessor :slot_size
|
53
77
|
|
54
78
|
def initialize(config)
|
@@ -56,24 +80,23 @@ module PryEmoji
|
|
56
80
|
@advantage = 4
|
57
81
|
super(config)
|
58
82
|
end
|
59
|
-
|
83
|
+
|
60
84
|
def randomize_emoji
|
61
|
-
@emoji = slot_size.times.inject([]) { |a| a <<
|
62
|
-
|
85
|
+
@emoji = slot_size.times.inject([]) { |a| a << random_emoji(a*advantage) }
|
86
|
+
super
|
63
87
|
end
|
64
|
-
|
65
|
-
def
|
66
|
-
|
88
|
+
|
89
|
+
def print_emoji
|
90
|
+
"|#{emoji.collect{ |e| e.raw.strip }.join('|')}|"
|
67
91
|
end
|
68
92
|
|
69
|
-
def
|
70
|
-
|
93
|
+
def winner?
|
94
|
+
emoji.length > 1 && emoji.uniq.length == 1
|
71
95
|
end
|
72
96
|
end
|
73
97
|
|
74
|
-
class Match <
|
75
|
-
|
76
|
-
attr_accessor :advantage
|
98
|
+
class Match < Game
|
99
|
+
attr_accessor :last_emoji
|
77
100
|
|
78
101
|
def initialize(config)
|
79
102
|
@advantage = 10
|
@@ -81,41 +104,44 @@ module PryEmoji
|
|
81
104
|
end
|
82
105
|
|
83
106
|
def randomize_emoji
|
84
|
-
@
|
107
|
+
@last_emoji = emoji
|
108
|
+
@emoji = random_emoji
|
109
|
+
super
|
85
110
|
end
|
86
|
-
end
|
87
111
|
|
88
|
-
|
89
|
-
|
112
|
+
def winner?
|
113
|
+
last_emoji == emoji
|
114
|
+
end
|
90
115
|
end
|
91
116
|
end
|
92
117
|
|
93
118
|
class Prompt < Array
|
94
119
|
cattr_accessor(:types) { PryEmoji::PromptConfig.constants.select{ |constant| PryEmoji::PromptConfig.const_get(constant).is_a? Class } }
|
95
120
|
|
96
|
-
def initialize(type = :base)
|
97
|
-
super(PryEmoji::Config.new(type).prompt)
|
121
|
+
def initialize(type = :base, configuration = nil)
|
122
|
+
super(PryEmoji::Config.new(type, configuration).prompt)
|
98
123
|
end
|
99
124
|
|
100
125
|
def self.method_missing(method_id, *arguments, &block)
|
101
|
-
self.new(normalize_type(method_id))
|
126
|
+
self.new(normalize_type(method_id), *arguments)
|
102
127
|
end
|
103
128
|
|
104
129
|
private
|
105
130
|
|
106
131
|
def self.normalize_type(type)
|
107
|
-
play_type = type.to_s.titleize.to_sym
|
108
|
-
puts "I don't know how to play #{type}"
|
109
|
-
|
132
|
+
play_type = (types & Array(type.to_s.titleize.to_sym)).first
|
133
|
+
puts "I don't know how to play #{type}" unless play_type
|
134
|
+
play_type || :base
|
110
135
|
end
|
111
136
|
end
|
112
137
|
|
113
138
|
class Config
|
114
|
-
|
115
|
-
|
116
|
-
|
139
|
+
attr_accessor :prompt_config, :prompt, :configuration
|
140
|
+
|
141
|
+
def initialize(prompt = :base, configuration = nil)
|
142
|
+
@configuration = Hash(configuration).with_indifferent_access
|
143
|
+
%i[emoji].each { |option| parse_configuration_option(option) }
|
117
144
|
|
118
|
-
def initialize(prompt = :base)
|
119
145
|
@prompt_config = PromptConfig.const_get(prompt.to_s.titleize.to_sym).new(self)
|
120
146
|
@prompt = [
|
121
147
|
proc { |obj, nest_level, pry| prompt_config.prompt(obj, nest_level, pry) },
|
@@ -124,21 +150,23 @@ module PryEmoji
|
|
124
150
|
# Pry.config.prompt = prompt
|
125
151
|
end
|
126
152
|
|
127
|
-
def
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
announce_winner(([print_emoji(emoji)]*3).join(' ')) if mode == 'match' && emoji_array.length > 1 && emoji == current_emoji
|
135
|
-
end
|
136
|
-
self.current_emoji = emoji
|
153
|
+
def emoji
|
154
|
+
@emoji ||= %i[octopus blowfish space_invader skull smiling_imp imp smile_cat joy_cat heart_eyes_cat pouting_cat scream_cat cherry_blossom blossom mushroom bird penguin hatching_chick hatched_chick cat dragon snake tomato eggplant grapes watermelon tangerine lemon apple green_apple pear peach cherries strawberry pizza ramen oden dango fish_cake beer tea cake musical_note pill beginner diamond_shape_with_a_dot_inside bomb poop sushi]
|
155
|
+
end
|
156
|
+
|
157
|
+
def emoji=(emoji)
|
158
|
+
@emoji_array = nil
|
159
|
+
@emoji = Array(emoji)
|
137
160
|
end
|
138
161
|
|
139
|
-
def
|
140
|
-
|
141
|
-
|
162
|
+
def emoji_array
|
163
|
+
@emoji_array ||= emoji.collect { |e| ::Emoji.find_by_alias(e.to_s) }
|
164
|
+
end
|
165
|
+
|
166
|
+
private
|
167
|
+
|
168
|
+
def parse_configuration_option(option)
|
169
|
+
self.instance_variable_set(:"@#{option}", configuration[option]) if configuration.include?(option)
|
142
170
|
end
|
143
171
|
end
|
144
172
|
end
|
data/lib/pry-emoji/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-emoji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chaunce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.6.14
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Clutter up your shell with some emoji.
|