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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68a96f261d17f5d2b04b2854769c97b5d00bea30
4
- data.tar.gz: dedd852862742d2589b9a9709a53925ba5417d31
3
+ metadata.gz: 965f675b371254bb25cb51d30a81f16fef5c97bc
4
+ data.tar.gz: 1ac02582e05100cb54732be6add7f86c86bd109f
5
5
  SHA512:
6
- metadata.gz: ae6cdbb243009c56a924cf32e7e0ce984001ab383d92e6ea612346ae46818ef50ee2a2a6eb9e0cba9c9337db751a0260e57ed8e0a45713b83b258c6fe1c2178d
7
- data.tar.gz: 5eeca462d9e01fa85fe6074ad5111e20ce045f2e51c373c5070bca9448c230243263c5f339eb996664af921a1b592275d731789543e7525af8421e985185da38
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
- # Gemfile.lock
48
- # .ruby-version
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:
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.10
4
+ - 2.5.1
5
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+ gem 'alki-testing'
@@ -0,0 +1,5 @@
1
+ = Alki::Support
2
+
3
+ image:https://travis-ci.org/alki-project/alki-support.svg?branch=master["Build Status", link="https://travis-ci.org/alki-project/alki-support"]
4
+
5
+ Small collection of support methods for Alki.
@@ -0,0 +1,3 @@
1
+ require 'alki/testing/tasks'
2
+
3
+ task default: [:test]
@@ -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 = "https://github.com/medlefsen/alki-support"
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) }
@@ -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')
@@ -1,5 +1,5 @@
1
1
  module Alki
2
2
  module Support
3
- VERSION = '0.7.0'
3
+ VERSION = '0.7.1'
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ class Bar
2
+
3
+ end
@@ -0,0 +1,6 @@
1
+ $foo_loaded += 1
2
+
3
+ module AlkiTest
4
+ class Foo
5
+ end
6
+ end
@@ -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.0
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: 2016-12-29 00:00:00.000000000 Z
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
- homepage: https://github.com/medlefsen/alki-support
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: '0'
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.5.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