Skip to content
Browse files

Formatting

  • Loading branch information...
1 parent 2781c63 commit 9a2a45992657f066815488ec00ba83234ea81f99 Jeroen Jacobs committed Feb 16, 2010
Showing with 46 additions and 46 deletions.
  1. +31 −29 ChillDocument.rb
  2. +11 −12 SplitViewDelegate.rb
  3. +1 −1 Tests/run_suite.rb
  4. +1 −1 Tests/stub_test.rb
  5. +1 −1 parameter.rb
  6. +1 −2 rb_main.rb
View
60 ChillDocument.rb
@@ -1,8 +1,8 @@
class ChillDocument < NSPersistentDocument
attr_accessor :request_url, :request_method, :output, :indicator, :request_headers, :headers_tab_view
-
+
attr_accessor :engine
-
+
def init
if super
@engine = Wrapper.new
@@ -15,29 +15,28 @@ def awakeFromNib
@http_headers = []
@request_headers.dataSource = self
end
-
- # Name of nib containing document window
- def windowNibName
- 'ChillDocument'
- end
-
- # Document data representation for saving (return NSData)
- def dataOfType(type, error:outError)
- outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
- nil
- end
- # Read document from data (return non-nil on success)
- def readFromData(data, ofType:type, error:outError)
- outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
- nil
- end
+ # Name of nib containing document window
+ def windowNibName
+ 'ChillDocument'
+ end
- # Return lowercase 'untitled', to comply with HIG
- def displayName
- fileURL ? super : super.sub(/^[[:upper:]]/) {|s| s.downcase}
- end
+ # Document data representation for saving (return NSData)
+ def dataOfType(type, error:outError)
+ outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
+ nil
+ end
+ # Read document from data (return non-nil on success)
+ def readFromData(data, ofType:type, error:outError)
+ outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
+ nil
+ end
+
+ # Return lowercase 'untitled', to comply with HIG
+ def displayName
+ fileURL ? super : super.sub(/^[[:upper:]]/) {|s| s.downcase}
+ end
@@ -65,6 +64,8 @@ def tableView(view, setObjectValue:object, forTableColumn:column, row:index)
end
+
+
# GUI Actions
def rest_call(sender)
url = NSURL.URLWithString(request_url.stringValue)
@@ -78,6 +79,7 @@ def rest_call(sender)
+
# REST Wrapper Delegates
def wrapper(engine, didRetrieveData:data)
response = engine.httpResponse
@@ -101,7 +103,7 @@ def wrapper(engine, didRetrieveData:data)
end
def wrapperHasBadCredentials(wrapper)
- #handle this in here by showing an overlay in which you can enter your credentials
+ # handle this in here by showing an overlay in which you can enter your credentials
stop_indicator
alert = NSAlert.alertWithMessageText("Bad credentials!", defaultButton:"OK", alternateButton:nil, otherButton:nil, informativeTextWithFormat:"Please specify a valid username and password")
alert.runModal
@@ -120,8 +122,8 @@ def wrapper(wrapper, didFailWithError:error)
end
#def wrapper(wrapper, didReceiveStatusCode:statusCode)
- # stop_indicator
- # alert = NSAlert.alertWithMessageText("Status code not OK", defaultButton:"OK", alternateButton:nil, otherButton:nil, informativeTextWithFormat:"I am an alert!")
+ # stop_indicator
+ # alert = NSAlert.alertWithMessageText("Status code not OK", defaultButton:"OK", alternateButton:nil, otherButton:nil, informativeTextWithFormat:"I am an alert!")
# alert.runModal
#end
@@ -136,22 +138,22 @@ def stop_indicator
indicator.setHidden(true)
indicator.stopAnimation(self)
end
-
+
def show_response_tab
headers_tab_view.selectLastTabViewItem(self)
end
-
+
def request_parameters
parameters = {}
begin
context = self.managedObjectContext
all_parameters_request = NSFetchRequest.alloc.init
all_parameters_request.entity = NSEntityDescription.entityForName('Parameter', inManagedObjectContext:context)
-
+
error = nil
array = context.executeFetchRequest(all_parameters_request, error:error)
-
+
if array.size > 0
array.each do |parameter|
parameters[parameter.valueForKey('name')] = parameter.valueForKey('value') if parameter.valueForKey('name') && parameter.valueForKey('value')
View
23 SplitViewDelegate.rb
@@ -1,15 +1,14 @@
class SplitViewDelegate
+ attr_accessor :split_view
- attr_accessor :split_view
-
- MIN_SIZE = 200
- MAX_SIZE = 100 # height - this
-
- def splitView(split_view, constrainMinCoordinate: proposed_coordinate, ofSubviewAt: index)
- proposed_coordinate + MIN_SIZE
- end
-
- def splitView(split_view, constrainMaxCoordinate: proposed_coordinate, ofSubviewAt: index)
- proposed_coordinate - MAX_SIZE
- end
+ MIN_SIZE = 200
+ MAX_SIZE = 100 # height - this
+
+ def splitView(split_view, constrainMinCoordinate: proposed_coordinate, ofSubviewAt: index)
+ proposed_coordinate + MIN_SIZE
+ end
+
+ def splitView(split_view, constrainMaxCoordinate: proposed_coordinate, ofSubviewAt: index)
+ proposed_coordinate - MAX_SIZE
+ end
end
View
2 Tests/run_suite.rb
@@ -1 +1 @@
-Dir.glob(File.expand_path('../**/*_test.rb', __FILE__)).each { |test| require test }
+Dir.glob(File.expand_path('../**/*_test.rb', __FILE__)).each { |test| require test }
View
2 Tests/stub_test.rb
@@ -14,4 +14,4 @@ def teardown
def test_fail
assert false, 'Assertion was false.'
end
-end
+end
View
2 parameter.rb
@@ -1,3 +1,3 @@
class Parameter
- attr_accessor :name, :value
+ attr_accessor :name, :value
end
View
3 rb_main.rb
@@ -1,5 +1,4 @@
-# Loading the Cocoa framework. If you need to load more frameworks, you can
-# do that here too.
+# Loading the Cocoa framework. If you need to load more frameworks, you can do that here too.
framework 'Cocoa'
framework 'CoreData'

0 comments on commit 9a2a459

Please sign in to comment.
Something went wrong with that request. Please try again.