larva 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/larva/utils.rb +23 -0
- data/lib/larva/version.rb +1 -1
- data/test/utils_test.rb +19 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfaa4b9a6ff919d5f0aa1612a1c10f5b4f79f80a
|
4
|
+
data.tar.gz: ea1caa084a630cd2d8397e6621f6c1f2ce6e80f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dd87a1aee18fa7fe46afd0d40d5e80366bef6543bb1fdb088924c8f9f9ca3626f888212a82ac4a72dc72a89f461d17fe83b290342d6accbf4d0b4a8b1e6c080
|
7
|
+
data.tar.gz: 3801c9bad24bb8d427eb28297b8051c5f7e76072e6e37f96ade3dd26c9dda4d7bbea5a52de1205fde404437959c6558eb0fac0931fcb09a05e57adc695df720d
|
data/CHANGELOG.md
CHANGED
data/lib/larva/utils.rb
CHANGED
@@ -3,3 +3,26 @@ class Object
|
|
3
3
|
respond_to?(:empty?) ? !!empty? : !self
|
4
4
|
end
|
5
5
|
end
|
6
|
+
|
7
|
+
class String
|
8
|
+
def camelize(first_letter = :upper)
|
9
|
+
case first_letter
|
10
|
+
when :upper
|
11
|
+
Larva::Utils.camelize(self, true)
|
12
|
+
when :lower
|
13
|
+
Larva::Utils.camelize(self, false)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Larva
|
19
|
+
module Utils
|
20
|
+
def self.camelize(term, uppercase_first_letter = true)
|
21
|
+
string = term.to_s
|
22
|
+
string = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
23
|
+
string.gsub!(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }
|
24
|
+
string.gsub!('/', '::')
|
25
|
+
string
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/larva/version.rb
CHANGED
data/test/utils_test.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Larva
|
4
|
+
class UtilsTest < Minitest::Test
|
5
|
+
def test_blank?
|
6
|
+
assert "".blank?
|
7
|
+
assert nil.blank?
|
8
|
+
refute "foobar".blank?
|
9
|
+
refute 0.blank?
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_camelize
|
13
|
+
assert_equal "Foobar", "foobar".camelize
|
14
|
+
assert_equal "FooBar", "foo_bar".camelize
|
15
|
+
assert_equal "Foo::Bar", "foo/bar".camelize
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: larva
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iHiD
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- test/mocker_test.rb
|
152
152
|
- test/processor_test.rb
|
153
153
|
- test/test_helper.rb
|
154
|
+
- test/utils_test.rb
|
154
155
|
- test/worker_pool_test.rb
|
155
156
|
homepage: https://github.com/meducation/larva
|
156
157
|
licenses:
|
@@ -187,5 +188,6 @@ test_files:
|
|
187
188
|
- test/mocker_test.rb
|
188
189
|
- test/processor_test.rb
|
189
190
|
- test/test_helper.rb
|
191
|
+
- test/utils_test.rb
|
190
192
|
- test/worker_pool_test.rb
|
191
193
|
has_rdoc:
|