priscilla 0.0.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
  SHA1:
3
- metadata.gz: 2a5cce59a7dc7bf7419147704a5be9de5ca419cc
4
- data.tar.gz: c253d820579c8623962923d45d1adf8bd11c02b6
3
+ metadata.gz: 7a52af6acd6213eead9ab9d0581b19af86381905
4
+ data.tar.gz: 42ea159fc75993795fa444a3c6c3333ce936751b
5
5
  SHA512:
6
- metadata.gz: 608f35c0a914ca795414d3203b4271f361792735e936af124ae38512e9a00dd99d47cf993488a1b9a92259cfc47012b800fe86d0772e6b162556ce210e159358
7
- data.tar.gz: f44d2a52cbba062e64f170cf67bf8789b93aaf3538d154964fb0a9caad0ec2dc2846f859b46b1178b1d0935f80a10b6eb4713aab2b20d8837c50fd7370b3ebfd
6
+ metadata.gz: 55fa690da61390f5218daa78dea194489fd47f3e4f0d44e12a88a64765a0e98d95f36e0490b0eafae831bfa57fa96762104a396d8f41727fd5549e6167793684
7
+ data.tar.gz: c7daa595dac5813bb9e4f895b29034291c8591ce7eec7f0bea21f2e38947c0ac9c285dfe1120a2fe1493a7934214aeb5818a821c08c367a69f4bf50cef1fa218
data/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # Priscilla
2
2
 
3
- TODO: Write a gem description
3
+ Frock up your console messages. :dancer: :dancer: :dancer:
4
4
 
5
- ## Installation
5
+ ## Why Priscilla
6
+
7
+ Because of Priscilla, Queen of the Desert. Don't let your console messages drown
8
+ in a wall of text, make them stand out!
9
+
10
+ ![Tutorial](images/priscilla.gif)
11
+
12
+ ## Install
6
13
 
7
14
  Add this line to your application's Gemfile:
8
15
 
@@ -16,13 +23,55 @@ Or install it yourself as:
16
23
 
17
24
  $ gem install priscilla
18
25
 
19
- ## Usage
26
+ ## Use
27
+
28
+ Require the gem:
29
+
30
+ require 'priscilla'
31
+
32
+ Use `pr` to frock up your console messages
33
+
34
+ pr "A cock in a frock on a rock"
35
+
36
+ Result
37
+
38
+ ![Result](images/result.png)
39
+
40
+ ## Decorators
41
+
42
+ Priscilla supports a lot of different decorators:
43
+
44
+ **Strings**
45
+
46
+ ![Strings](images/strings.png)
47
+
48
+ **Colored Strings**
49
+
50
+ ![Colored Strings](images/colored_strings.png)
51
+ ![Colored Strings, part 2](images/colored_strings_two.png)
52
+
53
+ **Unicode Emojis**
54
+
55
+ ![Unicode Emojis](images/unicode_emojis.rb)
56
+
57
+ **Text Emojis**
58
+
59
+ ![Text Emojis](images/text_emojis.rb)
60
+
61
+ ## Configure
62
+
63
+ If you're using rails create an initializer in `config/initializers/priscilla.rb`:
20
64
 
21
- TODO: Write usage instructions here
65
+ ```ruby
66
+ Priscilla.configure do |c|
67
+ c.width = 80 # default
68
+ c.decorator = ':dancer: ' # default
69
+ end
70
+ ```
22
71
 
23
- ## Contributing
72
+ ## Contribute
24
73
 
