Sutto-perennial 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,9 +39,33 @@ module Perennial
39
39
  end
40
40
 
41
41
  def generator!
42
- self.command_env = Perennial::Generator::CommandEnv
42
+ if defined?(Generator)
43
+ self.command_env = Generator::CommandEnv
44
+ end
45
+ end
46
+
47
+ def controller!(controller, description)
48
+ return unless defined?(Loader)
49
+ add_default_options!
50
+ option :kill, "Kill any runninng instances"
51
+ controller_name = controller.to_s.underscore
52
+ controller = controller.to_sym
53
+ command_name = controller_name.gsub("_", "-")
54
+ add("#{command_name} [PATH]", description) do |*args|
55
+ options = args.extract_options!
56
+ path = File.expand_path(args[0] || ".")
57
+ Settings.root = path
58
+ if options[:kill]
59
+ puts "Attempting to kill processess..."
60
+ Daemon.kill_all(controller)
61
+ else
62
+ Loader.run!(controller)
63
+ end
64
+ end
43
65
  end
44
66
 
67
+
68
+
45
69
  def add(raw_command, description = nil, &blk)
46
70
  raise ArgumentError, "You must provide a block with an #{self.class.name}#add" if blk.nil?
47
71
  raise ArgumentError, "Your block must accept atleast one argument (a hash of options)" if blk.arity == 0
data/lib/perennial.rb CHANGED
@@ -8,7 +8,7 @@ require 'perennial/exceptions'
8
8
 
9
9
  module Perennial
10
10
 
11
- VERSION = "0.2.0"
11
+ VERSION = "0.2.1"
12
12
 
13
13
  has_libary :dispatchable, :hookable, :loader, :logger,
14
14
  :loggable, :manifest, :settings, :argument_parser,
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ require 'perennial'
3
+
4
+ module <%= @application_module %>
5
+ include Perennial
6
+
7
+ VERSION = "0.0.1"
8
+
9
+ manifest do |m, l|
10
+ Settings.root = File.dirname(__FILE__)
11
+ # Initialize your controllers, e.g:
12
+ # l.register_controller :client, <%= @application_module %>::Client
13
+ end
14
+
15
+ end
@@ -0,0 +1,2 @@
1
+ require <%= @application_name.to_s.inspect %>
2
+ <%= @application_module %>::Settings.root = Pathname.new(__FILE__).join("..").expand_path
@@ -0,0 +1,31 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ task :default => "test:units"
5
+
6
+ namespace :test do
7
+
8
+ desc "Runs the unit tests for perennial"
9
+ Rake::TestTask.new("units") do |t|
10
+ t.pattern = 'test/*_test.rb'
11
+ t.libs << 'test'
12
+ t.verbose = true
13
+ end
14
+
15
+ end
16
+
17
+ task :gemspec do
18
+ require 'rubygems'
19
+ require File.join(File.dirname(__FILE__), "lib", "<%= @application_path %>")
20
+ spec = Gem::Specification.new do |s|
21
+ s.name = '<%= @application_path %>'
22
+ s.email = ''
23
+ s.homepage = ''
24
+ s.authors = ["YOUR NAME"]
25
+ s.version = <%= @application_module %>::VERSION
26
+ s.summary = ""
27
+ s.files = FileList["{bin,vendor,lib,test}/**/*"].to_a
28
+ s.platform = Gem::Platform::RUBY
29
+ end
30
+ File.open("<%= @application_path %>.gemspec", "w+") { |f| f.puts spec.to_ruby }
31
+ end
@@ -0,0 +1,4 @@
1
+ # Use this on a per-application setup / initialization basis.
2
+ <%= @application_module %>::Loader.before_run do
3
+ # Do stuff here...
4
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class <%= @application_module %>Test < Test::Unit::TestCase
4
+
5
+ should 'have tests' do
6
+ fail "You need to write some tests"
7
+ end
8
+
9
+ end
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+
3
+ # Testing dependencies
4
+ require 'test/unit'
5
+ require 'shoulda'
6
+ # RedGreen doesn't seem to be needed under 1.9
7
+ require 'redgreen' if RUBY_VERSION < "1.9"
8
+
9
+ require 'pathname'
10
+ root_directory = Pathname.new(__FILE__).dirname.join("..").expand_path
11
+ require root_directory.join("lib", "<%= @application_path %>")
12
+
13
+ class Test::Unit::TestCase
14
+
15
+ protected
16
+
17
+ # Short hand for creating a class with
18
+ # a given class_eval block.
19
+ def class_via(*args, &blk)
20
+ klass = Class.new(*args)
21
+ klass.class_eval(&blk) unless blk.blank?
22
+ return klass
23
+ end
24
+
25
+ # Short hand for creating a test class
26
+ # for a set of mixins - give it the modules
27
+ # and it will include them all.
28
+ def test_class_for(*mods, &blk)
29
+ klass = Class.new
30
+ klass.class_eval { include(*mods) }
31
+ klass.class_eval(&blk) unless blk.blank?
32
+ return klass
33
+ end
34
+
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Sutto-perennial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -10,13 +10,13 @@ bindir: bin
10
10
  cert_chain: []
11
11
 
12
12
  date: 2009-08-08 00:00:00 -07:00
13
- default_executable:
13
+ default_executable: perennial
14
14
  dependencies: []
15
15
 
16
- description:
16
+ description: Perennial is a platform for building different applications in Ruby. It uses a controller-based approach with mixins to provide different functionality.
17
17
  email: sutto@sutto.net
18
- executables: []
19
-
18
+ executables:
19
+ - perennial
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files: []
@@ -59,6 +59,12 @@ files:
59
59
  - test/logger_test.rb
60
60
  - test/settings_test.rb
61
61
  - test/test_helper.rb
62
+ - templates/application.erb
63
+ - templates/boot.erb
64
+ - templates/rakefile.erb
65
+ - templates/setup.erb
66
+ - templates/test.erb
67
+ - templates/test_helper.erb
62
68
  has_rdoc: false
63
69
  homepage: http://sutto.net/
64
70
  licenses:
@@ -85,6 +91,6 @@ rubyforge_project:
85
91
  rubygems_version: 1.3.5
86
92
  signing_key:
87
93
  specification_version: 3
88
- summary: A simple event-oriented application library for Ruby
94
+ summary: A simple (generally event-oriented) application library for Ruby
89
95
  test_files: []
90
96