diff --git a/.bacon b/.bacon new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.bacon @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile index 764be63..a905332 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ source 'https://rubygems.org' gem 'rake' +gem 'motion-redgreen' # Add your dependencies here: diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..21cffda --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,12 @@ +GEM + remote: https://rubygems.org/ + specs: + motion-redgreen (0.1.0) + rake (10.3.2) + +PLATFORMS + ruby + +DEPENDENCIES + motion-redgreen + rake diff --git a/Rakefile b/Rakefile index e905dc4..14fef65 100644 --- a/Rakefile +++ b/Rakefile @@ -11,4 +11,5 @@ end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. app.name = 'tymur' + app.redgreen_style = :full end diff --git a/app/app_delegate.rb b/app/app_delegate.rb index 43b2aa9..fbf8e78 100644 --- a/app/app_delegate.rb +++ b/app/app_delegate.rb @@ -1,5 +1,10 @@ class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) - true + vc = TimerController.new + + @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) + @window.rootViewController = vc + @window.rootViewController.wantsFullScreenLayout = true + @window.makeKeyAndVisible end end diff --git a/app/coach.rb b/app/coach.rb new file mode 100644 index 0000000..40a3823 --- /dev/null +++ b/app/coach.rb @@ -0,0 +1,14 @@ +class Coach + attr_accessor :rounds_count + + def initialize + self.rounds_count = 0 + end + + def average + end + + def record_round + self.rounds_count = self.rounds_count + 1 + end +end diff --git a/app/timer_controller.rb b/app/timer_controller.rb new file mode 100644 index 0000000..f89b5f5 --- /dev/null +++ b/app/timer_controller.rb @@ -0,0 +1,10 @@ +class TimerController < UIViewController + def loadView + self.view = TimerView.new + end + + def viewDidLoad + view.backgroundColor = UIColor.whiteColor + super + end +end diff --git a/app/timer_view.rb b/app/timer_view.rb new file mode 100644 index 0000000..85f031e --- /dev/null +++ b/app/timer_view.rb @@ -0,0 +1,19 @@ +class TimerView < UIView + attr_accessor :counter_label + + def drawRect(rect) + super rect + create_counter_label + end + + def create_counter_label + counter_label = UILabel.new + counter_label.text = "0" + counter_label.frame = self.frame + counter_label.adjustsFontSizeToFitWidth = true + counter_label.font = UIFont.fontWithName("Arial", size:64) + + + self.addSubview(counter_label) + end +end diff --git a/spec/coach_spec.rb b/spec/coach_spec.rb new file mode 100644 index 0000000..3c44a16 --- /dev/null +++ b/spec/coach_spec.rb @@ -0,0 +1,25 @@ +describe "Coach" do + before do + @coach = Coach.new + end + + context "with zero rounds" do + it "does not have an average" do + @coach.average.should == nil + end + + it "has zero rounds" do + @coach.average.should == nil + end + end + + describe "record_round" do + before do + @coach.record_round + end + + it "increments the count" do + @coach.rounds_count.should == 1 + end + end +end