require_module 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8de7ec307473e3260046abee12619a9b4239b406dffd7cb7680c5c44852e4c4f
4
- data.tar.gz: 397cc6e76d6463b7395ae604acaebaf6e21c9ea8fdcff31a691fce13ac9a0892
3
+ metadata.gz: a5492d76df85e6cc8e6b6f1bef49db9d6bd67190edbf0b2c784cf902bda17ba0
4
+ data.tar.gz: 6fe79ec0348c9f2f8c0459da69ea2d88d55276c38621410ade8407a8617138e0
5
5
  SHA512:
6
- metadata.gz: '019281db025c320f5c98a143549ba6c034276ab8a94e8166d597128620821056305e0c9474f64a42459f6718fbeebfee541d13657a6dae5ef322befb70697a0d'
7
- data.tar.gz: 328e26a5698c513c00f5d3fca278f7c53dca358f1697f2d3e738dc00aa06aaa2b95a3945f19a979794c44d3c5f70c9edbffd163cda35fd34e815bdd76459de56
6
+ metadata.gz: 6eaf83ad94c4eb0a3c5a51ec96651c0b6425b0b4122ebcf96ac9269fc83841d7e6cef52de7f39ad29ff184111a973f1ec55e6a70a0c119f1049a26323999a49d
7
+ data.tar.gz: e33c2fecf8f4413a700ea0b6389a993925d118b946a42f02735921129c41b944d413600334f560430f0c04ca81c74fb462552d7a894413b456af17cae7993758
data/Gemfile CHANGED
@@ -1,5 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
- gem 'coveralls', require: false
5
- gem 'pry', require: false
4
+
5
+ group :test do
6
+ gem 'coveralls'
7
+ gem 'pry'
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'simplecov'
11
+ end
@@ -16,8 +16,9 @@ module RequireModule
16
16
  # require_module('/home/user/rubyapp/lib', cache: false) # returns #<Module:0000012312>
17
17
  # require_module('/home/user/rubyapp/lib') # returns :HomeUserRubyappLib
18
18
  def require_module(fullpath, cache: true)
19
- with_ext = add_ext(fullpath)
20
- without_ext = rem_ext(fullpath)
19
+ path = fullpath.to_s
20
+ with_ext = add_ext(path)
21
+ without_ext = rem_ext(path)
21
22
 
22
23
  if cache
23
24
  constant_name =
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'require_module'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.authors = ['Sergey Homa']
5
5
  s.email = 'melgaardbjorn@gmail.com'
6
6
  s.summary = 'Evaluates file content inside Module.new, with cache'
@@ -11,47 +11,101 @@ describe 'require_module_relative' do
11
11
  unload_all_matching(/FixturesSomeLib/)
12
12
  end
13
13
 
14
- it 'without ext' do
15
- mod = require_module_relative './fixtures/some_lib'
14
+ context 'require_module_relative' do
15
+ it 'without ext' do
16
+ mod = require_module_relative './fixtures/some_lib'
16
17
 
17
- expect(mod.inspect).to end_with 'FixturesSomeLib'
18
- expect(mod.some_fn).to eq 'some_val'
19
- end
18
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
19
+ expect(mod.some_fn).to eq 'some_val'
20
+ end
20
21
 
21
- it 'with ext' do
22
- mod = require_module_relative './fixtures/some_lib.rb'
22
+ it 'with ext' do
23
+ mod = require_module_relative './fixtures/some_lib.rb'
23
24
 
24
- expect(mod.inspect).to end_with 'FixturesSomeLib'
25
- expect(mod.some_fn).to eq 'some_val'
26
- end
25
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
26
+ expect(mod.some_fn).to eq 'some_val'
27
+ end
27
28
 
