activesupport-slices 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.
@@ -0,0 +1,39 @@
1
+ require 'active_support'
2
+ require 'active_support/slices/dependencies'
3
+ require 'active_support/slices/rails' if defined?(Rails)
4
+
5
+ module ActiveSupport
6
+ module Slices
7
+ mattr_accessor :slices
8
+ self.slices = {}
9
+
10
+ def paths
11
+ Dependencies.autoload_paths
12
+ end
13
+
14
+ def load(filename)
15
+ filename = local(filename)
16
+ if slices.key?(filename)
17
+ slices[filename].each { |slice| Dependencies.load(slice) }
18
+ end
19
+ end
20
+
21
+ def register
22
+ Dir["{#{paths.join(',')}}/**/*_slice*.rb"].each do |path|
23
+ filename = local(path).sub('_slice', '')
24
+ slices[filename] ||= []
25
+ slices[filename] << path
26
+ end
27
+ end
28
+
29
+ def local(path)
30
+ path.sub(pattern, '')
31
+ end
32
+
33
+ def pattern
34
+ @pattern || %r((#{paths.join('|')})/)
35
+ end
36
+
37
+ extend self
38
+ end
39
+ end
@@ -0,0 +1,12 @@
1
+ require 'active_support/dependencies'
2
+
3
+ module ActiveSupport
4
+ module Dependencies
5
+ def require_or_load_with_slices(*args)
6
+ require_or_load_without_slices(*args).tap do |result|
7
+ Slices.load(args.first) if result
8
+ end
9
+ end
10
+ alias_method_chain :require_or_load, :slices
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ module Slices
2
+ class Railtie < Rails::Railtie
3
+ initializer 'activesupport.slices.register' do |app|
4
+ ActiveSupport::Slices.register
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveSupport
2
+ module Slices
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activesupport-slices
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sven Fuchs
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-14 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Lazy loaded vertical code slices based on ActiveSupport Dependencies.
23
+ email: svenfuchs@artweb-design.de
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/active_support/slices/dependencies.rb
32
+ - lib/active_support/slices/rails.rb
33
+ - lib/active_support/slices/version.rb
34
+ - lib/active_support/slices.rb
35
+ has_rdoc: true
36
+ homepage: http://github.com/svenfuchs/activesupport-slices
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project: "[none]"
65
+ rubygems_version: 1.3.7
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Lazy loaded vertical code slices based on ActiveSupport Dependencies
69
+ test_files: []
70
+