alki-support 0.7.0 → 0.7.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 +4 -4
- data/.gitignore +2 -2
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/README.adoc +5 -0
- data/Rakefile +3 -0
- data/alki-support.gemspec +2 -1
- data/lib/alki/support.rb +0 -5
- data/lib/alki/support/version.rb +1 -1
- data/test/fixtures/lib/alki_test/bar.rb +3 -0
- data/test/fixtures/lib/alki_test/foo.rb +6 -0
- data/test/test_helper.rb +1 -0
- data/test/unit/alk_support_test.rb +122 -0
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 965f675b371254bb25cb51d30a81f16fef5c97bc
|
4
|
+
data.tar.gz: 1ac02582e05100cb54732be6add7f86c86bd109f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c19dac55ece903cf0d45dd6dc16e735882c24c61015e5f1b992a02c2888696424fa3e42cd6ed38bec6e79a3e7df2431823384d03b2faa14a6a734268b72479
|
7
|
+
data.tar.gz: 3e6ca9aa5c9c23ecd0ae4640a026eb4ff51d04221b2565d046fef4e065904d56e4978100a1f38c075e6144cee5566b71659ab8d7f5eaceca45f5bc0588114af7
|
data/.gitignore
CHANGED
@@ -44,8 +44,8 @@ build-iPhoneSimulator/
|
|
44
44
|
|
45
45
|
# for a library or gem, you might want to ignore these files since the code is
|
46
46
|
# intended to run in multiple environments; otherwise, check them in:
|
47
|
-
|
48
|
-
|
47
|
+
Gemfile.lock
|
48
|
+
.ruby-version
|
49
49
|
# .ruby-gemset
|
50
50
|
|
51
51
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.adoc
ADDED
data/Rakefile
ADDED
data/alki-support.gemspec
CHANGED
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.email = ["matt.edlefsen@gmail.com"]
|
9
9
|
spec.summary = %q{Alki support methods}
|
10
10
|
spec.description = %q{Various helper methods for Alki}
|
11
|
-
spec.homepage = "
|
11
|
+
spec.homepage = "http://github.com/medlefsen/alki-support"
|
12
12
|
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = '>= 2.1.0'
|
13
14
|
|
14
15
|
spec.files = `git ls-files -z`.split("\x0")
|
15
16
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/lib/alki/support.rb
CHANGED
@@ -42,11 +42,6 @@ module Alki
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def self.caller_path(root,caller_depth: 1)
|
46
|
-
path = caller_locations(caller_depth+1,1)[0].absolute_path
|
47
|
-
path_name path, root
|
48
|
-
end
|
49
|
-
|
50
45
|
def self.path_name(path,root=File.dirname(path))
|
51
46
|
root = File.join(root,'')
|
52
47
|
if path.start_with?(root) && path.end_with?('.rb')
|
data/lib/alki/support/version.rb
CHANGED
data/test/test_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$LOAD_PATH << Alki::Test.fixture_path('lib')
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'alki/test'
|
2
|
+
|
3
|
+
require 'alki/support'
|
4
|
+
|
5
|
+
describe Alki::Support do
|
6
|
+
after do
|
7
|
+
Object.send :remove_const, :AlkiTest if defined? AlkiTest
|
8
|
+
end
|
9
|
+
|
10
|
+
describe :load do
|
11
|
+
before do
|
12
|
+
$foo_loaded = 1
|
13
|
+
@saved_features = $LOADED_FEATURES.dup
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
$LOADED_FEATURES.replace @saved_features
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should require named file' do
|
21
|
+
$foo_loaded.must_equal 1
|
22
|
+
Alki::Support.load('alki_test/foo')
|
23
|
+
$foo_loaded.must_equal 2
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should be return the class in the named file' do
|
27
|
+
Alki::Support.load('alki_test/foo').name.must_equal 'AlkiTest::Foo'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return nil if the class cant be found' do
|
31
|
+
Alki::Support.load('alki_test/bar').must_be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should raise load error if file cant be found' do
|
35
|
+
assert_raises LoadError do
|
36
|
+
Alki::Support.load('alki_test/foobar')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe :create_constant do
|
42
|
+
it 'should create the named constant and assigned the value to it' do
|
43
|
+
Alki::Support.create_constant 'AlkiTest::C1', :c1
|
44
|
+
AlkiTest::C1.must_equal :c1
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should create intermediate modules as necessary' do
|
48
|
+
Alki::Support.create_constant 'AlkiTest::M1::C1', :c1
|
49
|
+
AlkiTest::M1::C1.must_equal :c1
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can use a different parent module' do
|
53
|
+
m = Module.new
|
54
|
+
Alki::Support.create_constant 'AlkiTest::C1', :c1, m
|
55
|
+
refute defined?(AlkiTest::C1)
|
56
|
+
m::AlkiTest::C1.must_equal :c1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe :classify do
|
61
|
+
it 'should capitalize words and remove underscores' do
|
62
|
+
Alki::Support.classify('my_class_name').must_equal 'MyClassName'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should convert forward slashes to double colons' do
|
66
|
+
Alki::Support.classify('a/b/c').must_equal 'A::B::C'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe :constantize do
|
71
|
+
it 'should lookup constant based on string name' do
|
72
|
+
module AlkiTest
|
73
|
+
class Foo
|
74
|
+
end
|
75
|
+
end
|
76
|
+
Alki::Support.constantize('AlkiTest::Foo').must_be_same_as AlkiTest::Foo
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should allow looking constant up with a given root module' do
|
80
|
+
m = Module.new do
|
81
|
+
module self::AlkiTest
|
82
|
+
class Foo
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
refute(defined?(AlkiTest::Foo))
|
87
|
+
Alki::Support.constantize('AlkiTest::Foo',m).must_be_same_as m::AlkiTest::Foo
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe :path_name do
|
92
|
+
it 'should return basename of path' do
|
93
|
+
Alki::Support.path_name('/a/foo.rb').must_equal 'foo'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should take an optional root to return the name from' do
|
97
|
+
Alki::Support.path_name('/a/foo/bar.rb','/a').must_equal 'foo/bar'
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should return nil if path is not in root' do
|
101
|
+
Alki::Support.path_name('/a/foo/bar.rb','/b').must_be_nil
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return nil if path is not a ruby file' do
|
105
|
+
Alki::Support.path_name('/a/foo/bar.py').must_be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe :find_root do
|
110
|
+
it 'should find first parent directory where given block evaluates to true' do
|
111
|
+
Alki::Support.find_root fixture_path('lib','alki_test') do |dir|
|
112
|
+
File.exist?(File.join(dir,'lib'))
|
113
|
+
end.must_equal fixtures_path
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should return nil if never found' do
|
117
|
+
Alki::Support.find_root fixture_path('lib','alki_test') do |dir|
|
118
|
+
false
|
119
|
+
end.must_be_nil
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alki-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Edlefsen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Various helper methods for Alki
|
14
14
|
email:
|
@@ -18,10 +18,18 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
+
- ".travis.yml"
|
22
|
+
- Gemfile
|
23
|
+
- README.adoc
|
24
|
+
- Rakefile
|
21
25
|
- alki-support.gemspec
|
22
26
|
- lib/alki/support.rb
|
23
27
|
- lib/alki/support/version.rb
|
24
|
-
|
28
|
+
- test/fixtures/lib/alki_test/bar.rb
|
29
|
+
- test/fixtures/lib/alki_test/foo.rb
|
30
|
+
- test/test_helper.rb
|
31
|
+
- test/unit/alk_support_test.rb
|
32
|
+
homepage: http://github.com/medlefsen/alki-support
|
25
33
|
licenses:
|
26
34
|
- MIT
|
27
35
|
metadata: {}
|
@@ -33,7 +41,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
41
|
requirements:
|
34
42
|
- - ">="
|
35
43
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
44
|
+
version: 2.1.0
|
37
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
46
|
requirements:
|
39
47
|
- - ">="
|
@@ -41,8 +49,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
49
|
version: '0'
|
42
50
|
requirements: []
|
43
51
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.
|
52
|
+
rubygems_version: 2.6.12
|
45
53
|
signing_key:
|
46
54
|
specification_version: 4
|
47
55
|
summary: Alki support methods
|
48
|
-
test_files:
|
56
|
+
test_files:
|
57
|
+
- test/fixtures/lib/alki_test/bar.rb
|
58
|
+
- test/fixtures/lib/alki_test/foo.rb
|
59
|
+
- test/test_helper.rb
|
60
|
+
- test/unit/alk_support_test.rb
|