pry-emoji 0.0.1
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 +7 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/pry-emoji.rb +144 -0
- data/lib/pry-emoji/cli.rb +1 -0
- data/lib/pry-emoji/version.rb +3 -0
- data/pry-emoji.gemspec +23 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d171518d7d84b68d4570bed7a8c59d6b83e8a0c8
|
4
|
+
data.tar.gz: a1a18a37fbef6b2ad26ebd8d6e1f1cd2135257dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b00c90ee5ceb26004929b1adc5dba1e25b45ebc1fcd951948718a154415408922151ed93110db1c5535f55573e8741e05d6567a28db801124b079b5be533e00a
|
7
|
+
data.tar.gz: 34d060036c594eccc28edb6b27ab92f12a710ec55c346c8240b8ab04c75cfc6e0b5318b45c0d85e82e4ee72bd808557aa48d877867f7c5406b5993715a44573b
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 by chaunce
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
pry-emoji
|
2
|
+
===========
|
3
|
+
|
4
|
+
Clutter up your shell with some emoji. Why not? You already have all that pry crap mucking everything up.
|
5
|
+
|
6
|
+
|
7
|
+
Usage
|
8
|
+
--------
|
9
|
+
|
10
|
+
set your `Pry.config.prompt` customization setting to use the `pry-emoji` prompt in your `.pryrc` file, or wherever you do your customization
|
11
|
+
|
12
|
+
Pry.config.prompt = PryEmoji::Prompt.new
|
13
|
+
|
14
|
+
|
15
|
+
Games
|
16
|
+
--------
|
17
|
+
|
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.
|
19
|
+
|
20
|
+
Pry.config.prompt = PryEmoji::Prompt.slots
|
21
|
+
|
22
|
+
Pry.config.prompt = PryEmoji::Prompt.match
|
23
|
+
|
24
|
+
|
25
|
+
Everything is broken
|
26
|
+
--------
|
27
|
+
|
28
|
+
Yep. I'm working on it.
|
29
|
+
|
30
|
+
|
31
|
+
Your gem is stupid
|
32
|
+
--------
|
33
|
+
|
34
|
+
Alright.
|
data/Rakefile
ADDED
data/lib/pry-emoji.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'pry-emoji/version'
|
2
|
+
require 'emoji'
|
3
|
+
|
4
|
+
module PryEmoji
|
5
|
+
module PromptConfig
|
6
|
+
class Base
|
7
|
+
attr_accessor :config
|
8
|
+
attr_accessor :emoji
|
9
|
+
attr_accessor :emoji_array
|
10
|
+
attr_accessor :title
|
11
|
+
|
12
|
+
def initialize(config)
|
13
|
+
@config = config
|
14
|
+
@emoji_array = PryEmoji::Config.emoji_array
|
15
|
+
@title = 'irb'
|
16
|
+
randomize_emoji
|
17
|
+
end
|
18
|
+
|
19
|
+
def randomize_emoji
|
20
|
+
@emoji = emoji_array[Random.rand(emoji_array.length)]
|
21
|
+
end
|
22
|
+
|
23
|
+
def line_number(pry)
|
24
|
+
# config.pry.input_array.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def indent(obj, nest_level, pry)
|
28
|
+
"#{' ' * title.length} #{print_emoji} | "
|
29
|
+
end
|
30
|
+
|
31
|
+
def prompt(obj, nest_level, pry)
|
32
|
+
randomize_emoji
|
33
|
+
"#{title} #{print_emoji} > "
|
34
|
+
end
|
35
|
+
|
36
|
+
def emoji_string(use_last = false)
|
37
|
+
print_emoji(use_last ? current_emoji : new_emoji)
|
38
|
+
end
|
39
|
+
|
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"
|
42
|
+
end
|
43
|
+
|
44
|
+
def print_emoji
|
45
|
+
"#{emoji.raw} "
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Slots < Base
|
50
|
+
# include PryEmoji::PromptConfig::Game
|
51
|
+
attr_accessor :advantage
|
52
|
+
attr_accessor :slot_size
|
53
|
+
|
54
|
+
def initialize(config)
|
55
|
+
@slot_size = 3
|
56
|
+
@advantage = 4
|
57
|
+
super(config)
|
58
|
+
end
|
59
|
+
|
60
|
+
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
|
63
|
+
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)]
|
67
|
+
end
|
68
|
+
|
69
|
+
def print_emoji(emoji)
|
70
|
+
"|#{emoji.raw.join(' |')} |"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Match < Base
|
75
|
+
# include PryEmoji::PromptConfig::Game
|
76
|
+
attr_accessor :advantage
|
77
|
+
|
78
|
+
def initialize(config)
|
79
|
+
@advantage = 10
|
80
|
+
super(config)
|
81
|
+
end
|
82
|
+
|
83
|
+
def randomize_emoji
|
84
|
+
@emoji = (emoji_array + emoji.*(advantage).split(//))[Random.rand(random_emoji_array.length + advantage)]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
module Game
|
89
|
+
attr_accessor :advantage
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class Prompt < Array
|
94
|
+
cattr_accessor(:types) { PryEmoji::PromptConfig.constants.select{ |constant| PryEmoji::PromptConfig.const_get(constant).is_a? Class } }
|
95
|
+
|
96
|
+
def initialize(type = :base)
|
97
|
+
super(PryEmoji::Config.new(type).prompt)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.method_missing(method_id, *arguments, &block)
|
101
|
+
self.new(normalize_type(method_id))
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
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
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
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
|
117
|
+
|
118
|
+
def initialize(prompt = :base)
|
119
|
+
@prompt_config = PromptConfig.const_get(prompt.to_s.titleize.to_sym).new(self)
|
120
|
+
@prompt = [
|
121
|
+
proc { |obj, nest_level, pry| prompt_config.prompt(obj, nest_level, pry) },
|
122
|
+
proc { |obj, nest_level, pry| prompt_config.indent(obj, nest_level, pry) }
|
123
|
+
]
|
124
|
+
# Pry.config.prompt = prompt
|
125
|
+
end
|
126
|
+
|
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
|
137
|
+
end
|
138
|
+
|
139
|
+
def random_emoji(advantage = [])
|
140
|
+
random_emoji_array = emoji_array + advantage
|
141
|
+
emoji = random_emoji_array[Random.rand(random_emoji_array.length)]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'pry-emoji'
|
data/pry-emoji.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/pry-emoji/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'pry-emoji'
|
7
|
+
gem.version = PryEmoji::VERSION
|
8
|
+
gem.author = 'chaunce'
|
9
|
+
gem.email = 'chaunce.slc@gmail.com'
|
10
|
+
gem.license = 'MIT'
|
11
|
+
gem.homepage = 'https://github.com/chaunce/pry-emoji'
|
12
|
+
gem.summary = 'Clutter up your shell with some emoji.'
|
13
|
+
gem.description = "Clutter up your shell with some emoji. Why not? You already have all that pry crap mucking everything up."
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# Dependencies
|
20
|
+
gem.required_ruby_version = '>= 1.8.7'
|
21
|
+
gem.add_runtime_dependency 'pry'
|
22
|
+
gem.add_runtime_dependency 'gemoji'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-emoji
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chaunce
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
|
+
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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gemoji
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Clutter up your shell with some emoji. Why not? You already have all
|
42
|
+
that pry crap mucking everything up.
|
43
|
+
email: chaunce.slc@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/pry-emoji.rb
|
54
|
+
- lib/pry-emoji/cli.rb
|
55
|
+
- lib/pry-emoji/version.rb
|
56
|
+
- pry-emoji.gemspec
|
57
|
+
homepage: https://github.com/chaunce/pry-emoji
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.7
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Clutter up your shell with some emoji.
|
81
|
+
test_files: []
|