28
- it "raises NameError if dependencies can't be resolved" do
29
- expect do
30
- require_module_relative './unresolveable'
31
- end.to raise_error(LoadError)
32
- end
29
+ it 'pathname without ext' do
30
+ mod = require_module_relative(Pathname.new('./fixtures/some_lib'))
31
+
32
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
33
+ expect(mod.some_fn).to eq 'some_val'
34
+ end
33
35
 
34
- it 'test cache' do
35
- mod = require_module_relative './fixtures/some_lib'
36
- mod2 = require_module_relative './fixtures/some_lib'
36
+ it 'pathname with ext' do
37
+ mod = require_module_relative(Pathname.new('./fixtures/some_lib.rb'))
37
38
 
38
- expect(mod.inspect).to end_with 'FixturesSomeLib'
39
- expect(mod2.inspect).to end_with 'FixturesSomeLib'
39
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
40
+ expect(mod.some_fn).to eq 'some_val'
41
+ end
40
42
 
41
- expect(mod <=> mod2).to eq 0
43
+ it "raises NameError if dependencies can't be resolved" do
44
+ expect do
45
+ require_module_relative './unresolveable'
46
+ end.to raise_error(LoadError)
47
+ end
42
48
  end
43
49
 
44
- it 'test without cache' do
45
- mod = require_module_relative('./fixtures/some_lib.rb', cache: false)
50
+ context 'require_module' do
51
+ it 'without ext' do
52
+ mod = require_module(File.dirname(__FILE__) + '/fixtures/some_lib')
53
+
54
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
55
+ expect(mod.some_fn).to eq 'some_val'
56
+ end
57
+
58
+ it 'with ext' do
59
+ mod = require_module(File.dirname(__FILE__) + '/fixtures/some_lib.rb')
60
+
61
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
62
+ expect(mod.some_fn).to eq 'some_val'
63
+ end
64
+
65
+ it 'pathname without ext' do
66
+ mod = require_module(Pathname.new(File.dirname(__FILE__) + '/fixtures/some_lib'))
46
67
 
47
- expect(mod.inspect).to start_with '#<Module:'
48
- expect(mod.some_fn).to eq 'some_val'
68
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
69
+ expect(mod.some_fn).to eq 'some_val'
70
+ end
71
+
72
+ it 'pathname with ext' do
73
+ mod = require_module(Pathname.new(File.dirname(__FILE__) + '/fixtures/some_lib.rb'))
74
+
75
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
76
+ expect(mod.some_fn).to eq 'some_val'
77
+ end
78
+
79
+ it "raises NameError if dependencies can't be resolved" do
80
+ expect do
81
+ require_module './unresolveable'
82
+ end.to raise_error(LoadError)
83
+ end
49
84
  end
50
85
 
51
- it 'test without cache and ext' do
52
- mod = require_module_relative('./fixtures/some_lib', cache: false)
86
+ context 'test cache' do
87
+ it 'test with cache' do
88
+ mod = require_module_relative './fixtures/some_lib'
89
+ mod2 = require_module_relative './fixtures/some_lib'
90
+
91
+ expect(mod.inspect).to end_with 'FixturesSomeLib'
92
+ expect(mod2.inspect).to end_with 'FixturesSomeLib'
93
+
94
+ expect(mod <=> mod2).to eq 0
95
+ end
96
+
97
+ it 'test without cache' do
98
+ mod = require_module_relative('./fixtures/some_lib.rb', cache: false)
99
+
100
+ expect(mod.inspect).to start_with '#<Module:'
101
+ expect(mod.some_fn).to eq 'some_val'
102
+ end
103
+
104
+ it 'test without cache and ext' do
105
+ mod = require_module_relative('./fixtures/some_lib', cache: false)
53
106
 
54
- expect(mod.inspect).to start_with '#<Module:'
55
- expect(mod.some_fn).to eq 'some_val'
107
+ expect(mod.inspect).to start_with '#<Module:'
108
+ expect(mod.some_fn).to eq 'some_val'
109
+ end
56
110
  end
57
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_module
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Homa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-01-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: melgaardbjorn@gmail.com