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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d171518d7d84b68d4570bed7a8c59d6b83e8a0c8
4
- data.tar.gz: a1a18a37fbef6b2ad26ebd8d6e1f1cd2135257dc
3
+ metadata.gz: 2134d491fbe1e4616303ea0e97aab193b20851d5
4
+ data.tar.gz: d643ff1d3d37f86fce1bc72626efb6f390d6f087
5
5
  SHA512:
6
- metadata.gz: b00c90ee5ceb26004929b1adc5dba1e25b45ebc1fcd951948718a154415408922151ed93110db1c5535f55573e8741e05d6567a28db801124b079b5be533e00a
7
- data.tar.gz: 34d060036c594eccc28edb6b27ab92f12a710ec55c346c8240b8ab04c75cfc6e0b5318b45c0d85e82e4ee72bd808557aa48d877867f7c5406b5993715a44573b
6
+ metadata.gz: 25d5a462f698835aa7d86724ac546fcf404cda450ed1104f08348ee5e6bb2f940fe38c541ca454a865ee5b5e5894beed3d88ac61932f6ef462b732523623475f
7
+ data.tar.gz: f3d7b7bb836bd438d448f3688f0f05b2443723a45cd7d89c29109a1be82973ec678891076bc0838c5f6769739cf302c978e3f4f04a196c16f606ea5a27c97c11
@@ -1,3 +1,7 @@
1
+ ## 0.0.2 (2018-06-28)
2
+
3
+ * Some updates. Maybe it works now
4
+
1
5
  ## 0.0.1 (2015-05-05)
2
6
 
3
7
  * Initial release
data/README.md CHANGED
@@ -1,34 +1,85 @@
1
1
  pry-emoji
2
2
  ===========
3
3
 
4
- Clutter up your shell with some emoji. Why not? You already have all that pry crap mucking everything up.
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. You should know, you're already using pry.
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
- Everything is broken
26
- --------
39
+ faq
40
+ ===========
27
41
 
28
- Yep. I'm working on it.
42
+ ### My console announced I was a winner, please explain
29
43
 
44
+ You're not.
30
45
 
31
- Your gem is stupid
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
+
@@ -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 = emoji_array[Random.rand(emoji_array.length)]
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 emoji_string(use_last = false)
37
- print_emoji(use_last ? current_emoji : new_emoji)
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 announce_winner(message)
41
- puts "\033[1L\033[34m\033[1m #{::Emoji.find_by_alias('boom').raw} WINNER #{message} WINNER #{::Emoji.find_by_alias('boom').raw}\033[0m\033[39m"
49
+ def initialize(config)
50
+ @winner_emoji = :boom
51
+ super(config)
42
52
  end
43
53
 
44
- def print_emoji
45
- "#{emoji.raw} "
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 < Base
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 << one_random_emoji_with_advantage(a*advantage) }
62
- # announce_winner(print_emoji(emoji).strip) if emoji_array.length > 1 && emoji.uniq.length == 1
85
+ @emoji = slot_size.times.inject([]) { |a| a << random_emoji(a*advantage) }
86
+ super
63
87
  end
64
-
65
- def one_random_emoji_with_advantage_array(advantage_array)
66
- (emoji_array + emoji.*(advantage).split(//))[Random.rand(random_emoji_array.length + advantage)]
88
+
89
+ def print_emoji
90
+ "|#{emoji.collect{ |e| e.raw.strip }.join('|')}|"
67
91
  end
68
92
 
69
- def print_emoji(emoji)
70
- "|#{emoji.raw.join(' |')} |"
93
+ def winner?
94
+ emoji.length > 1 && emoji.uniq.length == 1
71
95
  end
72
96
  end
73
97
 
74
- class Match < Base
75
- # include PryEmoji::PromptConfig::Game
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
- @emoji = (emoji_array + emoji.*(advantage).split(//))[Random.rand(random_emoji_array.length + advantage)]
107
+ @last_emoji = emoji
108
+ @emoji = random_emoji
109
+ super
85
110
  end
86
- end
87
111
 
88
- module Game
89
- attr_accessor :advantage
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}" if (types & [play_type]).none?
109
- (types & [play_type]).first || :base
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
- cattr_accessor(:emoji_array) { ['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', 'recycle', 'bomb', 'poop', 'sushi'].collect{ |a| ::Emoji.find_by_alias(a) } }
115
- attr_accessor :prompt_config
116
- attr_accessor :prompt
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 new_emoji(play = true)
128
- case mode
129
- when 'slots'
130
- emoji = 3.times.inject([]) { |a| a << random_emoji(a*4) }
131
- announce_winner(print_emoji(emoji).strip) if emoji_array.length > 1 && emoji.uniq.length == 1
132
- when 'match', 'standard'
133
- emoji = random_emoji
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 random_emoji(advantage = [])
140
- random_emoji_array = emoji_array + advantage
141
- emoji = random_emoji_array[Random.rand(random_emoji_array.length)]
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
@@ -1,3 +1,3 @@
1
1
  module PryEmoji
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
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: 2015-06-03 00:00:00.000000000 Z
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.2.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.