Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 166 lines (142 sloc) 4.257 kb
3c5a729 @danlucraft Cleaned up the load path; can now run plugin specs
danlucraft authored
1
1addb58 @danlucraft Bump version number to 0.3.3
danlucraft authored
2 $:.push File.expand_path(File.join(File.dirname(__FILE__)))
3c5a729 @danlucraft Cleaned up the load path; can now run plugin specs
danlucraft authored
3
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
4 require 'redcar/usage'
5
9977e52 @danlucraft Gem packaging works
danlucraft authored
6 require 'rbconfig'
31acf33 @danlucraft Sensitive objects inherit sensitivities from their parents
danlucraft authored
7
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
8 require 'redcar/ruby_extensions'
9 require 'redcar/instance_exec'
58640fb @danlucraft Move install command help into usage.rb
danlucraft authored
10 require 'redcar/usage'
9709645 @danlucraft Spawn a sub jruby process unless --no-sub-jruby is specified. This makes...
danlucraft authored
11 require 'regex_replace'
58640fb @danlucraft Move install command help into usage.rb
danlucraft authored
12
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
13 require 'forwardable'
14 require 'yaml'
15
16 # ## Loading and Initialization
17 #
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
18 # Every feature in Redcar is written as a plugin. This module contains a few
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
19 # methods to bootstrap the plugins by loading the PluginManager.
20 #
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
21 # Once loaded, bin/redcar will start the gui pump, which will run
22 # Redcar.gui.start. This starts the GUI library's event loop and hands over
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
23 # control to the GUI.
24 #
25 # ## Application
26 #
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
27 # The top class of Redcar is a {Redcar::Application}, which handles the creation
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
28 # of Redcar::Windows. {Redcar::Application} is a good place to start
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
29 # to see how the Redcar models are created.
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
30 #
31 # {Redcar::ApplicationSWT} is the start point for the SWT GUI, which listens
ae36d02 @danlucraft Soft tabs should respect tab stops
danlucraft authored
32 # for events from the {Redcar::Application} model and reflects them in the GUI.
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
33 #
34 # This structure of a model and a controller that listens to it is repeated for
35 # each part of Redcar reflected in the GUI.
36 #
ae36d02 @danlucraft Soft tabs should respect tab stops
danlucraft authored
37 # * {Redcar::Window} has {Redcar::ApplicationSWT::Window}
38 # * {Redcar::Notebook} has {Redcar::ApplicationSWT::Notebook}
39 # * {Redcar::EditTab} has {Redcar::EditViewSWT::EditTab}
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
40 #
41 # and so on.
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' step....
danlucraft authored
42 module Redcar
1e3fd45 @danlucraft Bump version to 0.3.5
danlucraft authored
43 VERSION = '0.3.5'
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' step....
danlucraft authored
44 VERSION_MAJOR = 0
45 VERSION_MINOR = 3
1e3fd45 @danlucraft Bump version to 0.3.5
danlucraft authored
46 VERSION_RELEASE = 5
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored
47
3f45491 @danlucraft Fix storage spec and added Redcar.environment
danlucraft authored
48 ENVIRONMENTS = [:user, :debug, :test]
11d608b @danlucraft Halve startup time (warm)
danlucraft authored
49
50 PROCESS_START_TIME = Time.now
3f45491 @danlucraft Fix storage spec and added Redcar.environment
danlucraft authored
51
52 def self.environment=(env)
53 unless ENVIRONMENTS.include?(env)
54 raise "environment must be one of #{ENVIRONMENTS.inspect}"
55 end
56 @environment = env
57 end
58
59 def self.environment
07f2d74 @danlucraft Raise an error if the environment is not set
danlucraft authored
60 raise "no environment set" unless @environment
3f45491 @danlucraft Fix storage spec and added Redcar.environment
danlucraft authored
61 @environment
62 end
63
9709645 @danlucraft Spawn a sub jruby process unless --no-sub-jruby is specified. This makes...
danlucraft authored
64 def self.spin_up
ec89d40 @danlucraft Don't spin up a child process if we are on linux/windows and already in ...
danlucraft authored
65 return if ARGV.include?("--no-sub-jruby")
66 return if Config::CONFIG["RUBY_INSTALL_NAME"] == "jruby" and [:linux, :windows].include?(platform)
67
68 require 'redcar/runner'
69 runner = Redcar::Runner.new
70 runner.spin_up
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' step....
danlucraft authored
71 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
72
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
73 def self.root
74 File.expand_path(File.join(File.dirname(__FILE__), ".."))
75 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
76
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
77 def self.plugin_manager
78 @plugin_manager ||= begin
79 m = PluginManager.new
80 m.add_plugin_source(File.join(root, "plugins"))
81 m.add_plugin_source(File.join(user_dir, "plugins"))
82 m
83 end
84 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
85
64ea71b @danlucraft Writing documentation
danlucraft authored
86 # Tells the plugin manager to load plugins, and prints debug output.
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
87 def self.load
e5ab655 @danlucraft Load the openssl gem after we are sure we are not installing
danlucraft authored
88 $:.push File.expand_path(File.join(File.dirname(__FILE__), "plugin_manager", "lib"))
89 require 'plugin_manager'
90
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
91 plugin_manager.load
92 if plugin_manager.unreadable_definitions.any?
93 puts "Couldn't read definition files: "
94 puts plugin_manager.unreadable_definitions.map {|d| " * " + d}
95 end
96 if plugin_manager.plugins_with_errors.any?
5b1be1a @rdp add some helper methods to window and document
rdp authored
97 puts "There was an error loading plugins: "
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
98 puts plugin_manager.plugins_with_errors.map {|d| " * " + d.name}
99 end
100 if ENV["PLUGIN_DEBUG"]
101 puts "Loaded plugins:"
102 puts plugin_manager.loaded_plugins.map {|d| " * " + d.name}
103 puts
104 puts "Unloaded plugins:"
105 puts plugin_manager.unloaded_plugins.map {|d| " * " + d.name}
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
106
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
107 end
108 end
109
64ea71b @danlucraft Writing documentation
danlucraft authored
110 # Starts the GUI.
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
111 def self.pump
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
112 Redcar.gui.start
113 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
114
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
115 # Platform symbol
116 #
117 # @return [:osx/:windows/:linux]
118 def self.platform
119 case Config::CONFIG["target_os"]
120 when /darwin/
121 :osx
122 when /mswin|mingw/
123 :windows
124 when /linux/
125 :linux
126 end
127 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored
128
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
129 # Platform specific ~/.redcar
130 #
131 # @return [String] expanded path
132 def self.user_dir
fbad936 @danlucraft Use a clean environment for features
danlucraft authored
133 dirname = {
134 :user => ".redcar",
135 :test => ".redcar_test",
136 :debug => ".redcar_debug"
137 }[Redcar.environment]
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
138 if platform == :windows
139 if ENV['USERPROFILE'].nil?
fbad936 @danlucraft Use a clean environment for features
danlucraft authored
140 userdir = "C:/My Documents/#{dirname}/"
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
141 else
fbad936 @danlucraft Use a clean environment for features
danlucraft authored
142 userdir = File.join(ENV['USERPROFILE'], dirname)
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
143 end
144 else
fbad936 @danlucraft Use a clean environment for features
danlucraft authored
145 userdir = File.join(ENV['HOME'], dirname) unless ENV['HOME'].nil?
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored
146 end
147 File.expand_path(userdir)
62aa218 @danlucraft Fix specs and features for new code loading
danlucraft authored
148 end
64ea71b @danlucraft Writing documentation
danlucraft authored
149
150 class << self
151 attr_accessor :app
152 attr_reader :gui
153 end
154
155 # Set the application GUI.
156 def self.gui=(gui)
157 raise "can't set gui twice" if @gui
158 @gui = gui
159 end
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' step....
danlucraft authored
160 end
161
58640fb @danlucraft Move install command help into usage.rb
danlucraft authored
162 usage = Redcar::Usage.new
163 usage.version_string
164 usage.version_requested
165 usage.help_requested
Something went wrong with that request. Please try again.