lotus-utils 0.1.1 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +49 -0
- data/README.md +2 -3
- data/lib/lotus/utils/callbacks.rb +36 -4
- data/lib/lotus/utils/kernel.rb +235 -109
- data/lib/lotus/utils/load_paths.rb +149 -0
- data/lib/lotus/utils/string.rb +18 -0
- data/lib/lotus/utils/version.rb +1 -1
- data/lotus-utils.gemspec +2 -2
- metadata +6 -31
- data/.gitignore +0 -20
- data/.travis.yml +0 -6
- data/.yardopts +0 -3
- data/CONTRIBUTING.md +0 -44
- data/Gemfile +0 -10
- data/Rakefile +0 -17
- data/test/callbacks_test.rb +0 -213
- data/test/class_attribute_test.rb +0 -132
- data/test/class_test.rb +0 -47
- data/test/hash_test.rb +0 -35
- data/test/io_test.rb +0 -29
- data/test/kernel_test.rb +0 -1752
- data/test/path_prefix_test.rb +0 -68
- data/test/string_test.rb +0 -75
- data/test/test_helper.rb +0 -20
- data/test/version_test.rb +0 -7
data/test/path_prefix_test.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'lotus/utils/path_prefix'
|
3
|
-
|
4
|
-
describe Lotus::Utils::PathPrefix do
|
5
|
-
it 'exposes itself as a string' do
|
6
|
-
prefix = Lotus::Utils::PathPrefix.new
|
7
|
-
prefix.must_equal ''
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'adds root prefix only when needed' do
|
11
|
-
prefix = Lotus::Utils::PathPrefix.new('/fruits')
|
12
|
-
prefix.must_equal '/fruits'
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#join' do
|
16
|
-
it 'joins a string' do
|
17
|
-
prefix = Lotus::Utils::PathPrefix.new('fruits')
|
18
|
-
prefix.join('peaches').must_equal '/fruits/peaches'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'joins a prefixed string' do
|
22
|
-
prefix = Lotus::Utils::PathPrefix.new('fruits')
|
23
|
-
prefix.join('/cherries').must_equal '/fruits/cherries'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'joins a string when the root is blank' do
|
27
|
-
prefix = Lotus::Utils::PathPrefix.new
|
28
|
-
prefix.join('tea').must_equal '/tea'
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'joins a prefixed string when the root is blank' do
|
32
|
-
prefix = Lotus::Utils::PathPrefix.new
|
33
|
-
prefix.join('/tea').must_equal '/tea'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#relative_join' do
|
38
|
-
it 'joins a string without prefixing with separator' do
|
39
|
-
prefix = Lotus::Utils::PathPrefix.new('fruits')
|
40
|
-
prefix.relative_join('peaches').must_equal 'fruits/peaches'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'joins a prefixed string without prefixing with separator' do
|
44
|
-
prefix = Lotus::Utils::PathPrefix.new('fruits')
|
45
|
-
prefix.relative_join('/cherries').must_equal 'fruits/cherries'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'joins a string when the root is blank without prefixing with separator' do
|
49
|
-
prefix = Lotus::Utils::PathPrefix.new
|
50
|
-
prefix.relative_join('tea').must_equal 'tea'
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'joins a prefixed string when the root is blank and removes the prefix' do
|
54
|
-
prefix = Lotus::Utils::PathPrefix.new
|
55
|
-
prefix.relative_join('/tea').must_equal 'tea'
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'joins a string with custom separator' do
|
59
|
-
prefix = Lotus::Utils::PathPrefix.new('fruits')
|
60
|
-
prefix.relative_join('cherries', '_').must_equal 'fruits_cherries'
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'joins a prefixed string without prefixing with custom separator' do
|
64
|
-
prefix = Lotus::Utils::PathPrefix.new('fruits')
|
65
|
-
prefix.relative_join('_cherries', '_').must_equal 'fruits_cherries'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/test/string_test.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'lotus/utils/string'
|
3
|
-
|
4
|
-
describe Lotus::Utils::String do
|
5
|
-
describe '#classify' do
|
6
|
-
it 'returns a classified string' do
|
7
|
-
Lotus::Utils::String.new('lotus').classify.must_equal('Lotus')
|
8
|
-
Lotus::Utils::String.new('lotus_router').classify.must_equal('LotusRouter')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns a classified string from symbol' do
|
12
|
-
Lotus::Utils::String.new(:lotus).classify.must_equal('Lotus')
|
13
|
-
Lotus::Utils::String.new(:lotus_router).classify.must_equal('LotusRouter')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#underscore' do
|
18
|
-
it 'keep self untouched' do
|
19
|
-
string = Lotus::Utils::String.new('Lotus')
|
20
|
-
string.underscore
|
21
|
-
string.must_equal 'Lotus'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'removes all the upcase characters' do
|
25
|
-
string = Lotus::Utils::String.new('Lotus')
|
26
|
-
string.underscore.must_equal 'lotus'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'transforms camel case class names' do
|
30
|
-
string = Lotus::Utils::String.new('LotusView')
|
31
|
-
string.underscore.must_equal 'lotus_view'
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'substitutes double colons with path separators' do
|
35
|
-
string = Lotus::Utils::String.new('Lotus::View')
|
36
|
-
string.underscore.must_equal 'lotus/view'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#demodulize' do
|
41
|
-
it 'returns the class name without the namespace' do
|
42
|
-
Lotus::Utils::String.new('String').demodulize.must_equal('String')
|
43
|
-
Lotus::Utils::String.new('Lotus::Utils::String').demodulize.must_equal('String')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#tokenize' do
|
48
|
-
before do
|
49
|
-
@logger = []
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'calls the given block for each token occurrence' do
|
53
|
-
string = Lotus::Utils::String.new('Lotus::(Utils|App)')
|
54
|
-
string.tokenize do |token|
|
55
|
-
@logger.push token
|
56
|
-
end
|
57
|
-
|
58
|
-
@logger.must_equal(['Lotus::Utils', 'Lotus::App'])
|
59
|
-
end
|
60
|
-
|
61
|
-
it "guarantees the block to be called even when the token conditions aren't met" do
|
62
|
-
string = Lotus::Utils::String.new('Lotus')
|
63
|
-
string.tokenize do |token|
|
64
|
-
@logger.push token
|
65
|
-
end
|
66
|
-
|
67
|
-
@logger.must_equal(['Lotus'])
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'returns nil' do
|
71
|
-
result = Lotus::Utils::String.new('Lotus::(Utils|App)').tokenize { }
|
72
|
-
result.must_be_nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
if ENV['COVERAGE'] == 'true'
|
5
|
-
require 'simplecov'
|
6
|
-
require 'coveralls'
|
7
|
-
|
8
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
|
-
SimpleCov::Formatter::HTMLFormatter,
|
10
|
-
Coveralls::SimpleCov::Formatter
|
11
|
-
]
|
12
|
-
|
13
|
-
SimpleCov.start do
|
14
|
-
command_name 'test'
|
15
|
-
add_filter 'test'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
require 'minitest/autorun'
|
20
|
-
$:.unshift 'lib'
|