lumos 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/README.md +41 -3
- data/TODO.md +13 -5
- data/lib/lumos.rb +2 -0
- data/lib/lumos/core_ext/kernel.rb +7 -3
- data/lib/lumos/formatters/base.rb +7 -3
- data/lib/lumos/railtie.rb +11 -0
- data/lib/lumos/version.rb +1 -1
- data/lib/lumos/wrapper.rb +12 -2
- data/lumos.gemspec +1 -0
- data/spec/core_ext/kernel_spec.rb +23 -14
- data/spec/formatters/base_spec.rb +5 -3
- data/spec/formatters/bottom_spec.rb +8 -8
- data/spec/formatters/horizontal_spec.rb +8 -8
- data/spec/formatters/left_spec.rb +7 -7
- data/spec/formatters/right_spec.rb +7 -7
- data/spec/formatters/surround_spec.rb +8 -8
- data/spec/formatters/top_spec.rb +8 -8
- data/spec/formatters/vertical_spec.rb +7 -7
- data/spec/wrapper_spec.rb +23 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 887b1b4fa514d8fc3666225a92cb9cdb53ac3d49
|
4
|
+
data.tar.gz: a191bf9c29e01e53b6ec91f8df0d8925b2a99038
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6104e45fed2d29c7b2197ba3ab8d38a6a8cbc781c494b5eeb4d341bd32ab8a7eb882bc5d9daa78bc30b8096c87e1b7be51f82e3ed4669fae5de6c92cc829e3e5
|
7
|
+
data.tar.gz: 38855eb12ffa31c6272e9e0cd5eeacfd2220069a2f2adeeffae0d114a6d93456dfc3cb077869afe0c1b3935c63f58e2d4f16a573c91dcee7167ebb8909adacf6
|
data/README.md
CHANGED
@@ -56,6 +56,8 @@ lumos :>, "☢", 10
|
|
56
56
|
print "☢☢☢☢☢☢☢☢☢☢"
|
57
57
|
```
|
58
58
|
|
59
|
+
---
|
60
|
+
|
59
61
|
### Wrapper
|
60
62
|
|
61
63
|
But main reason of `lumos` existence is necessity of objects highlighting besides ambient noise. So, initial array might be highlighted with `lumos %w(foo bar baz)` that will give us such output:
|
@@ -89,7 +91,7 @@ nes", :la=>"Laos"}
|
|
89
91
|
#### delimiter:
|
90
92
|
|
91
93
|
```ruby
|
92
|
-
lumos domains,
|
94
|
+
lumos domains, position: :horizontal, delimiter: "❤★"
|
93
95
|
```
|
94
96
|
|
95
97
|
<pre>
|
@@ -98,10 +100,20 @@ nes", :la=>"Laos"}
|
|
98
100
|
❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★
|
99
101
|
</pre>
|
100
102
|
|
103
|
+
And as you know – everything is better with emoji, so lumos supports emoji delimiters as well!
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
lumos "Coffee smells like freshly ground heaven", delimiter: ":coffee:", position: :bottom
|
107
|
+
```
|
108
|
+
|
109
|
+
Coffee smells like freshly ground heaven
|
110
|
+
|
111
|
+
:coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee::coffee:
|
112
|
+
|
101
113
|
#### padding:
|
102
114
|
|
103
115
|
```ruby
|
104
|
-
lumos domains,
|
116
|
+
lumos domains, delimiter: "❄", padding: 2
|
105
117
|
```
|
106
118
|
|
107
119
|
<pre>
|
@@ -120,7 +132,7 @@ lumos domains, {delimiter: "❄", padding: 2}
|
|
120
132
|
#### length:
|
121
133
|
|
122
134
|
```ruby
|
123
|
-
lumos domains,
|
135
|
+
lumos domains, position: :horizontal, delimiter: "->", length: 140
|
124
136
|
```
|
125
137
|
|
126
138
|
<pre>
|
@@ -128,3 +140,29 @@ lumos domains, {position: :horizontal, delimiter: "->", length: 140}
|
|
128
140
|
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippines", :la=>"Laos"}
|
129
141
|
->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->
|
130
142
|
</pre>
|
143
|
+
|
144
|
+
---
|
145
|
+
|
146
|
+
### Default options
|
147
|
+
|
148
|
+
You are able to specify one or few settings described above as a part of global default options.
|
149
|
+
|
150
|
+
If you're using Rails, you can define a Hash with default options in `config/application.rb` or in any of the `config/environments/*.rb` files on config.lumos_defaults. An example:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
module YourApp
|
154
|
+
class Application < Rails::Application
|
155
|
+
# Other code...
|
156
|
+
|
157
|
+
config.lumos_defaults = {position: :bottom, delimiter: ":poop:"}
|
158
|
+
end
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
162
|
+
Another option is to directly modify the `Lumos::Wrapper.default_options` Hash - this method works for non-Rails applications or is an option if you prefer to place the Lumos default settings in an initializer.
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
Lumos::Wrapper.default_options[:padding] = 5
|
166
|
+
Lumos::Wrapper.default_options[:length] = 140
|
167
|
+
Lumos::Wrapper.default_options[:delimiter] = ":alien:"
|
168
|
+
```
|
data/TODO.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
# Lumos TODO
|
2
2
|
|
3
|
-
##
|
3
|
+
## 0.0.1
|
4
4
|
- [x] Cases when length is wider than message
|
5
5
|
- [x] Test different input objects behaviour (Set, Struct, OpenStruct, Class, ActiveRecord)
|
6
6
|
- [x] Refactor Lumos::Formatters::Base
|
7
7
|
- [x] Rewrite README
|
8
|
-
- [
|
8
|
+
- [x] Release on Rubygems
|
9
|
+
|
10
|
+
## Release
|
11
|
+
- [x] Add \n to the end of lumos line
|
12
|
+
- [x] Add emoji support for divider and wrapper
|
13
|
+
- [x] Changeable default options
|
14
|
+
- [x] default_options spec
|
15
|
+
- [x] Support emoji for default_options too
|
16
|
+
- [x] Update README about emoji support
|
17
|
+
- [x] Add config.rails_defaults options
|
18
|
+
- [x] Add defaults description to README
|
9
19
|
|
10
20
|
## Next
|
11
|
-
- [ ]
|
12
|
-
- [ ] Add colors support
|
13
|
-
- [ ] Add emoji support
|
21
|
+
- [ ] Add multi-colors support
|
data/lib/lumos.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "rumoji"
|
2
|
+
|
1
3
|
module Kernel
|
2
4
|
def lumos(message = nil, *args)
|
3
5
|
if message.nil? || message == :>
|
@@ -13,11 +15,13 @@ private
|
|
13
15
|
delimiter ||= "#"
|
14
16
|
iterations ||= 3
|
15
17
|
|
16
|
-
print delimiter * iterations.to_i
|
18
|
+
print (Lumos::Formatters::Base.string_to_emoji(delimiter) * iterations.to_i) + "\n"
|
17
19
|
end
|
18
20
|
|
19
21
|
def lumos_wrap(message = nil, options)
|
20
|
-
options
|
21
|
-
|
22
|
+
options ||= {}
|
23
|
+
options[:delimiter] = options[:delimiter] if options[:delimiter]
|
24
|
+
|
25
|
+
print Lumos::Wrapper.new(message, options).result + "\n"
|
22
26
|
end
|
23
27
|
end
|
@@ -6,11 +6,16 @@ module Lumos
|
|
6
6
|
|
7
7
|
attr_reader :message, :delimiter, :padding, :length
|
8
8
|
|
9
|
+
def self.string_to_emoji(delimiter)
|
10
|
+
emoji = delimiter.scan(/\:.*?\:/)
|
11
|
+
emoji.size > 0 ? emoji.map{|string| Rumoji.decode(string)}.join("") : delimiter
|
12
|
+
end
|
13
|
+
|
9
14
|
def initialize(options = {})
|
10
15
|
@message = unwrap_message options.fetch(:message)
|
11
|
-
@delimiter = options.fetch(:delimiter, "#").to_s
|
12
16
|
@padding = options.fetch(:padding, 1).to_i.abs
|
13
|
-
@
|
17
|
+
@delimiter = Lumos::Formatters::Base.string_to_emoji options[:delimiter].to_s
|
18
|
+
@length = options[:length].to_i.abs
|
14
19
|
end
|
15
20
|
|
16
21
|
def message_length
|
@@ -24,7 +29,6 @@ module Lumos
|
|
24
29
|
message.to_s.include?(object_id_hex) ? message.inspect : message.to_s
|
25
30
|
end
|
26
31
|
|
27
|
-
|
28
32
|
def vertical_padding
|
29
33
|
" " * padding if padding > 0
|
30
34
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "lumos"
|
2
|
+
|
3
|
+
module Lumos
|
4
|
+
require "rails"
|
5
|
+
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
initializer "lumos.insert_into_active_record" do |app|
|
8
|
+
Lumos::Wrapper.default_options.merge!(app.config.lumos_defaults) if app.config.respond_to?(:lumos_defaults)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/lumos/version.rb
CHANGED
data/lib/lumos/wrapper.rb
CHANGED
@@ -2,10 +2,20 @@ module Lumos
|
|
2
2
|
class Wrapper
|
3
3
|
attr_reader :message, :options, :position
|
4
4
|
|
5
|
+
def self.default_options
|
6
|
+
@default_options ||= {
|
7
|
+
position: :surround,
|
8
|
+
delimiter: "#",
|
9
|
+
length: 70
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
5
13
|
def initialize(message, options = {})
|
6
|
-
|
14
|
+
options = self.class.default_options.merge(options)
|
15
|
+
|
7
16
|
@options = options
|
8
|
-
@position = options
|
17
|
+
@position = options[:position].to_sym
|
18
|
+
@message = message
|
9
19
|
|
10
20
|
validate_position
|
11
21
|
end
|
data/lumos.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "rumoji", "0.4.1"
|
21
22
|
spec.add_development_dependency "activesupport", "4.2"
|
22
23
|
spec.add_development_dependency "activerecord", "4.2"
|
23
24
|
spec.add_development_dependency "sqlite3", "~> 1.3"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
require "active_record_helper"
|
3
5
|
require "set"
|
@@ -5,58 +7,65 @@ require "set"
|
|
5
7
|
RSpec.describe "Lumos kernel extensions" do
|
6
8
|
context "divider" do
|
7
9
|
it "returns sharps if no arguments defined" do
|
8
|
-
expect { lumos }.to output("
|
10
|
+
expect { lumos }.to output("###\n").to_stdout
|
9
11
|
end
|
10
12
|
|
11
13
|
it "returns sharps if only pointer defined" do
|
12
|
-
expect { lumos :> }.to output("
|
14
|
+
expect { lumos :> }.to output("###\n").to_stdout
|
13
15
|
end
|
14
16
|
|
15
17
|
it "returns delimiter based string" do
|
16
|
-
expect { lumos :>, "-" }.to output("
|
18
|
+
expect { lumos :>, "-" }.to output("---\n").to_stdout
|
17
19
|
end
|
18
20
|
|
19
21
|
it "returns delimiter based string repeated 10 times" do
|
20
|
-
expect { lumos :>, "@", 10 }.to output("
|
22
|
+
expect { lumos :>, "@", 10 }.to output("@@@@@@@@@@\n").to_stdout
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns emoji-delimiter repeated 10 times" do
|
26
|
+
expect { lumos :>, ":coffee:", 10 }.to output("☕☕☕☕☕☕☕☕☕☕\n").to_stdout
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
24
30
|
context "wrapper" do
|
25
31
|
it "returns wrapped messages if no arguments except message defined" do
|
26
|
-
expect { lumos "Accio" }.to output("#########\n# #\n# Accio #\n# #\n
|
32
|
+
expect { lumos "Accio" }.to output("#########\n# #\n# Accio #\n# #\n#########\n").to_stdout
|
27
33
|
end
|
28
34
|
|
29
35
|
it "returns bottom positioned message" do
|
30
|
-
expect { lumos "Accio", {position: :bottom, delimiter: "@"} }.to output("Accio\n
|
36
|
+
expect { lumos "Accio", {position: :bottom, delimiter: "@"} }.to output("Accio\n@@@@@\n").to_stdout
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns an emoji-wrapped messages" do
|
40
|
+
expect { lumos "Accio", {delimiter: ":alien:"} }.to output( "👽👽👽👽👽👽👽👽👽\n👽 👽\n👽 Accio 👽\n👽 👽\n👽👽👽👽👽👽👽👽👽\n").to_stdout
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
34
44
|
context "objects" do
|
35
|
-
it "returns
|
36
|
-
expect { lumos %w(One Two Freddy is coming for you Three Four better lock your door ) }.to output("##########################################################################\n# #\n# [\"One\", \"Two\", \"Freddy\", \"is\", \"coming\", \"for\", \"you\", \"Three\", \"Four\" #\n# , \"better\", \"lock\", \"your\", \"door\"] #\n# #\n
|
45
|
+
it "returns wrapped Array" do
|
46
|
+
expect { lumos %w(One Two Freddy is coming for you Three Four better lock your door ) }.to output("##########################################################################\n# #\n# [\"One\", \"Two\", \"Freddy\", \"is\", \"coming\", \"for\", \"you\", \"Three\", \"Four\" #\n# , \"better\", \"lock\", \"your\", \"door\"] #\n# #\n##########################################################################\n").to_stdout
|
37
47
|
end
|
38
48
|
|
39
49
|
it "returns wrapped Hash" do
|
40
50
|
domains = {ru: "Russia", th: "Thailand", "com.au" => "Australia", ph: "Philippines"}
|
41
|
-
expect { lumos domains, {length: 56}}.to output("############################################################\n# #\n# {:ru=>\"Russia\", :th=>\"Thailand\", \"com.au\"=>\"Australia\", #\n# :ph=>\"Philippines\"} #\n# #\n
|
51
|
+
expect { lumos domains, {length: 56} }.to output("############################################################\n# #\n# {:ru=>\"Russia\", :th=>\"Thailand\", \"com.au\"=>\"Australia\", #\n# :ph=>\"Philippines\"} #\n# #\n############################################################\n").to_stdout
|
42
52
|
end
|
43
53
|
|
44
54
|
it "returns wrapped Set" do
|
45
|
-
expect { lumos Set.new([1,2,3])}.to output("#####################\n# #\n# #<Set: {1, 2, 3}> #\n# #\n
|
55
|
+
expect { lumos Set.new([1,2,3]) }.to output("#####################\n# #\n# #<Set: {1, 2, 3}> #\n# #\n#####################\n").to_stdout
|
46
56
|
end
|
47
57
|
|
48
58
|
it "returns wrapped Struct" do
|
49
59
|
Struct.new("Customer", :name, :address)
|
50
|
-
expect { lumos Struct::Customer.new("Dave", "123 Main")}.to output("##############################################################\n# #\n# #<struct Struct::Customer name=\"Dave\", address=\"123 Main\"> #\n# #\n
|
60
|
+
expect { lumos Struct::Customer.new("Dave", "123 Main") }.to output("##############################################################\n# #\n# #<struct Struct::Customer name=\"Dave\", address=\"123 Main\"> #\n# #\n##############################################################\n").to_stdout
|
51
61
|
end
|
52
62
|
|
53
63
|
it "returns wrapped OpenStruct" do
|
54
|
-
expect { lumos OpenStruct.new(country: "Russia", population: 143_975_923)}.to output("########################################################\n# #\n# #<OpenStruct country=\"Russia\", population=143975923> #\n# #\n
|
64
|
+
expect { lumos OpenStruct.new(country: "Russia", population: 143_975_923) }.to output("########################################################\n# #\n# #<OpenStruct country=\"Russia\", population=143975923> #\n# #\n########################################################\n").to_stdout
|
55
65
|
end
|
56
66
|
|
57
67
|
it "returns wrapped ActiveRecord" do
|
58
|
-
|
59
|
-
expect { lumos Coffee.new(sort: "Cappuccino", price: 105, saturation: 25)}.to output("#####################################################################\n# #\n# #<Coffee id: nil, sort: \"Cappuccino\", price: 105, saturation: 25> #\n# #\n#####################################################################").to_stdout
|
68
|
+
expect { lumos Coffee.new(sort: "Cappuccino", price: 105, saturation: 25) }.to output("#####################################################################\n# #\n# #<Coffee id: nil, sort: \"Cappuccino\", price: 105, saturation: 25> #\n# #\n#####################################################################\n").to_stdout
|
60
69
|
end
|
61
70
|
end
|
62
71
|
end
|
@@ -3,21 +3,23 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
describe Lumos::Formatters::Base do
|
5
5
|
|
6
|
+
let(:options) { Lumos::Wrapper.default_options }
|
7
|
+
|
6
8
|
context "subsidary methods" do
|
7
9
|
it "returns number of message characters" do
|
8
10
|
expect(described_class.new(message: "Cave Inimicum").message_length).to eq(13)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "returns number of short message lines" do
|
12
|
-
expect(described_class.new(message: "Colloportus").chopped_message.size).to eq(1)
|
14
|
+
expect(described_class.new(message: "Colloportus", length: options[:length]).chopped_message.size).to eq(1)
|
13
15
|
end
|
14
16
|
|
15
17
|
it "returns number of long message lines" do
|
16
|
-
expect(described_class.new(message: "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.").chopped_message.size).to eq(3)
|
18
|
+
expect(described_class.new(message: "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", length: options[:length]).chopped_message.size).to eq(3)
|
17
19
|
end
|
18
20
|
|
19
21
|
it "returns messages size based on lenght of first chopped line" do
|
20
|
-
expect(described_class.new(message: "Confringo").chopped_message_length).to eq(9)
|
22
|
+
expect(described_class.new(message: "Confringo", length: options[:length]).chopped_message_length).to eq(9)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -4,39 +4,39 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Bottom do
|
5
5
|
context "messages" do
|
6
6
|
it "returns wrapped message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Langlock", position: :bottom }.to output("Langlock\n########\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :bottom }.to output("Coffee has long had a reputation as being unhealthy. But in almost eve\nry single respect that reputation is backward. The potential health be\nnefits are surprisingly large.\n######################################################################\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :bottom, length: 35 }.to output("Coffee has long had a reputation as\n being unhealthy. But in almost eve\nry single respect that reputation i\ns backward. The potential health be\nnefits are surprisingly large.\n###################################\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Langlock", position: :bottom, padding: 0 }.to output("Langlock\n########\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit padding message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Langlock", position: :bottom, padding: 1 }.to output("Langlock\n\n########\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Langlock", position: :bottom, padding: 2 }.to output("Langlock\n\n\n########\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "delimiters" do
|
34
34
|
it "returns delimiter message" do
|
35
|
-
expect
|
35
|
+
expect { lumos "Legilimens", position: :bottom, delimiter: "☯" }.to output("Legilimens\n☯☯☯☯☯☯☯☯☯☯\n").to_stdout
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns message with multichar delimiter" do
|
39
|
-
expect
|
39
|
+
expect { lumos "Legilimens", position: :bottom, delimiter: "=->" }.to output("Legilimens\n=->=->=->=\n").to_stdout
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -4,39 +4,39 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Horizontal do
|
5
5
|
context "messages" do
|
6
6
|
it "returns message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Meteolojinx Recanto", position: :horizontal }.to output("###################\nMeteolojinx Recanto\n###################\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :horizontal }.to output("######################################################################\nCoffee has long had a reputation as being unhealthy. But in almost eve\nry single respect that reputation is backward. The potential health be\nnefits are surprisingly large.\n######################################################################\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :horizontal, length: 35 }.to output("###################################\nCoffee has long had a reputation as\n being unhealthy. But in almost eve\nry single respect that reputation i\ns backward. The potential health be\nnefits are surprisingly large.\n###################################\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Mobilicorpus", position: :horizontal, padding: 0 }.to output("############\nMobilicorpus\n############\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Mobilicorpus", position: :horizontal, padding: 1 }.to output("############\n\nMobilicorpus\n\n############\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Mobilicorpus", position: :horizontal, padding: 2 }.to output("############\n\n\nMobilicorpus\n\n\n############\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "delimiters" do
|
34
34
|
it "returns delimiter message" do
|
35
|
-
expect
|
35
|
+
expect { lumos "Mobiliarbus", position: :horizontal, delimiter: "❄" }.to output("❄❄❄❄❄❄❄❄❄❄❄\nMobiliarbus\n❄❄❄❄❄❄❄❄❄❄❄\n").to_stdout
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns message with multichar delimiter" do
|
39
|
-
expect
|
39
|
+
expect { lumos "Mobiliarbus", position: :horizontal, delimiter: "=->" }.to output("=->=->=->=-\nMobiliarbus\n=->=->=->=-\n").to_stdout
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -4,33 +4,33 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Left do
|
5
5
|
context "messages" do
|
6
6
|
it "returns wrapped message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Engorgio", position: :left }.to output("# Engorgio\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :left }.to output("# Coffee has long had a reputation as being unhealthy. But in almost eve\n# ry single respect that reputation is backward. The potential health be\n# nefits are surprisingly large.\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :left, length: 35 }.to output("# Coffee has long had a reputation as\n# being unhealthy. But in almost eve\n# ry single respect that reputation i\n# s backward. The potential health be\n# nefits are surprisingly large.\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-digit padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Episkey", position: :left, padding: 0 }.to output("#Episkey\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit padding message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Episkey", position: :left, padding: 1 }.to output("# Episkey\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Episkey", position: :left, padding: 2 }.to output("# Episkey\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns delimiter message" do
|
34
|
-
expect
|
34
|
+
expect { lumos "Ennervate", position: :left, delimiter: "☭" }.to output("☭ Ennervate\n").to_stdout
|
35
35
|
end
|
36
36
|
end
|
@@ -4,34 +4,34 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Right do
|
5
5
|
context "messages" do
|
6
6
|
it "returns wrapped message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Ferula", position: :right }.to output("Ferula #\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :right }.to output("Coffee has long had a reputation as being unhealthy. But in almost eve #\nry single respect that reputation is backward. The potential health be #\nnefits are surprisingly large. #\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :right, length: 35 }.to output("Coffee has long had a reputation as #\n being unhealthy. But in almost eve #\nry single respect that reputation i #\ns backward. The potential health be #\nnefits are surprisingly large. #\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Finite Incantatum", position: :right, padding: 0 }.to output("Finite Incantatum#\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit padding message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Finite Incantatum", position: :right, padding: 1 }.to output("Finite Incantatum #\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Finite Incantatum", position: :right, padding: 2 }.to output("Finite Incantatum #\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns delimiter message" do
|
34
|
-
expect
|
34
|
+
expect { lumos "Fidelius", position: :right, delimiter: "->" }.to output("Fidelius ->\n").to_stdout
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -4,39 +4,39 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Surround do
|
5
5
|
context "messages" do
|
6
6
|
it "returns wrapped message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Defodio" }.to output("###########\n# #\n# Defodio #\n# #\n###########\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large." }.to output("##########################################################################\n# #\n# Coffee has long had a reputation as being unhealthy. But in almost eve #\n# ry single respect that reputation is backward. The potential health be #\n# nefits are surprisingly large. #\n# #\n##########################################################################\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", length: 35 }.to output("#######################################\n# #\n# Coffee has long had a reputation as #\n# being unhealthy. But in almost eve #\n# ry single respect that reputation i #\n# s backward. The potential health be #\n# nefits are surprisingly large. #\n# #\n#######################################\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-digit padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Densaugeo", padding: 0 }.to output("###########\n#Densaugeo#\n###########\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit padding message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Densaugeo", padding: 1 }.to output("#############\n# #\n# Densaugeo #\n# #\n#############\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Densaugeo", padding: 2 }.to output("###############\n# #\n# #\n# Densaugeo #\n# #\n# #\n###############\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "delimiters" do
|
34
34
|
it "returns delimiter message" do
|
35
|
-
expect
|
35
|
+
expect { lumos "Deletrius", delimiter: "❤" }.to output("❤❤❤❤❤❤❤❤❤❤❤❤❤\n❤ ❤\n❤ Deletrius ❤\n❤ ❤\n❤❤❤❤❤❤❤❤❤❤❤❤❤\n").to_stdout
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns message with multichar delimiter" do
|
39
|
-
expect
|
39
|
+
expect { lumos "Deletrius", delimiter: "=->" }.to output("=->=->=->=->=->=-\n=-> =->\n=-> Deletrius =->\n=-> =->\n=->=->=->=->=->=-\n").to_stdout
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/spec/formatters/top_spec.rb
CHANGED
@@ -4,39 +4,39 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Top do
|
5
5
|
context "messages" do
|
6
6
|
it "returns wrapped message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Immobulus", position: :top }.to output("#########\nImmobulus\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :top }.to output("######################################################################\nCoffee has long had a reputation as being unhealthy. But in almost eve\nry single respect that reputation is backward. The potential health be\nnefits are surprisingly large.\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :top, length: 35 }.to output("###################################\nCoffee has long had a reputation as\n being unhealthy. But in almost eve\nry single respect that reputation i\ns backward. The potential health be\nnefits are surprisingly large.\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Imperio", position: :top }.to output("#######\nImperio\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit padding message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Imperio", position: :top, padding: 1 }.to output("#######\n\nImperio\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Imperio", position: :top, padding: 2 }.to output("#######\n\n\nImperio\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "delimiters" do
|
34
34
|
it "returns delimiter message" do
|
35
|
-
expect
|
35
|
+
expect { lumos "Impedimenta", position: :top, delimiter: "★" }.to output("★★★★★★★★★★★\nImpedimenta\n").to_stdout
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns message with multichar delimiter" do
|
39
|
-
expect
|
39
|
+
expect { lumos "Impedimenta", position: :top, delimiter: "=->" }.to output("=->=->=->=-\nImpedimenta\n").to_stdout
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -4,33 +4,33 @@ require "spec_helper"
|
|
4
4
|
describe Lumos::Formatters::Vertical do
|
5
5
|
context "messages" do
|
6
6
|
it "returns message" do
|
7
|
-
expect
|
7
|
+
expect { lumos "Obliviate", position: :vertical }.to output("# Obliviate #\n").to_stdout
|
8
8
|
end
|
9
9
|
|
10
10
|
it "returns multiline message" do
|
11
|
-
expect
|
11
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :vertical }.to output("# Coffee has long had a reputation as being unhealthy. But in almost eve #\n# ry single respect that reputation is backward. The potential health be #\n# nefits are surprisingly large. #\n").to_stdout
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns multiline message with defined length" do
|
15
|
-
expect
|
15
|
+
expect { lumos "Coffee has long had a reputation as being unhealthy. But in almost every single respect that reputation is backward. The potential health benefits are surprisingly large.", position: :vertical, length: 35 }.to output("# Coffee has long had a reputation as #\n# being unhealthy. But in almost eve #\n# ry single respect that reputation i #\n# s backward. The potential health be #\n# nefits are surprisingly large. #\n").to_stdout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "paddings" do
|
20
20
|
it "returns zero-padding message" do
|
21
|
-
expect
|
21
|
+
expect { lumos "Oppugno", position: :vertical, padding: 0 }.to output("#Oppugno#\n").to_stdout
|
22
22
|
end
|
23
23
|
|
24
24
|
it "returns 1-digit padding message" do
|
25
|
-
expect
|
25
|
+
expect { lumos "Oppugno", position: :vertical, padding: 1 }.to output("# Oppugno #\n").to_stdout
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns 2-digits padding message" do
|
29
|
-
expect
|
29
|
+
expect { lumos "Oppugno", position: :vertical, padding: 2 }.to output("# Oppugno #\n").to_stdout
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns delimiter message" do
|
34
|
-
expect
|
34
|
+
expect { lumos "Obscuro", position: :vertical, delimiter: "☢" }.to output("☢ Obscuro ☢\n").to_stdout
|
35
35
|
end
|
36
36
|
end
|
data/spec/wrapper_spec.rb
CHANGED
@@ -27,4 +27,27 @@ describe Lumos::Wrapper do
|
|
27
27
|
expect(described_class.new("Aparecium").bottom).to eq("Aparecium\n#########")
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
context "default_options" do
|
32
|
+
it "returns default positioned message with delimiter changed" do
|
33
|
+
described_class.default_options[:delimiter] = "@"
|
34
|
+
expect(described_class.new("Avifors").result).to eq("@@@@@@@@@@@\n@ @\n@ Avifors @\n@ @\n@@@@@@@@@@@")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns default positioned message with padding changed" do
|
38
|
+
described_class.default_options[:padding] = 3
|
39
|
+
expect(described_class.new("Avifors").result).to eq("@@@@@@@@@@@@@@@\n@ @\n@ @\n@ @\n@ Avifors @\n@ @\n@ @\n@ @\n@@@@@@@@@@@@@@@")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns message with position changed" do
|
43
|
+
described_class.default_options[:position] = :horizontal
|
44
|
+
expect(described_class.new("Avifors").result).to eq("@@@@@@@\n\n\n\nAvifors\n\n\n\n@@@@@@@")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns message with bottom position and emoji delimiter" do
|
48
|
+
described_class.default_options[:position] = :bottom
|
49
|
+
described_class.default_options[:delimiter] = ":poop:"
|
50
|
+
expect(described_class.new("Avifors").result).to eq("Avifors\n\n\n\n💩💩💩💩💩💩💩")
|
51
|
+
end
|
52
|
+
end
|
30
53
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumos
|
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
|
- query-string
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rumoji
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: activesupport
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +150,7 @@ files:
|
|
136
150
|
- lib/lumos/formatters/surround.rb
|
137
151
|
- lib/lumos/formatters/top.rb
|
138
152
|
- lib/lumos/formatters/vertical.rb
|
153
|
+
- lib/lumos/railtie.rb
|
139
154
|
- lib/lumos/version.rb
|
140
155
|
- lib/lumos/wrapper.rb
|
141
156
|
- lumos.gemspec
|