Skip to content
Newer
Older
100644 192 lines (165 sloc) 4.67 KB
3c5a729 @danlucraft Cleaned up the load path; can now run plugin specs
danlucraft authored Sep 20, 2009
1
9977e52 @danlucraft Gem packaging works
danlucraft authored Dec 15, 2009
2 $:.push File.join(File.dirname(__FILE__))
3c5a729 @danlucraft Cleaned up the load path; can now run plugin specs
danlucraft authored Sep 20, 2009
3
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
4 require 'redcar/usage'
5
9977e52 @danlucraft Gem packaging works
danlucraft authored Dec 15, 2009
6 require 'rbconfig'
31acf33 @danlucraft Sensitive objects inherit sensitivities from their parents
danlucraft authored Nov 14, 2009
7
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
8 require 'redcar/ruby_extensions'
9 require 'redcar/instance_exec'
58640fb @danlucraft Move install command help into usage.rb
danlucraft authored Jan 9, 2010
10 require 'redcar/usage'
11
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
12 require 'plugin_manager/lib/plugin_manager'
13
14 require 'forwardable'
15 require 'yaml'
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
16 require 'socket'
17 require 'drb'
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
18
19 # ## Loading and Initialization
20 #
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
21 # 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 Jan 23, 2010
22 # methods to bootstrap the plugins by loading the PluginManager.
23 #
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
24 # Once loaded, bin/redcar will start the gui pump, which will run
25 # 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 Jan 23, 2010
26 # control to the GUI.
27 #
28 # ## Application
29 #
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
30 # 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 Jan 23, 2010
31 # of Redcar::Windows. {Redcar::Application} is a good place to start
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
32 # 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 Jan 23, 2010
33 #
34 # {Redcar::ApplicationSWT} is the start point for the SWT GUI, which listens
ae36d02 @danlucraft Soft tabs should respect tab stops
danlucraft authored Feb 13, 2010
35 # 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 Jan 23, 2010
36 #
37 # This structure of a model and a controller that listens to it is repeated for
38 # each part of Redcar reflected in the GUI.
39 #
ae36d02 @danlucraft Soft tabs should respect tab stops
danlucraft authored Feb 13, 2010
40 # * {Redcar::Window} has {Redcar::ApplicationSWT::Window}
41 # * {Redcar::Notebook} has {Redcar::ApplicationSWT::Notebook}
42 # * {Redcar::EditTab} has {Redcar::EditViewSWT::EditTab}
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
43 #
44 # and so on.
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' st…
danlucraft authored Jan 9, 2010
45 module Redcar
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
46 VERSION = '0.3.2'
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' st…
danlucraft authored Jan 9, 2010
47 VERSION_MAJOR = 0
48 VERSION_MINOR = 3
8036431 @danlucraft Debumped version
danlucraft authored Jan 23, 2010
49 VERSION_RELEASE = 2
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored Feb 8, 2010
50
3f45491 @danlucraft Fix storage spec and added Redcar.environment
danlucraft authored Feb 14, 2010
51 ENVIRONMENTS = [:user, :debug, :test]
52
53 def self.environment=(env)
54 unless ENVIRONMENTS.include?(env)
55 raise "environment must be one of #{ENVIRONMENTS.inspect}"
56 end
57 @environment = env
58 end
59
60 def self.environment
61 @environment
62 end
63
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
64 # if they are all files/dirs then attempt to load via drb if available
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored Feb 8, 2010
65 def self.try_to_load_via_drb
3136602 @danlucraft Added --multiple-instance option to bypass the drb for testing
danlucraft authored Feb 9, 2010
66 return if ARGV.include?("--multiple-instance")
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
67 return unless ARGV.any? and ARGV.all? {|arg| File.exist?(arg) }
68
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored Feb 8, 2010
69 port = 9999
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
70
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored Feb 8, 2010
71 begin
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
72 begin
73 TCPSocket.new('127.0.0.1', 9999).close
74 rescue Errno::ECONNREFUSED
75 # no other instance running...
76 return
77 end
78
79 drb = DRbObject.new(nil, "druby://127.0.0.1:9999")
80
81 if ARGV.any?
82 ARGV.each do |arg|
83 if drb.open_item_drb(File.expand_path(arg)) != 'ok'
84 return
3d48b07 @rdp open up RC on a second run even if you don't pass any arguments through
rdp authored Feb 8, 2010
85 end
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
86 end
3d48b07 @rdp open up RC on a second run even if you don't pass any arguments through
rdp authored Feb 8, 2010
87 else
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
88 return unless drb.open_item_drb('just_bring_to_front')
3d48b07 @rdp open up RC on a second run even if you don't pass any arguments through
rdp authored Feb 8, 2010
89 end
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored Feb 8, 2010
90 return true
91 rescue Exception => e
ac0fad5 @danlucraft Refactored DrbService class out of Project
danlucraft authored Feb 14, 2010
92 puts e.class.to_s + ": " + e.message
93 puts e.backtrace
94 # fall through and continue anyway
f6fcfa1 @rdp attempt to startup using drb if another redcar instance is available
rdp authored Feb 8, 2010
95 end
96 false
97 end
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' st…
danlucraft authored Jan 9, 2010
98
99 def self.ensure_jruby
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
100 if Config::CONFIG["RUBY_INSTALL_NAME"] != "jruby"
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' st…
danlucraft authored Jan 9, 2010
101 require 'redcar/runner'
102 runner = Redcar::Runner.new
103 runner.spin_up
104 end
105 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
106
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
107 def self.root
108 File.expand_path(File.join(File.dirname(__FILE__), ".."))
109 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
110
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
111 def self.plugin_manager
112 @plugin_manager ||= begin
113 m = PluginManager.new
114 m.add_plugin_source(File.join(root, "plugins"))
115 m.add_plugin_source(File.join(user_dir, "plugins"))
116 m
117 end
118 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
119
64ea71b @danlucraft Writing documentation
danlucraft authored Feb 13, 2010
120 # 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 Jan 23, 2010
121 def self.load
122 plugin_manager.load
123 if plugin_manager.unreadable_definitions.any?
124 puts "Couldn't read definition files: "
125 puts plugin_manager.unreadable_definitions.map {|d| " * " + d}
126 end
127 if plugin_manager.plugins_with_errors.any?
5b1be1a @rdp add some helper methods to window and document
rdp authored Feb 6, 2010
128 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 Jan 23, 2010
129 puts plugin_manager.plugins_with_errors.map {|d| " * " + d.name}
130 end
131 if ENV["PLUGIN_DEBUG"]
132 puts "Loaded plugins:"
133 puts plugin_manager.loaded_plugins.map {|d| " * " + d.name}
134 puts
135 puts "Unloaded plugins:"
136 puts plugin_manager.unloaded_plugins.map {|d| " * " + d.name}
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
137
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
138 end
139 end
140
64ea71b @danlucraft Writing documentation
danlucraft authored Feb 13, 2010
141 # Starts the GUI.
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
142 def self.pump
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
143 Redcar.gui.start
144 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
145
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
146 # Platform symbol
147 #
148 # @return [:osx/:windows/:linux]
149 def self.platform
150 case Config::CONFIG["target_os"]
151 when /darwin/
152 :osx
153 when /mswin|mingw/
154 :windows
155 when /linux/
156 :linux
157 end
158 end
4bf5b18 @danlucraft Speculative jmv change
danlucraft authored Jan 25, 2010
159
1fa016d @danlucraft Bumped version number to 0.3.3dev and merged boot.rb into redcar.rb
danlucraft authored Jan 23, 2010
160 # Platform specific ~/.redcar
161 #
162 # @return [String] expanded path
163 def self.user_dir
164 if platform == :windows
165 if ENV['USERPROFILE'].nil?
166 userdir = "C:/My Documents/.redcar/"
167 else
168 userdir = File.join(ENV['USERPROFILE'], ".redcar")
169 end
170 else
171 userdir = File.join(ENV['HOME'], ".redcar") unless ENV['HOME'].nil?
172 end
173 File.expand_path(userdir)
62aa218 @danlucraft Fix specs and features for new code loading
danlucraft authored Jan 9, 2010
174 end
64ea71b @danlucraft Writing documentation
danlucraft authored Feb 13, 2010
175
176 class << self
177 attr_accessor :app
178 attr_reader :gui
179 end
180
181 # Set the application GUI.
182 def self.gui=(gui)
183 raise "can't set gui twice" if @gui
184 @gui = gui
185 end
926d3dd @danlucraft Changed the install process so it requires a 'sudo redcar install' st…
danlucraft authored Jan 9, 2010
186 end
187
58640fb @danlucraft Move install command help into usage.rb
danlucraft authored Jan 9, 2010
188 usage = Redcar::Usage.new
189 usage.version_string
190 usage.version_requested
191 usage.help_requested
Something went wrong with that request. Please try again.