reactive-dev 0.2.0

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.
data/History ADDED
@@ -0,0 +1,3 @@
1
+ === 0.1.0 / 2008-04-27
2
+
3
+ * Initial release, note that this is an early alpha version used for proof-of-concept. Everything has a great chance to change! [PHI]
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2008-2009 Pascal Hurni
2
+ Copyright (c) 2004-2007 David Heinemeier Hansson
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ History
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ Rakefile
6
+ app_generators/reactive/USAGE
7
+ app_generators/reactive/reactive_generator.rb
8
+ app_generators/reactive/templates/README
9
+ app_generators/reactive/templates/Rakefile
10
+ app_generators/reactive/templates/config/boot.rb
11
+ app_generators/reactive/templates/config/config.rb
12
+ app_generators/reactive/templates/config/empty.log
13
+ app_generators/reactive/templates/script/console
14
+ app_generators/reactive/templates/script/destroy
15
+ app_generators/reactive/templates/script/generate
16
+ app_generators/reactive/templates/script/run
17
+ app_generators/reactive/templates/script/win_script.cmd
18
+ bin/reactive
19
+ lib/reactive-dev.rb
20
+ lib/reactive-dev/code_statistics.rb
21
+ lib/reactive-dev/generated_attribute.rb
22
+ lib/reactive-dev/named_base_generator.rb
23
+ lib/reactive-dev/rubigen_plugin_sources.rb
24
+ lib/reactive-dev/source_annotation_extractor.rb
25
+ lib/reactive-dev/tasks/annotations.rake
26
+ lib/reactive-dev/tasks/app.rake
27
+ lib/reactive-dev/tasks/plugin.rb
28
+ lib/reactive-dev/tasks/statistics.rake
29
+ lib/reactive-dev/tasks/testing.rake
data/README ADDED
@@ -0,0 +1,130 @@
1
+ == Welcome to Reactive
2
+
3
+ Please visit www.ruby-reactive.org for further informations.
4
+
5
+ == Description:
6
+
7
+ Reactive is a desktop application framework that gives everything
8
+ needed to create database-backed applications according to the
9
+ Model-View-Control pattern of separation.
10
+
11
+ Reactive is highly inspired and also uses code of Rails, the famous
12
+ Web-Framework for ruby.
13
+
14
+ In Reactive, the model is handled by what's called an object-relational mapping
15
+ layer. Reactive doesn't impose any ORM, you may choose the one you like but
16
+ Reactive defaults to Active Record. This means it has baked in support for it,
17
+ without forcing you to use it.
18
+
19
+ The view part is independant of Reactive, this means that the application has
20
+ to choose a view provider and feed it into Reactive. This leads to complete
21
+ freedom for the GUI part. View providers are packaged as gems, so that it is
22
+ easy for the developer to choose and install them. Look for reactive_view_*
23
+ to discover some view providers (at this early alpha stage, only reactive_view_wx
24
+ is available)
25
+
26
+ The controller is part of Reactive and is loosely coupled to the view. Simple
27
+ convention set up the link.
28
+
29
+
30
+ == Getting Started
31
+
32
+ 1. At the command prompt, start a new Reactive application using the <tt>reactive</tt> command
33
+ and your application name. Ex: reactive myapp -w wx
34
+ 2. Change directory into myapp and start the application: <tt>script/run</tt>
35
+ 3. Welcome into your new application!
36
+
37
+
38
+ == Debugging Reactive
39
+
40
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
41
+ will help you debug it and get it back on the reactive.
42
+
43
+ First area to check is the application log files. Have "tail -f" commands running
44
+ on the development.log. Reactive will automatically display debugging
45
+ and runtime information to these files.
46
+
47
+ You can also log your own messages directly into the log file from your code using
48
+ the Ruby logger class from inside your controllers. Example:
49
+
50
+ class WeblogController < ApplicationController
51
+ def destroy
52
+ @weblog = Weblog.find(params[:id])
53
+ @weblog.destroy
54
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
55
+ end
56
+ end
57
+
58
+ The result will be a message in your log file along the lines of:
59
+
60
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
61
+
62
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
63
+
64
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
65
+
66
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
67
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
68
+
69
+ These two online (and free) books will bring you up to speed on the Ruby language
70
+ and also on programming in general.
71
+
72
+
73
+ == Debugger
74
+
75
+
76
+ == Console
77
+
78
+
79
+ == Description of Contents
80
+
81
+ app
82
+ Holds all the code that's specific to this particular application.
83
+
84
+ app/controllers
85
+ Holds controllers that should be named like products_controller.rb.
86
+ All controllers should descend from ApplicationController
87
+ which itself descends from Reactive::Controller::Base.
88
+
89
+ app/models
90
+ Holds models that should be named like post.rb.
91
+ Most models will descend from ActiveRecord::Base if you chose this ORM.
92
+
93
+ app/views
94
+ Holds the code or template files for the view that should be named like
95
+ products/index.rb for the ProductsController#index action. The master views are
96
+ pure Ruby code.
97
+
98
+ app/helpers
99
+ Holds view helpers that should be named like products_helper.rb. These are generated
100
+ for you automatically when using script/generate for views. Helpers can be used to
101
+ wrap functionality for your views into methods.
102
+
103
+ assets
104
+ Contains specific application files, like icons and help files.
105
+
106
+ config
107
+ Configuration files for the Reactive environment, the database, and other dependencies.
108
+
109
+ db
110
+ Contains the database schema in schema.rb. db/migrate contains all
111
+ the sequence of Migrations for your schema.
112
+
113
+ doc
114
+ This directory is where your application documentation will be stored when generated
115
+ using <tt>rake doc:app</tt>
116
+
117
+ lib
118
+ Application specific libraries. Basically, any kind of custom code that doesn't
119
+ belong under controllers, models, or helpers. This directory is in the load path.
120
+
121
+ script
122
+ Helper scripts for automation and generation.
123
+
124
+ test
125
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
126
+ test files will be generated for you and placed in this directory.
127
+
128
+ gems
129
+ Alternate gem repository. You may install dependent gems into this directory. This is used for
130
+ the plugin system.
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'reactive-core/version'
3
+
4
+ @spec = Gem::Specification.new do |s|
5
+ s.name = "reactive-dev"
6
+ s.version = Reactive::VERSION::STRING
7
+ s.author = "Pascal Hurni"
8
+ s.email = "phi@ruby-reactive.org"
9
+ s.homepage = "http://www.ruby-reactive.org"
10
+ s.summary = "Reactive - The desktop application framework"
11
+ s.description = "Development tools for reactive applications"
12
+ s.rubyforge_project = "reactive-dev"
13
+ s.add_dependency 'reactive-core', ">= #{s.version}"
14
+ s.add_dependency 'rubigen', '>= 1.3.0'
15
+ s.add_dependency 'rubyforge', '>= 0.4.2'
16
+ s.add_dependency 'rake', '>= 0.7.0'
17
+ end
18
+
19
+ require 'reactive-dev/tasks/plugin'
@@ -0,0 +1,14 @@
1
+ Description:
2
+ The 'reactive' command creates a new Reactive application with a default
3
+ directory structure and configuration at the path you specify.
4
+ You may pass the plugin names you desire for this application
5
+ Use the -P switch to create a plugin scaffold.
6
+
7
+ Example:
8
+ reactive ~/Code/Ruby/mysales reactive-mvc reactive-activerecord reactive-wx
9
+
10
+ This generates a skeletical Reactive application in ~/Code/Ruby/mysales
11
+ with three plugins: reactive-mvc, reactive-activerecord and reactive-wx.
12
+ By specifying a dispatcher plugin and an output handler plugin, reactive is able
13
+ to create an initial view and config files accordingely.
14
+ See the README in the newly created application to get going.
@@ -0,0 +1,137 @@
1
+ class ReactiveGenerator < RubiGen::Base
2
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
3
+ Config::CONFIG['ruby_install_name']) unless defined? DEFAULT_SHEBANG
4
+
5
+ default_options :shebang => DEFAULT_SHEBANG
6
+
7
+ attr_reader :app_name
8
+
9
+ def initialize(runtime_args, runtime_options = {})
10
+ super
11
+ usage if args.empty?
12
+ @destination_root = args.shift
13
+ @root_path = File.expand_path(@destination_root)
14
+ @app_name = File.basename(@root_path)
15
+ extract_options
16
+ end
17
+
18
+ def manifest
19
+ script_options = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
20
+
21
+ record do |m|
22
+ # Root directory and all subdirectories.
23
+ m.directory ''
24
+ BASEDIRS.each { |path| m.directory path }
25
+
26
+ # copy skeleton
27
+ m.file_copy_each %w( Rakefile README )
28
+
29
+ # Configs
30
+ # m.file_copy_each %w( development.rb production.rb test.rb ), "config/environments"
31
+ m.file "config/boot.rb", "config/boot.rb"
32
+ m.template "config/config.rb", "config/config.rb", :assigns => {:plugins => args}
33
+
34
+ # Logs
35
+ %w( production development test ).each { |file|
36
+ m.file "config/empty.log", "log/#{file}.log", :chmod => 0666
37
+ }
38
+
39
+ # Scripts
40
+ %w( console generate destroy run ).each do |file|
41
+ m.template "script/#{file}", "script/#{file}", script_options
42
+ m.template "script/win_script.cmd", "script/#{file}.cmd", :assigns => { :filename => file } if windows
43
+ end
44
+
45
+ m.affiliates(:reactive_app, [@destination_root], options)
46
+
47
+ end
48
+ end
49
+
50
+ def windows
51
+ (RUBY_PLATFORM =~ /dos|win32|cygwin/i) || (RUBY_PLATFORM =~ /(:?mswin|mingw)/)
52
+ end
53
+
54
+ protected
55
+ def banner
56
+ <<-EOS
57
+ Creates a Reactive application stub.
58
+
59
+ Usage: #{spec.name} path_to_your_app [options]
60
+ EOS
61
+ end
62
+
63
+ def add_options!(opts)
64
+ # opts.separator ''
65
+ # opts.separator 'Options:'
66
+ # # For each option below, place the default
67
+ # # at the top of the file next to "default_options"
68
+ # opts.on("-r", "--ruby=path", String,
69
+ # "Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).",
70
+ # "Default: #{DEFAULT_SHEBANG}") { |options[:shebang]| }
71
+ opts.separator ''
72
+ opts.separator 'Options:'
73
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
74
+ end
75
+
76
+ def parse!(args, runtime_options = {})
77
+ self.options = {}
78
+ plugins = args[0..(args.index(args.find {|arg| arg[0..0] == '-'}) || 0)-1]
79
+ usage if plugins.empty?
80
+
81
+ @destination_root = plugins.shift
82
+ @root_path = File.expand_path(@destination_root)
83
+ load_plugins plugins
84
+
85
+ affiliates_options = []
86
+ @option_parser = OptionParser.new do |opt|
87
+ opt.banner = banner
88
+ add_options!(opt)
89
+ add_general_options!(opt)
90
+ self.class.sources.collect {|source| source.collect}.flatten.each do |spec|
91
+ affiliates_options << (affiliate_options = {})
92
+ capturer_class = Class.new(spec.klass)
93
+ capturer_class.send(:define_method, :options) { affiliate_options }
94
+ capturer_class.spec = spec
95
+ capturer = capturer_class.new([@destination_root], {})
96
+ spec.klass.instance_method(:add_options!).bind(capturer).call(opt)
97
+ end
98
+ opt.parse!(args)
99
+ affiliates_options.each {|ao| options.merge!(ao)}
100
+ end
101
+
102
+ return args
103
+ ensure
104
+ self.options = full_options(runtime_options)
105
+ end
106
+
107
+ def load_plugins(gems = [])
108
+ require 'reactive-core/initializer'
109
+ Reactive::Initializer.run(:configure) do |config|
110
+ config.root_dir = @root_path
111
+ # config may already be up to date because a config file may have been generated
112
+ gems.each {|name| config.gem name}
113
+ end
114
+ self.class.use_plugin_sources! :reactive_app
115
+ end
116
+
117
+ def extract_options
118
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
119
+ # Templates can access these value via the attr_reader-generated methods, but not the
120
+ # raw instance variable value.
121
+ # @author = options[:author]
122
+ end
123
+
124
+ # Installation skeleton. Intermediate directories are automatically
125
+ # created so don't sweat their absence here.
126
+ BASEDIRS = %w(
127
+ assets/default
128
+ config/environments
129
+ config/initializers
130
+ gems/specifications
131
+ gems/gems
132
+ log
133
+ script
134
+ test/unit
135
+ )
136
+
137
+ end
@@ -0,0 +1,101 @@
1
+ == Welcome to Reactive
2
+
3
+ Please visit www.ruby-reactive.org for further informations.
4
+
5
+ == Description:
6
+
7
+ Reactive is a desktop application framework that gives everything
8
+ needed to create database-backed applications according to the
9
+ Model-View-Control pattern of separation.
10
+
11
+ Reactive is highly inspired and also uses code of Rails, the famous
12
+ Web-Framework for ruby.
13
+
14
+ Every layer in Reactive is pluggable. So you have to create your stack by
15
+ choosing plugins.
16
+
17
+ The first layer you want is a dispatcher, which will dispatch the requests
18
+ (also comming from the user).
19
+ You may use reactive-mvc. It supplies a complete MVC architecture ala Rails.
20
+
21
+ The second layer is an output handler. It will interpret the output generated
22
+ by a request (which itself is generated by the dispatcher plugin).
23
+ You may use reactive-wx. It executes ruby code for the wxRuby GUI toolkit.
24
+
25
+ There's no third layer! But while reading reactive-mvc documentation, you will
26
+ find that it doesn't impose a specific ORM. You have to choose one. Currently
27
+ there's reactive-activerecord which as its name suggests, handles ActiveRecord.
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, start a new Reactive application using the <tt>reactive</tt> command
32
+ and your application name. Ex: reactive myapp
33
+ 2. Change directory into myapp and start the application: <tt>script/run</tt>
34
+ 3. Welcome into your new application!
35
+
36
+ Generally you want some plugins to take part of the app, specify them directly on the command line:
37
+ reactive myapp reactive-mvc reactive-activerecord reactive-wx
38
+
39
+ == Debugging Reactive
40
+
41
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
42
+ will help you debug it and get it back on the reactive.
43
+
44
+ First area to check is the application log files. Have "tail -f" commands running
45
+ on the development.log. Reactive will automatically display debugging
46
+ and runtime information to these files.
47
+
48
+ You can also log your own messages directly into the log file from your code using
49
+ the Ruby logger class from inside your controllers. Example:
50
+
51
+ class ProductController < ApplicationController
52
+ def destroy
53
+ @product = Product.find(params[:id])
54
+ @product.destroy
55
+ logger.info("#{Time.now} Destroyed Product ID ##{@product.id}!")
56
+ end
57
+ end
58
+
59
+ The result will be a message in your log file along the lines of:
60
+
61
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Product ID #1
62
+
63
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
64
+
65
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
66
+
67
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
68
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
69
+
70
+ These two online (and free) books will bring you up to speed on the Ruby language
71
+ and also on programming in general.
72
+
73
+ == Debugger
74
+
75
+
76
+ == Console
77
+
78
+
79
+ == Description of Contents
80
+
81
+ Without a specific dispatcher plugin, the directory layout of a Reactive application looks like this:
82
+
83
+ assets
84
+ Contains specific application files, like icons and help files.
85
+
86
+ config
87
+ Configuration files for the Reactive environment, the database, and other dependencies.
88
+
89
+ script
90
+ Helper scripts for automation and generation.
91
+
92
+ test
93
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
94
+ test files will be generated for you and placed in this directory.
95
+
96
+ gems
97
+ Alternate gem repository. You may install dependent gems into this directory. This is used for
98
+ the plugin system.
99
+
100
+ log
101
+ Contains runtime logfiles.