modules 0.0.0 → 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +13 -5
  2. data/lib/modules.rb +11 -9
  3. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c6fe69b584dd67b680c7ea8094ab647f5aa72c3d
4
- data.tar.gz: bb47241b23b0558f8037723d60dc65470f497fd6
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDhlZDkxNjg1MDc3OTRlNWI3Mjk2NjkzZjlhM2Q4OWFjZWQ2ZWUwMw==
5
+ data.tar.gz: !binary |-
6
+ MjYzYzQxYTU3NGRkZjllYjU2OGIxMTNkMmQ4ZmNjZmI3NmI1YjUyMg==
5
7
  SHA512:
6
- metadata.gz: dac58c001385704014080242a57743b8ce9ef2ae3161c49f172fd143190a2efc0a41a1c560731712563ff301e477ee82fea9e8757695ae778075ce6e56006c90
7
- data.tar.gz: 37e216b608f45789f248ad0543005ecc0db928cf0d66bd6d01caea4dc07179818385f47656fdcc9f6df9d066d5c42f0169de0e78457e27fd1b900c0e8f07233d
8
+ metadata.gz: !binary |-
9
+ ZTAxY2JlOWVkY2IxZGQ5OGZhZmMzYjEwYjIwOTYyN2M2NjhhMDBkOGUwOTk2
10
+ ZWRiNzBhNzQxMTdjYjEzYTdkOTJkZGNlZjhkNzFiN2I3ODkxNGM4ZWNiOWZm
11
+ MGNiZTZkZWUwYThkODExM2FlMGNkNWY3ZjU0MzFmYWFhYjdkOGU=
12
+ data.tar.gz: !binary |-
13
+ MDEyOGVlM2ZhZmUzNWEyMDY3NGU1ODVhOGNiNzg2ZWE2OTM2MTViNmVmZDVm
14
+ ZjFiMjQwMzdmMWZiOTA5Y2I0MzY4ZGRhZDRmN2VhZWY5NGM1NGU2YTA2Njcw
15
+ MTdiYTNlMWQxODA1ZjNjOTJmZjhhN2FjMGVlM2JkNzk5NjRhODU=
data/lib/modules.rb CHANGED
@@ -35,18 +35,11 @@ module Modules
35
35
  return @cache[name]
36
36
  end
37
37
 
38
- sym = name.to_sym
39
- if Module.constants.include? sym
40
- puts "Already loaded external module #{name}"
41
- resolved = eval name
42
- @cache[name] = resolved
43
- return resolved
44
- end
45
-
46
38
  puts "Loading external module #{name}"
47
39
  snapshot = Module.constants
48
40
  require name
49
41
  defined = Module.constants - snapshot
42
+ p defined
50
43
  plucked = []
51
44
  resolved = {}
52
45
  while defined.length > 0
@@ -57,7 +50,16 @@ module Modules
57
50
  next if const.nil?
58
51
  resolved[str] = const.class == Module ? Class.new.extend(const) : const
59
52
  if const.respond_to? :constants
60
- defined += const.constants.map {|child| "#{str}::#{child.to_s}"}
53
+ children = const
54
+ .constants
55
+ .map {|child| "#{str}::#{child.to_s}"}
56
+ .select {|id|
57
+ parts = id.split '::'
58
+ groups = parts.group_by {|x| x}
59
+ groups.values.all? {|group| group.length < 3}
60
+ }
61
+
62
+ defined += children
61
63
  end
62
64
  end
63
65
 
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gareth (Ari) Aye
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-01-15 00:00:00.000000000 Z
@@ -23,24 +23,24 @@ homepage: https://github.com/lambdabaa/modules
23
23
  licenses:
24
24
  - MIT
25
25
  metadata: {}
26
- post_install_message:
26
+ post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - ! '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - ! '>='
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubyforge_project:
42
- rubygems_version: 2.4.8
43
- signing_key:
41
+ rubyforge_project:
42
+ rubygems_version: 2.6.8
43
+ signing_key:
44
44
  specification_version: 4
45
45
  summary: Port of js module loader to ruby
46
46
  test_files: []