diff --git a/English.lproj/MainMenu.nib/designable.nib b/English.lproj/MainMenu.nib/designable.nib index 3976790..763aeeb 100644 --- a/English.lproj/MainMenu.nib/designable.nib +++ b/English.lproj/MainMenu.nib/designable.nib @@ -8,10 +8,10 @@ 353.00 YES + + - - YES @@ -40,7 +40,7 @@ 2 {{196, 216}, {285, 294}} 1677722624 - Window + Run Task NSWindow {3.40282e+38, 3.40282e+38} @@ -227,9 +227,7 @@ 2 {{363, 594}, {332, 396}} 1886912512 - - Window - + Preferences NSWindow @@ -767,38 +765,6 @@ 481 - - - hostField - - - - 482 - - - - newHostSheet - - - - 483 - - - - passwordField - - - - 484 - - - - preferencesWindow - - - - 485 - spinner @@ -807,22 +773,6 @@ 486 - - - tableView - - - - 487 - - - - usernameField - - - - 488 - add: @@ -927,6 +877,54 @@ 525 + + + preferences_window + + + + 526 + + + + table_view + + + + 527 + + + + new_host_sheet + + + + 528 + + + + host_field + + + + 529 + + + + password_field + + + + 530 + + + + username_field + + + + 531 + @@ -1533,9 +1531,9 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{557, 344}, {371, 206}} + {{647, 562}, {371, 206}} com.apple.InterfaceBuilder.CocoaPlugin - {{557, 344}, {371, 206}} + {{647, 562}, {371, 206}} {{120, 647}, {371, 206}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1561,9 +1559,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{502, 604}, {571, 327}} + {{418, 604}, {571, 327}} com.apple.InterfaceBuilder.CocoaPlugin - {{502, 604}, {571, 327}} + {{418, 604}, {571, 327}} {571, 303} @@ -1599,7 +1597,7 @@ - 525 + 531 @@ -1628,15 +1626,13 @@ YES YES - addButton - cancelButton - hostField - newHostSheet - passwordField - preferencesWindow + host_field + new_host_sheet + password_field + preferences_window spinner - tableView - usernameField + table_view + username_field YES @@ -1647,8 +1643,6 @@ id id id - id - id diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib index 404511a..8770234 100644 Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/controller/preferences_controller.rb b/controller/preferences_controller.rb index e5df3e6..22b5982 100644 --- a/controller/preferences_controller.rb +++ b/controller/preferences_controller.rb @@ -9,15 +9,13 @@ class PreferencesController < OSX::NSWindowController notify :host_version_not_accepted, :when => :host_version_inacceptable notify :host_credentials_invalid, :when => :host_credentials_invalid - ib_outlet :preferencesWindow - ib_outlet :tableView - ib_outlet :newHostSheet - ib_outlet :addButton - ib_outlet :cancelButton + ib_outlet :preferences_window + ib_outlet :table_view + ib_outlet :new_host_sheet ib_outlet :spinner - ib_outlet :hostField - ib_outlet :usernameField - ib_outlet :passwordField + ib_outlet :host_field + ib_outlet :username_field + ib_outlet :password_field def init init_hosts @@ -53,53 +51,52 @@ def fetchPasswords def showPreferences NSApp.activateIgnoringOtherApps true self.showWindow(self) - @preferencesWindow.makeKeyAndOrderFront(self) - @preferencesWindow.setTitle("Preferences") + @preferences_window.makeKeyAndOrderFront(self) end - def numberOfRowsInTableView(tableView) + def numberOfRowsInTableView(table_view) @hosts.size end - def tableView_objectValueForTableColumn_row(tableView, column, row) + def tableView_objectValueForTableColumn_row(table_view, column, row) @hosts[row].url end ib_action :add do - NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(@newHostSheet, @preferencesWindow, nil, nil, nil) - NSApp.endSheet @newHostSheet + NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(@new_host_sheet, @preferences_window, nil, nil, nil) + NSApp.endSheet @new_host_sheet end ib_action :addFromSheet do @spinner.startAnimation(self) @spinner.setHidden(false) host = Host.new - host.url = @hostField.stringValue - host.username = @usernameField.stringValue - host.password = @passwordField.stringValue.to_s + host.url = @host_field.stringValue + host.username = @username_field.stringValue + host.password = @password_field.stringValue.to_s host.schedule_version_check end def host_version_accepted(notification) # ignore messages to instances not connected to the nib. weird side effect of having an instance # of the controller in the project_controller - return if @hostField.nil? + return if @host_field.nil? host = notification.object add_host host - @newHostSheet.orderOut self - @tableView.reloadData + @new_host_sheet.orderOut self + @table_view.reloadData host.find_projects end def host_version_not_accepted(notification) - return if @hostField.nil? + return if @host_field.nil? host = notification.object show_alert("The Webistrano version you're running is not suitable for use with Macistrano", "You need at least version #{Host::ACCEPT_VERSION.join(".")}.") reset_spinner end def host_credentials_invalid(notification) - return if @hostField.nil? + return if @host_field.nil? show_alert("The specified credentials are invalid.", "Please check username and password and try again.") reset_spinner end @@ -126,18 +123,18 @@ def reset_spinner end ib_action :removeHost do - unless @tableView.selectedRow < 0 - host = @hosts[@tableView.selectedRow] + unless @table_view.selectedRow < 0 + host = @hosts[@table_view.selectedRow] Keychain.remove_password host - @hosts.delete_at(@tableView.selectedRow) + @hosts.delete_at(@table_view.selectedRow) save_hosts_to_preferences notify_host_removed host - @tableView.reloadData + @table_view.reloadData end end def closeSheet - @newHostSheet.orderOut self + @new_host_sheet.orderOut self end def add_host host @@ -160,9 +157,9 @@ def hosts_as_list end def reset_fields - @hostField.setStringValue "" - @newHostSheet.makeFirstResponder @hostField - @passwordField.setStringValue "" - @usernameField.setStringValue "" + @host_field.setStringValue "" + @new_host_sheet.makeFirstResponder @host_field + @password_field.setStringValue "" + @username_field.setStringValue "" end end diff --git a/controller/project_controller.rb b/controller/project_controller.rb index 7d3a2af..4fc1027 100644 --- a/controller/project_controller.rb +++ b/controller/project_controller.rb @@ -155,7 +155,6 @@ def clicked(sender) @task_field.setStringValue(sender.representedObject.name) NSApp.activateIgnoringOtherApps(true) @run_task_dialog.makeFirstResponder(@description_field) - @run_task_dialog.setTitle("Run Task") @run_task_dialog.makeKeyAndOrderFront(self) @run_task_dialog.center end diff --git a/model/host.rb b/model/host.rb index 5a3f082..daff2bf 100644 --- a/model/host.rb +++ b/model/host.rb @@ -24,8 +24,13 @@ def init @projects = [] self end + + def url=(url) + url = "http://#{url}" unless url.index("http://") == 0 or url.index("https://") == 0 + @url = url + end - def read_xml path + def read_xml(path) io = open("#{url}#{path}", :http_basic_authentication => [username, password]) io.read end diff --git a/spec/host_spec.rb b/spec/host_spec.rb index 2a43457..b429985 100644 --- a/spec/host_spec.rb +++ b/spec/host_spec.rb @@ -153,8 +153,25 @@ def fetch_stages end end -describe Host, "when checking for the host version" do +describe Host, "when setting the url" do + before(:each) do + @host = Host.new + end + + it "should append http:// if url is not complete" do + @host.url = "webistrano.local" + @host.url.should == "http://webistrano.local" + end + it "should not append http:// if url has http:// set" do + @host.url = "http://webistrano.local" + @host.url.should == "http://webistrano.local" + end + + it "should not append http:// if url has https:// set" do + @host.url = "https://webistrano.local" + @host.url.should == "https://webistrano.local" + end end describe Host, "when notified that a project finished loading" do