perennial 1.0.2.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/perennial/core_ext/misc.rb +6 -1
- data/lib/perennial/manifest.rb +28 -9
- data/lib/perennial.rb +1 -1
- data/test/test_helper.rb +1 -3
- metadata +2 -2
@@ -30,6 +30,11 @@ module Kernel
|
|
30
30
|
def P(&blk)
|
31
31
|
Proc.new(&blk)
|
32
32
|
end
|
33
|
+
|
34
|
+
def N(*args)
|
35
|
+
Perennial::Nash.new(*args)
|
36
|
+
end
|
37
|
+
|
33
38
|
end
|
34
39
|
|
35
40
|
class String
|
@@ -95,7 +100,7 @@ end
|
|
95
100
|
class Class
|
96
101
|
|
97
102
|
def is(*mixins)
|
98
|
-
ns = Perennial::Manifest.namespace
|
103
|
+
ns = Perennial::Manifest[self].namespace
|
99
104
|
return if ns.blank?
|
100
105
|
mixins.each do |mixin|
|
101
106
|
begin
|
data/lib/perennial/manifest.rb
CHANGED
@@ -1,29 +1,48 @@
|
|
1
1
|
module Perennial
|
2
2
|
class Manifest
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
self.namespace = Perennial
|
4
|
+
cattr_accessor :manifest_mapping
|
5
|
+
@@manifest_mapping = {}
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
attr_accessor :app_name, :namespace
|
8
|
+
|
9
|
+
def initialize(name, klass)
|
10
|
+
self.app_name = name
|
11
|
+
self.namespace = klass
|
12
|
+
@@manifest_mapping[klass.name] = self
|
13
|
+
end
|
14
|
+
|
15
|
+
def inspect
|
16
|
+
"#<#{self.class.name} app_name: #{self.app_name.inspect}, namespace: #{self.namespace.inspect}>"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.[](klass)
|
20
|
+
klass = klass.name if klass.respond_to?(:name)
|
21
|
+
@@manifest_mapping[klass.split("::", 2).first]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.add_manifest(name, klass)
|
25
|
+
self.new(name, klass)
|
10
26
|
end
|
11
27
|
|
28
|
+
add_manifest :perennial, Perennial
|
29
|
+
|
12
30
|
module Mixin
|
13
31
|
# Called in your application to set the default
|
14
32
|
# namespace and app_name. Also, if a block is
|
15
33
|
# provided it yields first with Manifest and then
|
16
34
|
# with the Loader class, making it simpler to setup.
|
17
35
|
def manifest(&blk)
|
18
|
-
|
19
|
-
|
36
|
+
namespace = self
|
37
|
+
app_name = self.name.to_s.underscore
|
38
|
+
manifest = Perennial::Manifest.add_manifest(app_name, namespace)
|
20
39
|
parent_folder = File.expand_path(File.dirname(__DIR__(0)))
|
21
40
|
Settings.library_root = parent_folder
|
22
|
-
libary_folder = parent_folder / 'lib'/
|
41
|
+
libary_folder = parent_folder / 'lib'/ app_name
|
23
42
|
attempt_require((libary_folder / 'core_ext'), (libary_folder / 'exceptions'))
|
24
43
|
unless blk.nil?
|
25
44
|
args = []
|
26
|
-
args <<
|
45
|
+
args << manifest if blk.arity != 0
|
27
46
|
args << Loader if blk.arity > 1 || blk.arity < 0
|
28
47
|
blk.call(*args)
|
29
48
|
end
|
data/lib/perennial.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
# Testing dependencies
|
4
|
-
require '
|
4
|
+
require 'leftright' if RUBY_VERSION < '1.9'
|
5
5
|
require 'shoulda'
|
6
6
|
require 'mocha'
|
7
|
-
# RedGreen doesn't seem to be needed under 1.9
|
8
|
-
require 'redgreen' if RUBY_VERSION < "1.9"
|
9
7
|
|
10
8
|
require 'pathname'
|
11
9
|
root_directory = Pathname.new(__FILE__).dirname.join("..").expand_path
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perennial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darcy Laycock
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-07 00:00:00 +08:00
|
13
13
|
default_executable: perennial
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|