25
- 1. Fork it ( http://github.com/<my-github-username>/priscilla/fork )
74
+ 1. Fork it ( http://github.com/Arkham/priscilla/fork )
26
75
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
76
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
77
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/priscilla.rb CHANGED
@@ -1,8 +1,19 @@
1
1
  require 'colorize'
2
2
 
3
- require "priscilla/version"
4
- require "priscilla/configuration"
5
- require "priscilla/makeup"
3
+ require 'priscilla/version'
4
+ require 'priscilla/simple_emoji'
5
+ require 'priscilla/configuration'
6
+ require 'priscilla/makeup'
7
+
8
+ module Priscilla
9
+ def self.configuration
10
+ @configuration ||= Configuration.new
11
+ end
12
+
13
+ def self.configure
14
+ yield(configuration)
15
+ end
16
+ end
6
17
 
7
18
  module Kernel
8
19
  def pr(message, **options)
@@ -1,21 +1,24 @@
1
1
  module Priscilla
2
- def self.configuration
3
- @configuration ||= Configuration.new
4
- end
5
-
6
- def self.configure
7
- yield(configuration)
8
- end
9
-
10
2
  class Configuration
11
3
  DEFAULT_WIDTH = 80
12
- DEFAULT_DECORATOR = "⚡ ".on_blue
4
+ DEFAULT_DECORATOR = ':dancer: '
13
5
 
14
6
  attr_accessor :width, :decorator
15
7
 
16
8
  def initialize
17
- @width = DEFAULT_WIDTH
18
- @decorator = DEFAULT_DECORATOR
9
+ self.width = DEFAULT_WIDTH
10
+ self.decorator = DEFAULT_DECORATOR
11
+ end
12
+
13
+ def decorator=(value)
14
+ @decorator = emojify(value)
15
+ end
16
+
17
+ private
18
+
19
+ def emojify(value)
20
+ value = ":#{value}: " if value.is_a? Symbol
21
+ SimpleEmoji.convert(value)
19
22
  end
20
23
  end
21
24
  end
@@ -13,7 +13,7 @@ module Priscilla
13
13
  def decorate(message, **options)
14
14
  override_config(options)
15
15
  message = message.to_s
16
- [ decorated_line, decorate_message(message), decorated_line ].join("\n")
16
+ [decorated_line, decorate_message(message), decorated_line].join("\n")
17
17
  end
18
18
 
19
19
  private
@@ -31,16 +31,16 @@ module Priscilla
31
31
  end
32
32
 
33
33
  def decoratable?(message)
34
- minimum_decorated_length(message) <= decoratable_width
34
+ min_decorated_length(message) <= decoratable_width
35
35
  end
36
36
 
37
- def minimum_decorated_length(message)
37
+ def min_decorated_length(message)
38
38
  # add two decorators and two wrapping spaces
39
39
  message.length + (decorator_length * 2) + 2
40
40
  end
41
41
 
42
42
  def message_template(message)
43
- padding = space_for(decoratable_width - minimum_decorated_length(message))
43
+ padding = space_for(decoratable_width - min_decorated_length(message))
44
44
  "#{decorator} #{message} #{padding}#{decorator}"
45
45
  end
46
46
 
@@ -0,0 +1,9 @@
1
+ require 'rumoji'
2
+
3
+ class SimpleEmoji
4
+ class << self
5
+ def convert(string)
6
+ Rumoji.decode(string)
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Priscilla
2
- VERSION = "0.0.1"
2
+ VERSION = '1.0.0'
3
3
  end
data/priscilla.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Priscilla::VERSION
9
9
  spec.authors = ["Ju Liu"]
10
10
  spec.email = ["ju.liu@welaika.com"]
11
- spec.summary = %q{Frock up your messages}
12
- spec.description = %q{Make your messages stand out from the crowd}
11
+ spec.summary = %q{Frock up your console messages}
12
+ spec.description = %q{Don't let your console messages drown in a wall of text, make them stand out}
13
13
  spec.homepage = "http://github.com/Arkham/priscilla"
14
14
  spec.license = "MIT"
15
15
 
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "colorize", "~> 0.7"
22
+ spec.add_dependency "rumoji", "~> 0.3"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.5"
24
25
  spec.add_development_dependency "rake", "~> 10.1"
@@ -1,20 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Priscilla do
4
- describe "::configure" do
5
- before do
4
+ describe '::configure' do
5
+ it 'allows to configure options' do
6
6
  Priscilla.configure do |c|
7
7
  c.width = 5
8
- c.decorator = "*"
8
+ c.decorator = '*'
9
9
  end
10
- end
11
10
 
12
- it "allows to configure options" do
13
- expect(capture_stdout { pr("1") }).to eq(
11
+ expect(capture_stdout { pr('∆') }).to eq(
14
12
  "*****\n" +
15
- "* 1 *\n" +
13
+ "* *\n" +
16
14
  "*****\n\n"
17
15
  )
18
16
  end
17
+
18
+ context "emoji" do
19
+ it 'converts decorator symbols to emoji' do
20
+ Priscilla.configure do |c|
21
+ c.width = 8
22
+ c.decorator = :zap
23
+ end
24
+
25
+ expect(capture_stdout { pr(':)') }).to eq(
26
+ "⚡ ⚡ ⚡ ⚡ \n" +
27
+ "⚡ :) ⚡ \n" +
28
+ "⚡ ⚡ ⚡ ⚡ \n\n"
29
+ )
30
+ end
31
+
32
+ it 'converts emoji within strings' do
33
+ Priscilla.configure do |c|
34
+ c.width = 24
35
+ c.decorator = ':zap: :dancer: :no_good: :frog: '
36
+ end
37
+
38
+ expect(capture_stdout { pr("DO IT") }).to eq(
39
+ "⚡ 💃 🙅 🐸 ⚡ 💃 🙅 🐸 ⚡ 💃 🙅 🐸 \n" +
40
+ "⚡ 💃 🙅 🐸 DO IT ⚡ 💃 🙅 🐸 \n" +
41
+ "⚡ 💃 🙅 🐸 ⚡ 💃 🙅 🐸 ⚡ 💃 🙅 🐸 \n\n"
42
+ )
43
+ end
44
+ end
19
45
  end
20
46
  end
@@ -6,12 +6,12 @@ module Priscilla
6
6
  describe "#decorate" do
7
7
  let(:width) { 35 }
8
8
  let(:decorator) { "=" }
9
- let(:config) {
9
+ let(:config) do
10
10
  OpenStruct.new(
11
11
  width: width,
12
12
  decorator: decorator
13
13
  )
14
- }
14
+ end
15
15
 
16
16
  subject do
17
17
  described_class.new(config)
@@ -92,6 +92,18 @@ module Priscilla
92
92
  expect(old_config.decorator).not_to eq(subject.config.decorator)
93
93
  end
94
94
  end
95
+
96
+ context "when an unicode emoji is passed" do
97
+ let(:decorator) { "⚡ " }
98
+
99
+ it "tries to convert it to an unicode emoji" do
100
+ expect(output).to eq(
101
+ "⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ \n" +
102
+ "⚡ A cock in a frock on a rock ⚡ \n" +
103
+ "⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ ⚡ "
104
+ )
105
+ end
106
+ end
95
107
  end
96
108
  end
97
109
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleEmoji do
4
+ describe "::convert" do
5
+ let(:emoji) { SimpleEmoji.convert(string) }
6
+
7
+ context "when emoji is found" do
8
+ let(:string) { ':zap:' }
9
+
10
+ it 'translates a string to an emoji' do
11
+ expect(emoji).to eq("⚡")
12
+ end
13
+ end
14
+
15
+ context "when no emoj is found" do
16
+ let(:string) { 'something_completely_different' }
17
+
18
+ it 'returns it unchanged' do
19
+ expect(emoji).to eq(string)
20
+ end
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: priscilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ju Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rumoji
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +80,8 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '2.14'
69
- description: Make your messages stand out from the crowd
83
+ description: Don't let your console messages drown in a wall of text, make them stand
84
+ out
70
85
  email:
71
86
  - ju.liu@welaika.com
72
87
  executables: []
@@ -82,10 +97,12 @@ files:
82
97
  - lib/priscilla.rb
83
98
  - lib/priscilla/configuration.rb
84
99
  - lib/priscilla/makeup.rb
100
+ - lib/priscilla/simple_emoji.rb
85
101
  - lib/priscilla/version.rb
86
102
  - priscilla.gemspec
87
103
  - spec/priscilla/configuration_spec.rb
88
104
  - spec/priscilla/makeup_spec.rb
105
+ - spec/priscilla/simple_emoji_spec.rb
89
106
  - spec/priscilla_spec.rb
90
107
  - spec/spec_helper.rb
91
108
  homepage: http://github.com/Arkham/priscilla
@@ -111,9 +128,11 @@ rubyforge_project:
111
128
  rubygems_version: 2.2.2
112
129
  signing_key:
113
130
  specification_version: 4
114
- summary: Frock up your messages
131
+ summary: Frock up your console messages
115
132
  test_files:
116
133
  - spec/priscilla/configuration_spec.rb
117
134
  - spec/priscilla/makeup_spec.rb
135
+ - spec/priscilla/simple_emoji_spec.rb
118
136
  - spec/priscilla_spec.rb
119
137
  - spec/spec_helper.rb
138
+ has_rdoc: