Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring ZACFactory, take 2

  • Loading branch information...
commit a6f2df64c5f4c4c879463bd7bd7b549059cc876f 1 parent 6de27cf
Dimitri Tischenko authored
View
5 Rakefile
@@ -8,7 +8,7 @@ Motion::Project::App.setup do |app|
app.name = 'ZAC'
app.info_plist['CFBundleShortVersionString'] = '0.8'
- app.info_plist['CFBundleVersion'] = '3'
+ app.info_plist['CFBundleVersion'] = '4'
app.codesign_certificate = 'iPhone Developer: Joachim Nolten (PNCKXWS2NR)'
@@ -17,9 +17,6 @@ Motion::Project::App.setup do |app|
app.provisioning_profile = '/Users/joachim/ZAC_distribution.mobileprovision'
app.files += Dir.glob(File.join(app.project_dir, 'lib/**/*.rb'))
- # app.pods do
- # dependency 'GData'
- # end
app.icons = %w{ icon.png }
View
2  app/game.rb
@@ -12,7 +12,7 @@ def initialize team1, team2, datetime, field
@team2 = team1
@datetime = datetime
@field = field
- @@all << self
+# @@all << self
end
# def self.all
View
16 app/team.rb
@@ -28,27 +28,11 @@ def upcomingGames
games.find_all { |game| game.datetime >= Time.new }
end
- def self.findOrCreate teamName, game
- team = find_by_name teamName
- unless team
- team = Team.new teamName
- end
- team.addGame game
- team
- end
# def self.all
# @@all
# end
- def self.find_by_name teamname
- if @@all.count > 0
- @@all.find do |team|
- team.name == teamname
- end
- end
- end
-
def to_s
@name
end
View
30 app/zac_factory.rb
@@ -1,31 +1,35 @@
class ZAC
attr_reader :games, :teams
-
- @@instance = ZAC.new
-
- @dateFormatter = NSDateFormatter.alloc.init.setDateFormat("dd-MM-yyyy HH:mm:ss")
-
+
def initialize
+ # puts "ZAC initialize"
+ @receivedData = NSMutableData.new
+ @dateFormatter = NSDateFormatter.alloc.init.setDateFormat("dd-MM-yyyy HH:mm:ss")
link = 'https://spreadsheets.google.com/feeds/list/0Aoe6kaQMB4f4dGRNajhvYlFCT3V4MVNOZlZXZ0tyckE/1/public/basic/'
feedURL = NSURL.URLWithString(link)
@request = NSURLRequest.requestWithURL(feedURL)
- @receivedData = NSMutableData.new
- @connection = NSURLConnection.connectionWithRequest(request, delegate:self)
- @games = []
- @teams = []
- @entries = []
+ p @connection
end
+ @@instance = ZAC.new
+
def fetch(sender)
+ # puts "fetch"
+ @games = []
+ @teams = []
+ @entries = []
@delegate = sender
+ @connection = NSURLConnection.connectionWithRequest(@request, delegate:self)
@connection.start
end
def find_or_create_team teamName
team = find_team_by_name teamName
+ # puts("find_or_create #{teamName} => #{team}")
unless team
team = Team.new teamName
+ @teams << team
end
team
end
@@ -37,10 +41,12 @@ def find_team_by_name teamname
end
def connection(connection, didReceiveResponse:response)
+ # puts ("connection didReceiveResponse")
@receivedData.setLength(0)
end
def connection(connection, didReceiveData:data)
+ # puts ("connection didReceiveData")
@receivedData.appendData(data)
end
@@ -80,7 +86,6 @@ def parser(parser, didEndElement:elementName, namespaceURI:namespaceURI, qualifi
team1.addGame(game)
team2.addGame(game)
@games << game
- @teams << team1 << team2
@entries << @rowHash
@inEntry = false
elsif elementName == "title" && @inEntry
@@ -106,7 +111,8 @@ def parseContents(string)
end
def self.instance
- return @@instance
+ # puts "self.instance: #{@@instance}"
+ @@instance
end
private_class_method :new
View
2  app/zac_teams_controller.rb
@@ -33,6 +33,6 @@ def prepareForSegue(segue, sender:sender)
# puts("defaults: synchronizing")
# defaults.synchronize
# end
- puts("prepareForSegue, segue=#{segue.identifier}, sender=#{sender.textLabel.text}")
+ # puts("prepareForSegue, segue=#{segue.identifier}, sender=#{sender.textLabel.text}")
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.