lumos 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/.gitignore +16 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +130 -0
- data/Rakefile +5 -0
- data/TODO.md +13 -0
- data/lib/lumos/core_ext/kernel.rb +23 -0
- data/lib/lumos/formatters/base.rb +33 -0
- data/lib/lumos/formatters/base_chopper.rb +34 -0
- data/lib/lumos/formatters/base_horizontal.rb +29 -0
- data/lib/lumos/formatters/bottom.rb +22 -0
- data/lib/lumos/formatters/horizontal.rb +20 -0
- data/lib/lumos/formatters/left.rb +12 -0
- data/lib/lumos/formatters/right.rb +12 -0
- data/lib/lumos/formatters/surround.rb +25 -0
- data/lib/lumos/formatters/top.rb +22 -0
- data/lib/lumos/formatters/vertical.rb +12 -0
- data/lib/lumos/version.rb +3 -0
- data/lib/lumos/wrapper.rb +39 -0
- data/lib/lumos.rb +9 -0
- data/lumos.gemspec +28 -0
- data/spec/active_record_helper.rb +13 -0
- data/spec/core_ext/kernel_spec.rb +62 -0
- data/spec/formatters/base_spec.rb +24 -0
- data/spec/formatters/bottom_spec.rb +42 -0
- data/spec/formatters/horizontal_spec.rb +42 -0
- data/spec/formatters/left_spec.rb +36 -0
- data/spec/formatters/right_spec.rb +37 -0
- data/spec/formatters/surround_spec.rb +42 -0
- data/spec/formatters/top_spec.rb +42 -0
- data/spec/formatters/vertical_spec.rb +36 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/wrapper_spec.rb +30 -0
- metadata +190 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e662e8a14acb448c195481fd0695f902efa6f30b
|
4
|
+
data.tar.gz: 96989e2c5815ab117671a61579a5761797e3c664
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d605efe5be6043cfac0d48c7bf1acc1fd0f56b17b620c3133eeb723ac7170c76c4c7db8678d1d2615ee43ed025dd68b8abae0d250a583949a5baad8219866a45
|
7
|
+
data.tar.gz: 56dba760f56e8a45d87e1fa1f4844101a0c37a2c58a2e6baf18aaee8084c801f1a01c4ecfe87344075f23f9b5d9ef173a89f7eb6b54a2a0503144afa5cc6d43a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 query-string
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# Lumos
|
2
|
+
|
3
|
+
[](https://travis-ci.org/query-string/lumos)
|
4
|
+
[](https://codeclimate.com/github/query-string/lumos)
|
5
|
+
[](https://codeclimate.com/github/query-string/lumos)
|
6
|
+
|
7
|
+
<pre>
|
8
|
+
☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢
|
9
|
+
☢ ☢
|
10
|
+
☢ ☢
|
11
|
+
☢ Objects wrapping library ☢
|
12
|
+
☢ ☢
|
13
|
+
☢ ☢
|
14
|
+
☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢
|
15
|
+
</pre>
|
16
|
+
|
17
|
+
Have you ever tried to highlight your Ruby objects from your controllers/models/whatever in the Rails log? I bet you have ). I usually do something like that ` p "###"; p %w(foo bar baz ); p "###"` and in general it works fine, until you have to repeat this construction again and again, with different objects, in different places. I have a good news – `lumos` can easily wrap and make any object perceptible amongs common Rails log mess.
|
18
|
+
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'lumos'
|
26
|
+
```
|
27
|
+
|
28
|
+
And call inside your controller/model/whatever
|
29
|
+
```ruby
|
30
|
+
class My::MoviesController < ApplicationController
|
31
|
+
def checked
|
32
|
+
lumos params
|
33
|
+
@movie = Movie.find(params[:movie_id])
|
34
|
+
current_user.send(params[:scope]) << @movie
|
35
|
+
#redirect_to root_path
|
36
|
+
end
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
Depend on passed parameters, `lumos` can act as a **divider** or as a **wrapper**.
|
43
|
+
|
44
|
+
### Divider
|
45
|
+
|
46
|
+
For example, simple call of `lumos` without params will print a `###` message in your log. Of course you're able to change a divider sign (`lumos :>, "☭"` will print a `☭☭☭` message) and number of repetitions – `lumos :>, "☢", 10`.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
lumos
|
50
|
+
print "###"
|
51
|
+
|
52
|
+
lumos :>, "☭"
|
53
|
+
print "☭☭☭"
|
54
|
+
|
55
|
+
lumos :>, "☢", 10
|
56
|
+
print "☢☢☢☢☢☢☢☢☢☢"
|
57
|
+
```
|
58
|
+
|
59
|
+
### Wrapper
|
60
|
+
|
61
|
+
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:
|
62
|
+
|
63
|
+
<pre>
|
64
|
+
#########################
|
65
|
+
# #
|
66
|
+
# ["foo", "bar", "baz"] #
|
67
|
+
# #
|
68
|
+
#########################
|
69
|
+
</pre>
|
70
|
+
|
71
|
+
Wrapping method also takes few options such as:
|
72
|
+
|
73
|
+
#### position:
|
74
|
+
|
75
|
+
`:surround` (by default), `:top`, `:bottom`, `:left`, `:right`, `:horizontal`, `:vertical`
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
domains = {ru: "Russia", th: "Thailand", "com.au" => "Australia", ph: "Philippines", la: "Laos"}
|
79
|
+
lumos domains, {position: :horizontal}
|
80
|
+
```
|
81
|
+
|
82
|
+
<pre>
|
83
|
+
######################################################################
|
84
|
+
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippi
|
85
|
+
nes", :la=>"Laos"}
|
86
|
+
######################################################################
|
87
|
+
</pre>
|
88
|
+
|
89
|
+
#### delimiter:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
lumos domains, {position: :horizontal, delimiter: "❤★"}
|
93
|
+
```
|
94
|
+
|
95
|
+
<pre>
|
96
|
+
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippi
|
97
|
+
nes", :la=>"Laos"}
|
98
|
+
❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★
|
99
|
+
</pre>
|
100
|
+
|
101
|
+
#### padding:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
lumos domains, {delimiter: "❄", padding: 2}
|
105
|
+
```
|
106
|
+
|
107
|
+
<pre>
|
108
|
+
❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
|
109
|
+
❄ ❄
|
110
|
+
❄ ❄
|
111
|
+
❄ ❄
|
112
|
+
❄ {:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippi ❄
|
113
|
+
❄ nes", :la=>"Laos"} ❄
|
114
|
+
❄ ❄
|
115
|
+
❄ ❄
|
116
|
+
❄ ❄
|
117
|
+
❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
|
118
|
+
</pre>
|
119
|
+
|
120
|
+
#### length:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
lumos domains, {position: :horizontal, delimiter: "->", length: 140}
|
124
|
+
```
|
125
|
+
|
126
|
+
<pre>
|
127
|
+
->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->
|
128
|
+
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippines", :la=>"Laos"}
|
129
|
+
->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->
|
130
|
+
</pre>
|
data/Rakefile
ADDED
data/TODO.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Lumos TODO
|
2
|
+
|
3
|
+
## Release
|
4
|
+
- [x] Cases when length is wider than message
|
5
|
+
- [x] Test different input objects behaviour (Set, Struct, OpenStruct, Class, ActiveRecord)
|
6
|
+
- [x] Refactor Lumos::Formatters::Base
|
7
|
+
- [x] Rewrite README
|
8
|
+
- [ ] Release on Rubygems
|
9
|
+
|
10
|
+
## Next
|
11
|
+
- [ ] Changeable default options
|
12
|
+
- [ ] Add colors support
|
13
|
+
- [ ] Add emoji support
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Kernel
|
2
|
+
def lumos(message = nil, *args)
|
3
|
+
if message.nil? || message == :>
|
4
|
+
lumos_divide args[0], args[1]
|
5
|
+
else
|
6
|
+
lumos_wrap message, args[0]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def lumos_divide(delimiter, iterations)
|
13
|
+
delimiter ||= "#"
|
14
|
+
iterations ||= 3
|
15
|
+
|
16
|
+
print delimiter * iterations.to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
def lumos_wrap(message = nil, options)
|
20
|
+
options ||= {}
|
21
|
+
print Lumos::Wrapper.new(message, options).result
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
class Base
|
4
|
+
include BaseChopper
|
5
|
+
include BaseHorizontal
|
6
|
+
|
7
|
+
attr_reader :message, :delimiter, :padding, :length
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@message = unwrap_message options.fetch(:message)
|
11
|
+
@delimiter = options.fetch(:delimiter, "#").to_s
|
12
|
+
@padding = options.fetch(:padding, 1).to_i.abs
|
13
|
+
@length = options.fetch(:length, 70).to_i.abs
|
14
|
+
end
|
15
|
+
|
16
|
+
def message_length
|
17
|
+
message.to_s.size
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def unwrap_message(message)
|
23
|
+
object_id_hex = (message.object_id << 1).to_s(16)
|
24
|
+
message.to_s.include?(object_id_hex) ? message.inspect : message.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def vertical_padding
|
29
|
+
" " * padding if padding > 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
module BaseChopper
|
4
|
+
def chopped_message
|
5
|
+
message.scan(/.{1,#{( length > message_length ? message_length : length )}}/)
|
6
|
+
end
|
7
|
+
|
8
|
+
def chopped_message_length
|
9
|
+
chopped_message[0].size
|
10
|
+
end
|
11
|
+
|
12
|
+
def iterate_chopped_lines(string = "")
|
13
|
+
chopped_message.each{ |line| string += yield line }
|
14
|
+
string
|
15
|
+
end
|
16
|
+
|
17
|
+
def chopping_line(line)
|
18
|
+
"\n" if chopped_message.size > 1 && !chopping_last_line?(line)
|
19
|
+
end
|
20
|
+
|
21
|
+
def chopping_last_line?(line)
|
22
|
+
chopped_message.index(line) == chopped_message.size - 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def chopping_padding(line)
|
26
|
+
if chopping_last_line?(line)
|
27
|
+
first_line = chopped_message.first.size
|
28
|
+
last_line = chopped_message.last.size
|
29
|
+
" " * (first_line - last_line) if first_line > last_line
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
module BaseHorizontal
|
4
|
+
def horizontal_pattern
|
5
|
+
delimiter * chopped_message_length
|
6
|
+
end
|
7
|
+
|
8
|
+
def horizontal_line
|
9
|
+
paragraph = content_paragraph(chopped_message[0])
|
10
|
+
paragraph_size = paragraph.size
|
11
|
+
draft_size = horizontal_pattern.size
|
12
|
+
|
13
|
+
draft_size > paragraph_size ? horizontal_pattern[0...paragraph_size] : horizontal_pattern
|
14
|
+
end
|
15
|
+
|
16
|
+
def horizontal_padding
|
17
|
+
"\n" * padding if padding > 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def horizontal_result
|
21
|
+
"#{horizontal_line}\n"\
|
22
|
+
"#{horizontal_padding}"\
|
23
|
+
"#{iterate_chopped_lines{ |line| "#{content_paragraph(line)}\n" }}"\
|
24
|
+
"#{horizontal_padding}"\
|
25
|
+
"#{horizontal_line}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
class Bottom < Lumos::Formatters::Base
|
4
|
+
def initialize(options = {})
|
5
|
+
super
|
6
|
+
@padding = options.fetch(:padding, 0).to_i.abs
|
7
|
+
end
|
8
|
+
|
9
|
+
def result
|
10
|
+
"#{iterate_chopped_lines{ |line| "#{content_paragraph(line)}\n" }}"\
|
11
|
+
"#{horizontal_padding}"\
|
12
|
+
"#{horizontal_line}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def content_paragraph(line)
|
18
|
+
line
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
class Horizontal < Lumos::Formatters::Base
|
4
|
+
def initialize(options = {})
|
5
|
+
super
|
6
|
+
@padding = options.fetch(:padding, 0).to_i.abs
|
7
|
+
end
|
8
|
+
|
9
|
+
def result
|
10
|
+
horizontal_result
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def content_paragraph(line)
|
16
|
+
line
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
class Surround < Lumos::Formatters::Base
|
4
|
+
def result
|
5
|
+
horizontal_result
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def horizontal_pattern
|
11
|
+
"#{delimiter * chopped_message_length}"\
|
12
|
+
"#{padding > 0 ? (delimiter * padding) * 2 : nil}"\
|
13
|
+
"#{delimiter * 2}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def horizontal_padding
|
17
|
+
"#{content_paragraph(" " * chopped_message_length)}\n" * padding if padding > 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def content_paragraph(line)
|
21
|
+
"#{delimiter}#{vertical_padding}#{line}#{vertical_padding}#{chopping_padding line}#{delimiter}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
class Top < Lumos::Formatters::Base
|
4
|
+
def initialize(options = {})
|
5
|
+
super
|
6
|
+
@padding = options.fetch(:padding, 0).to_i.abs
|
7
|
+
end
|
8
|
+
|
9
|
+
def result
|
10
|
+
"#{horizontal_line}\n"\
|
11
|
+
"#{horizontal_padding}"\
|
12
|
+
"#{iterate_chopped_lines{ |line| content_paragraph line }}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def content_paragraph(line)
|
18
|
+
"#{line}#{chopping_line line}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Lumos
|
2
|
+
module Formatters
|
3
|
+
class Vertical < Lumos::Formatters::Base
|
4
|
+
def result
|
5
|
+
iterate_chopped_lines do |line|
|
6
|
+
"#{delimiter}#{vertical_padding}#{line}#{vertical_padding}#{chopping_padding line}#{delimiter}"\
|
7
|
+
"#{chopping_line line}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Lumos
|
2
|
+
class Wrapper
|
3
|
+
attr_reader :message, :options, :position
|
4
|
+
|
5
|
+
def initialize(message, options = {})
|
6
|
+
@message = message
|
7
|
+
@options = options
|
8
|
+
@position = options.fetch(:position, :surround).to_sym
|
9
|
+
|
10
|
+
validate_position
|
11
|
+
end
|
12
|
+
|
13
|
+
def formatter(name = position)
|
14
|
+
("Lumos::Formatters::" + "#{name}".classify).constantize.new(merged_options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def result
|
18
|
+
formatter.result
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(name)
|
22
|
+
available_positions.include?(name) ? formatter(name).result : super
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def available_positions
|
28
|
+
[:surround, :left, :right, :top, :bottom, :horizontal, :vertical]
|
29
|
+
end
|
30
|
+
|
31
|
+
def validate_position
|
32
|
+
raise ArgumentError, "#{position} is not correct position. You can use one of following: #{available_positions.join(", ")}." unless available_positions.include?(position)
|
33
|
+
end
|
34
|
+
|
35
|
+
def merged_options
|
36
|
+
options.except(:position).merge(message: message)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/lumos.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "active_support/core_ext/string"
|
2
|
+
|
3
|
+
%w(base_chopper base_horizontal base surround left right top bottom horizontal vertical).each do |file|
|
4
|
+
require File.dirname(__FILE__) + "/lumos/formatters/#{file}"
|
5
|
+
end
|
6
|
+
|
7
|
+
require "lumos/wrapper"
|
8
|
+
require "lumos/core_ext/kernel"
|
9
|
+
require "lumos/version"
|
data/lumos.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lumos/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lumos"
|
8
|
+
spec.version = Lumos::VERSION
|
9
|
+
spec.authors = ["query-string"]
|
10
|
+
spec.email = ["atimofeev@reactant.ru"]
|
11
|
+
spec.summary = "Objects wrapping library"
|
12
|
+
spec.description = "Have you ever tried to highlight your Ruby objects from your controllers/models/whatever in the Rails log? Lumos can easily wrap and make any object perceptible amongs common Rails log mess!"
|
13
|
+
spec.homepage = "https://github.com/query-string/lumos"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "activesupport", "4.2"
|
22
|
+
spec.add_development_dependency "activerecord", "4.2"
|
23
|
+
spec.add_development_dependency "sqlite3", "~> 1.3"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
27
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
|
28
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Establish connection to in-memory SQLite DB
|
2
|
+
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
3
|
+
|
4
|
+
# Create the coffee table
|
5
|
+
ActiveRecord::Migration.verbose = false
|
6
|
+
ActiveRecord::Migration.create_table :coffees do |t|
|
7
|
+
t.string :sort
|
8
|
+
t.integer :price
|
9
|
+
t.integer :saturation
|
10
|
+
end
|
11
|
+
|
12
|
+
# Create model
|
13
|
+
class Coffee < ActiveRecord::Base; end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "active_record_helper"
|
3
|
+
require "set"
|
4
|
+
|
5
|
+
RSpec.describe "Lumos kernel extensions" do
|
6
|
+
context "divider" do
|
7
|
+
it "returns sharps if no arguments defined" do
|
8
|
+
expect { lumos }.to output("###").to_stdout
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns sharps if only pointer defined" do
|
12
|
+
expect { lumos :> }.to output("###").to_stdout
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns delimiter based string" do
|
16
|
+
expect { lumos :>, "-" }.to output("---").to_stdout
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns delimiter based string repeated 10 times" do
|
20
|
+
expect { lumos :>, "@", 10 }.to output("@@@@@@@@@@").to_stdout
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "wrapper" do
|
25
|
+
it "returns wrapped messages if no arguments except message defined" do
|
26
|
+
expect { lumos "Accio" }.to output("#########\n# #\n# Accio #\n# #\n#########").to_stdout
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns bottom positioned message" do
|
30
|
+
expect { lumos "Accio", {position: :bottom, delimiter: "@"} }.to output("Accio\n@@@@@").to_stdout
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "objects" do
|
35
|
+
it "returns wra pped Array" do
|
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##########################################################################").to_stdout
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns wrapped Hash" do
|
40
|
+
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############################################################").to_stdout
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns wrapped Set" do
|
45
|
+
expect { lumos Set.new([1,2,3])}.to output("#####################\n# #\n# #<Set: {1, 2, 3}> #\n# #\n#####################").to_stdout
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns wrapped Struct" do
|
49
|
+
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##############################################################").to_stdout
|
51
|
+
end
|
52
|
+
|
53
|
+
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########################################################").to_stdout
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns wrapped ActiveRecord" do
|
58
|
+
Struct.new("Customer", :name, :address)
|
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
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Base do
|
5
|
+
|
6
|
+
context "subsidary methods" do
|
7
|
+
it "returns number of message characters" do
|
8
|
+
expect(described_class.new(message: "Cave Inimicum").message_length).to eq(13)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns number of short message lines" do
|
12
|
+
expect(described_class.new(message: "Colloportus").chopped_message.size).to eq(1)
|
13
|
+
end
|
14
|
+
|
15
|
+
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)
|
17
|
+
end
|
18
|
+
|
19
|
+
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)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Bottom do
|
5
|
+
context "messages" do
|
6
|
+
it "returns wrapped message" do
|
7
|
+
expect(described_class.new(message: "Langlock").result).to eq("Langlock\n########")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("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######################################################################")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("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###################################")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-padding message" do
|
21
|
+
expect(described_class.new(message: "Levicorpus", padding: 0).result).to eq("Levicorpus\n##########")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit padding message" do
|
25
|
+
expect(described_class.new(message: "Levicorpus", padding: 1).result).to eq("Levicorpus\n\n##########")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Levicorpus", padding: 2).result).to eq("Levicorpus\n\n\n##########")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "delimiters" do
|
34
|
+
it "returns delimiter message" do
|
35
|
+
expect(described_class.new(message: "Legilimens", delimiter: "☯").result).to eq("Legilimens\n☯☯☯☯☯☯☯☯☯☯")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns message with multichar delimiter" do
|
39
|
+
expect(described_class.new(message: "Legilimens", delimiter: "=->").result).to eq("Legilimens\n=->=->=->=")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Horizontal do
|
5
|
+
context "messages" do
|
6
|
+
it "returns message" do
|
7
|
+
expect(described_class.new(message: "Meteolojinx Recanto").result).to eq("###################\nMeteolojinx Recanto\n###################")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("######################################################################\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######################################################################")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("###################################\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###################################")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-padding message" do
|
21
|
+
expect(described_class.new(message: "Mobilicorpus", padding: 0).result).to eq("############\nMobilicorpus\n############")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit message" do
|
25
|
+
expect(described_class.new(message: "Mobilicorpus", padding: 1).result).to eq("############\n\nMobilicorpus\n\n############")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Mobilicorpus", padding: 2).result).to eq("############\n\n\nMobilicorpus\n\n\n############")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "delimiters" do
|
34
|
+
it "returns delimiter message" do
|
35
|
+
expect(described_class.new(message: "Mobiliarbus", delimiter: "❄").result).to eq("❄❄❄❄❄❄❄❄❄❄❄\nMobiliarbus\n❄❄❄❄❄❄❄❄❄❄❄")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns message with multichar delimiter" do
|
39
|
+
expect(described_class.new(message: "Mobiliarbus", delimiter: "=->").result).to eq("=->=->=->=-\nMobiliarbus\n=->=->=->=-")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Left do
|
5
|
+
context "messages" do
|
6
|
+
it "returns wrapped message" do
|
7
|
+
expect(described_class.new(message: "Engorgio").result).to eq("# Engorgio")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("# 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.")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("# 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.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-digit padding message" do
|
21
|
+
expect(described_class.new(message: "Episkey", padding: 0).result).to eq("#Episkey")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit padding message" do
|
25
|
+
expect(described_class.new(message: "Episkey", padding: 1).result).to eq("# Episkey")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Episkey", padding: 2).result).to eq("# Episkey")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns delimiter message" do
|
34
|
+
expect(described_class.new(message: "Ennervate", delimiter: "☭").result).to eq("☭ Ennervate")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Right do
|
5
|
+
context "messages" do
|
6
|
+
it "returns wrapped message" do
|
7
|
+
expect(described_class.new(message: "Ferula").result).to eq("Ferula #")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("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. #")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("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. #")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-padding message" do
|
21
|
+
expect(described_class.new(message: "Finite Incantatum", padding: 0).result).to eq("Finite Incantatum#")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit padding message" do
|
25
|
+
expect(described_class.new(message: "Finite Incantatum", padding: 1).result).to eq("Finite Incantatum #")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Finite Incantatum", padding: 2).result).to eq("Finite Incantatum #")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns delimiter message" do
|
34
|
+
expect(described_class.new(message: "Fidelius", delimiter: "->").result).to eq("Fidelius ->")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Surround do
|
5
|
+
context "messages" do
|
6
|
+
it "returns wrapped message" do
|
7
|
+
expect(described_class.new(message: "Defodio").result).to eq("###########\n# #\n# Defodio #\n# #\n###########")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("##########################################################################\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##########################################################################")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("#######################################\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#######################################")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-digit padding message" do
|
21
|
+
expect(described_class.new(message: "Densaugeo", padding: 0).result).to eq("###########\n#Densaugeo#\n###########")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit padding message" do
|
25
|
+
expect(described_class.new(message: "Densaugeo", padding: 1).result).to eq("#############\n# #\n# Densaugeo #\n# #\n#############")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Densaugeo", padding: 2).result).to eq("###############\n# #\n# #\n# Densaugeo #\n# #\n# #\n###############")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "delimiters" do
|
34
|
+
it "returns delimiter message" do
|
35
|
+
expect(described_class.new(message: "Deletrius", delimiter: "❤").result).to eq("❤❤❤❤❤❤❤❤❤❤❤❤❤\n❤ ❤\n❤ Deletrius ❤\n❤ ❤\n❤❤❤❤❤❤❤❤❤❤❤❤❤")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns message with multichar delimiter" do
|
39
|
+
expect(described_class.new(message: "Deletrius", delimiter: "=->").result).to eq("=->=->=->=->=->=-\n=-> =->\n=-> Deletrius =->\n=-> =->\n=->=->=->=->=->=-")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Top do
|
5
|
+
context "messages" do
|
6
|
+
it "returns wrapped message" do
|
7
|
+
expect(described_class.new(message: "Immobulus").result).to eq("#########\nImmobulus")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("######################################################################\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.")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("###################################\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.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-padding message" do
|
21
|
+
expect(described_class.new(message: "Imperio", padding: 0).result).to eq("#######\nImperio")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit padding message" do
|
25
|
+
expect(described_class.new(message: "Imperio", padding: 1).result).to eq("#######\n\nImperio")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Imperio", padding: 2).result).to eq("#######\n\n\nImperio")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "delimiters" do
|
34
|
+
it "returns delimiter message" do
|
35
|
+
expect(described_class.new(message: "Impedimenta", delimiter: "★").result).to eq("★★★★★★★★★★★\nImpedimenta")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns message with multichar delimiter" do
|
39
|
+
expect(described_class.new(message: "Impedimenta", delimiter: "=->").result).to eq("=->=->=->=-\nImpedimenta")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Formatters::Vertical do
|
5
|
+
context "messages" do
|
6
|
+
it "returns message" do
|
7
|
+
expect(described_class.new(message: "Obliviate").result).to eq("# Obliviate #")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns multiline message" do
|
11
|
+
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.").result).to eq("# 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. #")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns multiline message with defined length" do
|
15
|
+
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: 35).result).to eq("# 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. #")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "paddings" do
|
20
|
+
it "returns zero-padding message" do
|
21
|
+
expect(described_class.new(message: "Oppugno", padding: 0).result).to eq("#Oppugno#")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns 1-digit padding message" do
|
25
|
+
expect(described_class.new(message: "Oppugno", padding: 1).result).to eq("# Oppugno #")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns 2-digits padding message" do
|
29
|
+
expect(described_class.new(message: "Oppugno", padding: 2).result).to eq("# Oppugno #")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns delimiter message" do
|
34
|
+
expect(described_class.new(message: "Obscuro", delimiter: "☢").result).to eq("☢ Obscuro ☢")
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
ENV['CODECLIMATE_REPO_TOKEN'] = "331d5a46a9d322bb39ba65ac61954d3f5453f7eb20ffd4d3825165cf7a2c19c1"
|
2
|
+
require "codeclimate-test-reporter"
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
|
5
|
+
require "active_record"
|
6
|
+
require "lumos"
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# Use color in STDOUT
|
10
|
+
config.color = true
|
11
|
+
|
12
|
+
# Use color not only in STDOUT but also in pagers and files
|
13
|
+
config.tty = true
|
14
|
+
|
15
|
+
# Use the specified formatter
|
16
|
+
config.formatter = :documentation # :progress, :html, :textmate
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Lumos::Wrapper do
|
5
|
+
context "position" do
|
6
|
+
it "returns surround if position was not defined" do
|
7
|
+
expect(described_class.new("Aguamenti").position).to eq(:surround)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "raises an ArgumentError exception if wrong position defined" do
|
11
|
+
expect { described_class.new("Avada Kedavra", {position: :unknown}) }.to raise_error(ArgumentError)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "service methods" do
|
16
|
+
it "instantiates class based on defined position" do
|
17
|
+
expect(described_class.new("Alohomora", {position: :left}).formatter.class).to eq(Lumos::Formatters::Left)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "missing methods" do
|
22
|
+
it "returns left positioned message" do
|
23
|
+
expect(described_class.new("Anapneo").left).to eq("# Anapneo")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns bottom positioned message" do
|
27
|
+
expect(described_class.new("Aparecium").bottom).to eq("Aparecium\n#########")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lumos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- query-string
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: codeclimate-test-reporter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.4'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.4'
|
111
|
+
description: Have you ever tried to highlight your Ruby objects from your controllers/models/whatever
|
112
|
+
in the Rails log? Lumos can easily wrap and make any object perceptible amongs common
|
113
|
+
Rails log mess!
|
114
|
+
email:
|
115
|
+
- atimofeev@reactant.ru
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- TODO.md
|
127
|
+
- lib/lumos.rb
|
128
|
+
- lib/lumos/core_ext/kernel.rb
|
129
|
+
- lib/lumos/formatters/base.rb
|
130
|
+
- lib/lumos/formatters/base_chopper.rb
|
131
|
+
- lib/lumos/formatters/base_horizontal.rb
|
132
|
+
- lib/lumos/formatters/bottom.rb
|
133
|
+
- lib/lumos/formatters/horizontal.rb
|
134
|
+
- lib/lumos/formatters/left.rb
|
135
|
+
- lib/lumos/formatters/right.rb
|
136
|
+
- lib/lumos/formatters/surround.rb
|
137
|
+
- lib/lumos/formatters/top.rb
|
138
|
+
- lib/lumos/formatters/vertical.rb
|
139
|
+
- lib/lumos/version.rb
|
140
|
+
- lib/lumos/wrapper.rb
|
141
|
+
- lumos.gemspec
|
142
|
+
- spec/active_record_helper.rb
|
143
|
+
- spec/core_ext/kernel_spec.rb
|
144
|
+
- spec/formatters/base_spec.rb
|
145
|
+
- spec/formatters/bottom_spec.rb
|
146
|
+
- spec/formatters/horizontal_spec.rb
|
147
|
+
- spec/formatters/left_spec.rb
|
148
|
+
- spec/formatters/right_spec.rb
|
149
|
+
- spec/formatters/surround_spec.rb
|
150
|
+
- spec/formatters/top_spec.rb
|
151
|
+
- spec/formatters/vertical_spec.rb
|
152
|
+
- spec/spec_helper.rb
|
153
|
+
- spec/wrapper_spec.rb
|
154
|
+
homepage: https://github.com/query-string/lumos
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata: {}
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.2.2
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Objects wrapping library
|
178
|
+
test_files:
|
179
|
+
- spec/active_record_helper.rb
|
180
|
+
- spec/core_ext/kernel_spec.rb
|
181
|
+
- spec/formatters/base_spec.rb
|
182
|
+
- spec/formatters/bottom_spec.rb
|
183
|
+
- spec/formatters/horizontal_spec.rb
|
184
|
+
- spec/formatters/left_spec.rb
|
185
|
+
- spec/formatters/right_spec.rb
|
186
|
+
- spec/formatters/surround_spec.rb
|
187
|
+
- spec/formatters/top_spec.rb
|
188
|
+
- spec/formatters/vertical_spec.rb
|
189
|
+
- spec/spec_helper.rb
|
190
|
+
- spec/wrapper_spec.rb
|