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.
@@ -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
@@ -1,29 +1,48 @@
1
1
  module Perennial
2
2
  class Manifest
3
3
 
4
- class_inheritable_accessor :app_name, :namespace
5
- self.app_name = :perennial
6
- self.namespace = Perennial
4
+ cattr_accessor :manifest_mapping
5
+ @@manifest_mapping = {}
7
6
 
8
- def self.inspect
9
- "#<#{self.name} app_name: #{self.app_name.inspect}, namespace: #{self.namespace.inspect}>"
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
- Manifest.namespace = self
19
- Manifest.app_name = self.name.to_s.underscore
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'/ Manifest.app_name
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 << Manifest if blk.arity != 0
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
@@ -9,7 +9,7 @@ require 'perennial/exceptions'
9
9
 
10
10
  module Perennial
11
11
 
12
- VERSION = [1, 0, 2, 1]
12
+ VERSION = [1, 1, 0]
13
13
 
14
14
  has_library :dispatchable, :hookable, :loader, :logger, :nash,
15
15
  :loggable, :manifest, :settings, :argument_parser,
data/test/test_helper.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'rubygems'
2
2
 
3
3
  # Testing dependencies
4
- require 'test/unit'
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.2.1
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-10-22 00:00:00 +08:00
12
+ date: 2009-11-07 00:00:00 +08:00
13
13
  default_executable: perennial
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency