lotus-utils 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
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
@@ -0,0 +1,15 @@
1
+ $:.unshift 'lib'
2
+
3
+ if ENV['COVERAGE']
4
+ require 'simplecov'
5
+ SimpleCov.start do
6
+ add_filter 'test'
7
+ command_name 'Mintest'
8
+ end
9
+ end
10
+
11
+ require 'rubygems'
12
+ require 'bundler/setup'
13
+ require 'coveralls'
14
+ Coveralls.wear!
15
+ require 'minitest/autorun'
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ describe Lotus::Utils::VERSION do
4
+ it 'exposes version' do
5
+ Lotus::Utils::VERSION.must_equal '0.1.0'
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lotus-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-01 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,32 +28,51 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
41
- description: Ruby core extentions and class utilities for Lotus
40
+ version: '10'
41
+ description: Lotus utilities
42
42
  email:
43
43
  - me@lucaguidi.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".coveralls.yml"
48
49
  - ".gitignore"
50
+ - ".travis.yml"
51
+ - ".yardopts"
49
52
  - Gemfile
50
53
  - LICENSE.txt
51
54
  - README.md
52
55
  - Rakefile
53
56
  - lib/lotus/utils.rb
57
+ - lib/lotus/utils/callbacks.rb
58
+ - lib/lotus/utils/class.rb
59
+ - lib/lotus/utils/class_attribute.rb
60
+ - lib/lotus/utils/hash.rb
61
+ - lib/lotus/utils/io.rb
62
+ - lib/lotus/utils/path_prefix.rb
63
+ - lib/lotus/utils/string.rb
54
64
  - lib/lotus/utils/version.rb
55
65
  - lotus-utils.gemspec
56
- homepage: ''
66
+ - test/callbacks_test.rb
67
+ - test/class_attribute_test.rb
68
+ - test/class_test.rb
69
+ - test/hash_test.rb
70
+ - test/io_test.rb
71
+ - test/path_prefix_test.rb
72
+ - test/string_test.rb
73
+ - test/test_helper.rb
74
+ - test/version_test.rb
75
+ homepage: http://lotusrb.org
57
76
  licenses:
58
77
  - MIT
59
78
  metadata: {}
@@ -76,5 +95,15 @@ rubyforge_project:
76
95
  rubygems_version: 2.2.0
77
96
  signing_key:
78
97
  specification_version: 4
79
- summary: Ruby core extentions and class utilities for Lotus
80
- test_files: []
98
+ summary: Ruby core extentions and Louts utilities
99
+ test_files:
100
+ - test/callbacks_test.rb
101
+ - test/class_attribute_test.rb
102
+ - test/class_test.rb
103
+ - test/hash_test.rb
104
+ - test/io_test.rb
105
+ - test/path_prefix_test.rb
106
+ - test/string_test.rb
107
+ - test/test_helper.rb
108
+ - test/version_test.rb
109
+ has_rdoc: