motion-momentum 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddc2e4b530fce838ceab0386e65b3f0a9b7d8a96
4
- data.tar.gz: 07d02f37340b839d82333534cfd24a5bc7b95594
3
+ metadata.gz: 35bac3aa4e9d7529267bf224811942bf32219fa8
4
+ data.tar.gz: dd586ab8bc2079b9ed4a14a59eb71d9495116a59
5
5
  SHA512:
6
- metadata.gz: 4438273e9bb261496f03fa5b78242525b446241a2440bda22ca296433b756db5267f5c53aca4bec1ee80fd4c6c720482155cefebd68aea292c34b63778365ff3
7
- data.tar.gz: 1a816fbfd0943af5fc2de2dafcdca02ab86dbad872aa345168b82dde66a210b1feb7b3c876de78efd5b6e482c2e0754dbd5fcfb7c8fa7922b05a13009dcc4ef0
6
+ metadata.gz: a73b0b4d1edab87c3dc18842a3b9a81583d698b2c81c75a97e4ede89f64e7601f20d9bd87a43d125dbe004365377333bd1638b3455fbfddb97f0fda27f8a025a
7
+ data.tar.gz: d931218f5ce551404717e292153406dce3627602c9a5405427bfcd6153506d2953ce256ddd2d274c6f7fc1272fee3d8cb3979f7a875dfc1ca9ac89e3e7d6d9a8
data/README.md CHANGED
@@ -1,12 +1,119 @@
1
1
  # Momentum
2
2
 
3
- [![Build Status](https://travis-ci.org/FluffyJack/motion-momentum.png)](https://travis-ci.org/FluffyJack/motion-momentum) [![Code Climate](https://codeclimate.com/github/FluffyJack/motion-momentum.png)](https://codeclimate.com/github/FluffyJack/motion-momentum) [![Dependency Status](https://gemnasium.com/FluffyJack/motion-momentum.png)](https://gemnasium.com/FluffyJack/motion-momentum)
3
+ [![Gem Version](https://badge.fury.io/rb/motion-momentum.png)](http://badge.fury.io/rb/motion-momentum) [![Build Status](https://travis-ci.org/FluffyJack/motion-momentum.png)](https://travis-ci.org/FluffyJack/motion-momentum) [![Code Climate](https://codeclimate.com/github/FluffyJack/motion-momentum.png)](https://codeclimate.com/github/FluffyJack/motion-momentum) [![Dependency Status](https://gemnasium.com/FluffyJack/motion-momentum.png)](https://gemnasium.com/FluffyJack/motion-momentum)
4
4
 
5
5
  Momentum is a RubyMotion framework for creating iOS and OS X applications the "Rails" way.
6
6
 
7
+ I suggest you use this framework with [RMQ](https://github.com/infinitered/rmq) and [CDQ](https://github.com/infinitered/cdq).
8
+
9
+ This framework is being developed along side the [RubyMotion for Rails Developers book](http://book.motioninmotion.tv/), but my vision for it is most certainly to help the long term happiness of the RubyMotion community. Please share your ideas by submitting an issue here on GitHub. Show support by purchasing the book or [subscribe to my screencasts](https://motioninmotion.tv/).
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'motion-momentum'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install motion-momentum
24
+
7
25
  ## Usage
8
26
 
9
- Proposed ideas can be found in this gist: [https://gist.github.com/FluffyJack/9409243](https://gist.github.com/FluffyJack/9409243)
27
+ This framework is still in it's early days. Feel free to use it, but understand that until v1.x the API may change between releases. Proposed ideas can be found in this gist: [https://gist.github.com/FluffyJack/9409243](https://gist.github.com/FluffyJack/9409243).
28
+
29
+ ### Application Structure
30
+
31
+ Momentum tries to take a convention-over-configuration approach. A controller called `MainController` will assign it's view to be `MainView`, it's delegate (and the view's `delegate` and `dataSource` attribtues if they exist) to be `MainDelegate`, and it's stylesheet to be `MainStylesheet`, though stylesheets have not been properly integrated yet, and so, using a stylesheet gem is suggested.
32
+
33
+ The suggested application structure is as follows:
34
+
35
+ ```
36
+ app
37
+ \- app_delegate.rb
38
+ \- controllers
39
+ \- posts_controller.rb
40
+ \- delegates
41
+ \- posts_delegate.rb
42
+ \- models
43
+ \- post.rb
44
+ \- stylesheets
45
+ \- posts_stylesheet.rb
46
+ \- views
47
+ \- posts_view.rb
48
+ ```
49
+
50
+ ### Controllers
51
+
52
+ To create a Momentum controller which will help you clean up your controller code, you can just inherit from `Momentum::ViewController` for iOS. OS X support is coming soon and a `Momentum::WindowController` will be available then.
53
+
54
+ ```ruby
55
+ class PostsController < Momentum::ViewController
56
+ title "Posts"
57
+
58
+ def setup
59
+ self.delegate.data[:posts] = Post.all
60
+ end
61
+ end
62
+ ```
63
+
64
+ You can also just include the `Momentum::ViewControllerModule`, though this isn't well tested with support for other types of view controllers yet (remember, very early days).
65
+
66
+ If you want to choose which view, delegate, or stylesheet class is used, you can do so.
67
+
68
+ ```ruby
69
+ class PostsController < Momentum::ViewController
70
+ view "PostsView"
71
+ delegate "PostsDelegate"
72
+ stylesheet "PostsStylesheet"
73
+ title "Posts"
74
+
75
+ def setup
76
+ self.delegate.data[:posts] = Post.all
77
+ end
78
+ end
79
+ ```
80
+
81
+ ### Views
82
+
83
+ Views are currently just standard `UIViews`.
84
+
85
+ ```ruby
86
+ class PostsView < UITableView
87
+ end
88
+ ```
89
+
90
+ ### Delegates
91
+
92
+ Delegates are fairly stock standard, but you can inherit from `Momentum::Delegate` to get a nice `data` attribute to pass data to your delegate for you view to consume.
93
+
94
+ ```ruby
95
+ class PostsDelegate < Momentum::Delegate
96
+ def tableView(tableView, numberOfRowsInSection:section)
97
+ self.data[:posts].count
98
+ end
99
+
100
+ def tableView(tableView, cellForRowAtIndexPath:indexPath)
101
+ @reuseIdentifier ||= "CELL_IDENTIFIER"
102
+
103
+ cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier) || begin
104
+ UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier:@reuseIdentifier)
105
+ end
106
+
107
+ cell.textLabel.text = self.data[:posts][indexPath.row].title
108
+
109
+ cell
110
+ end
111
+
112
+ def tableView(tableView, didSelectRowAtIndexPath:indexPath)
113
+ # push the detail controller with the post
114
+ end
115
+ end
116
+ ```
10
117
 
11
118
  ## Contributing
12
119
 
@@ -42,7 +42,7 @@ module Momentum
42
42
  self.view.dataSource = self.delegate if self.view.class.instance_methods.include?(:dataSource)
43
43
  end
44
44
 
45
- def viewDidAppear(animated)
45
+ def viewWillAppear(animated)
46
46
  self.setup if self.class.instance_methods.include?(:setup)
47
47
  end
48
48
 
@@ -1,3 +1,3 @@
1
1
  module Momentum
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -43,7 +43,7 @@ describe Momentum::ViewController do
43
43
 
44
44
  it "calls setup if it's defined when the view appears" do
45
45
  CallbackHelper.shared.data[:setup_called] = false
46
- @vc.viewDidAppear(true)
46
+ @vc.viewWillAppear(true)
47
47
  CallbackHelper.shared.data[:setup_called].should == true
48
48
  end
49
49
 
@@ -52,7 +52,7 @@ describe Momentum::ViewController do
52
52
  end
53
53
 
54
54
  it "will still use the title instance variable though" do
55
- @vc.viewDidAppear(true)
55
+ @vc.viewWillAppear(true)
56
56
  @vc.title.should == "Custom"
57
57
  end
58
58
 
@@ -63,7 +63,7 @@ describe Momentum::ViewController do
63
63
  before { @vc = NoSetupMockController.new }
64
64
 
65
65
  it "does not call setup if it's not defined when the view appears" do
66
- lambda { @vc.viewDidAppear(true) }.should.not.raise(NoMethodError)
66
+ lambda { @vc.viewWillAppear(true) }.should.not.raise(NoMethodError)
67
67
  end
68
68
 
69
69
  it "will return nil with no class title or title instance variable" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-momentum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Dean Watson-Hamblin