motion-table 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -16,3 +16,6 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .repl_history
19
+ build
20
+ build/*
21
+ *.000
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  MotionTable is a RubyMotion gem for easily building table views in iOS.
4
4
 
5
- *This gem has not been published to rubygems.org*
5
+ *RubyGems.org does not have the current version of this gem.*
6
6
 
7
7
  ## Installation
8
8
 
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  $:.unshift("/Library/RubyMotion/lib")
2
2
  require 'motion/project'
3
- require 'bundler'
3
+ require 'bundler/gem_tasks'
4
4
  Bundler.setup
5
+ Bundler.require
@@ -0,0 +1,96 @@
1
+ class AppDelegate
2
+ attr_accessor :window
3
+
4
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
5
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
6
+ @window.rootViewController = UINavigationController.alloc.initWithRootViewController(MainViewController.alloc.init)
7
+ @window.makeKeyAndVisible
8
+ end
9
+ end
10
+ class TestViewController < UITableViewController
11
+ include MotionTable::GroupedTable
12
+
13
+ def viewDidLoad
14
+ super
15
+ self.title = "GroupedTable"
16
+
17
+ grouped_table_view_data = [
18
+ {
19
+ title: "Your Account",
20
+ cells: [
21
+ { title: "Edit Profile", action: :edit_profile },
22
+ { title: "Log Out", action: :log_out },
23
+ ]
24
+ },
25
+ {
26
+ title: "Test",
27
+ cells: [
28
+ { title: "About", action: :something_here },
29
+ { title: "Feedback", action: :something_here }
30
+ ]
31
+ }
32
+ ]
33
+
34
+ self.tableView = self.createTableViewFromData(grouped_table_view_data)
35
+ end
36
+
37
+ def edit_profile
38
+ return "edit_profile"
39
+ end
40
+ def push(view_class)
41
+ view = view_class.alloc.initWithNibName(nil, bundle: nil)
42
+ self.navigationController.pushViewController(view, animated: true)
43
+ end
44
+ def pop
45
+ self.navigationController.popViewControllerAnimated(true)
46
+ end
47
+ def pop_all
48
+ UIApplication.sharedApplication.delegate.initial_view
49
+ end
50
+ end
51
+ class MainViewController < UIViewController
52
+
53
+ def viewDidLoad
54
+ super
55
+ self.title = "MotionTable"
56
+ rightButton = UIBarButtonItem.alloc.initWithTitle("Table Demo", style: UIBarButtonItemStyleBordered, target: self, action: 'grouped_table')
57
+ self.navigationItem.rightBarButtonItem = rightButton
58
+
59
+ self.view.backgroundColor = UIColor.whiteColor
60
+
61
+ @motionTableLabel = UILabel.alloc.initWithFrame(CGRectMake(20, 10, 90, 40))
62
+ @motionTableLabel.text = "MotionTable"
63
+ @motionTableLabel.textColor = UIColor.blueColor
64
+ @motionTableLabel.sizeToFit
65
+
66
+ @colon = UILabel.alloc.initWithFrame(CGRectMake(115, 10, 10, 10))
67
+ @colon.text = "::"
68
+ @colon.textColor = UIColor.grayColor
69
+ @colon.sizeToFit
70
+
71
+ @groupedTableLabel = UILabel.alloc.initWithFrame(CGRectMake(125, 10, 90, 40))
72
+ @groupedTableLabel.text = "GroupedTable"
73
+ @groupedTableLabel.textColor = UIColor.greenColor
74
+ @groupedTableLabel.sizeToFit
75
+
76
+ self.view.addSubview @motionTableLabel
77
+ self.view.addSubview @colon
78
+ self.view.addSubview @groupedTableLabel
79
+ end
80
+
81
+
82
+ def grouped_table
83
+ push TestViewController
84
+ end
85
+ def push(view_class)
86
+ view = view_class.alloc.initWithNibName(nil, bundle: nil)
87
+ self.navigationController.pushViewController(view, animated: true)
88
+ end
89
+ def pop
90
+ self.navigationController.popViewControllerAnimated(true)
91
+ end
92
+ def pop_all
93
+ UIApplication.sharedApplication.delegate.initial_view
94
+ end
95
+
96
+ end
@@ -0,0 +1,21 @@
1
+ module MotionTable
2
+ class Console
3
+ NAME = "MotionTable::Console"
4
+ DEFAULT_COLOR = [ '', '' ]
5
+ RED_COLOR = [ "\e[0;31m", "\e[0m" ] # Must be in double quotes
6
+
7
+ class << self
8
+ def log(obj, actionNotImplemented:action)
9
+ log " actionNotImplemented -- the action :#{action} is not implemented in #{obj.class.to_s}", withColor: RED_COLOR
10
+ end
11
+
12
+ def log(log, withColor:color)
13
+ puts color[0] + NAME + log + color[1]
14
+ end
15
+
16
+ def log(log)
17
+ log(log, withColor: DEFAULT_COLOR)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -42,6 +42,8 @@ module MotionTable
42
42
  tableView.deselectRowAtIndexPath(indexPath, animated: true);
43
43
  if self.respond_to?(cell[:action])
44
44
  self.send(cell[:action])
45
+ else
46
+ MotionTable::Console.log(self, actionNotImplemented: cell[:action])
45
47
  end
46
48
  end
47
49
 
@@ -1,3 +1,3 @@
1
1
  module MotionTable
2
- VERSION = "0.1.0" unless defined?(MotionTable::VERSION)
2
+ VERSION = "0.1.1" unless defined?(MotionTable::VERSION)
3
3
  end
File without changes
@@ -0,0 +1,40 @@
1
+ describe "Test App" do
2
+ before do
3
+ @app = UIApplication.sharedApplication
4
+ end
5
+
6
+ it "has one window" do
7
+ @app.windows.size.should == 1
8
+ end
9
+
10
+ describe "MotionTable::Grouped Table Mixin" do
11
+ tests TestViewController
12
+
13
+ it "includes MotionTable::GroupedTable as a mixin" do
14
+ controller.class.included_modules.should.include?(MotionTable::GroupedTable)
15
+ end
16
+
17
+ it "creates a UITableView with UITableViewStyleGrouped from array" do
18
+ data = [
19
+ {
20
+ title: "Your Account",
21
+ cells: [
22
+ { title: "Edit Profile", action: :whatever },
23
+ { title: "Log Out", action: :log_out },
24
+ ]
25
+ },
26
+ {
27
+ title: "Test",
28
+ cells: [
29
+ { title: "About", action: :something_here },
30
+ { title: "Feedback", action: :something_here }
31
+ ]
32
+ }
33
+ ]
34
+
35
+ controller.createTableViewFromData(data)
36
+ controller.view.style.should == UITableViewStyleGrouped
37
+ true.should == true
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2012-08-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: MotionTable is a RubyMotion gem that makes it easy to handle UITableViews
15
15
  from a UITableViewController.
@@ -24,10 +24,14 @@ files:
24
24
  - LICENSE
25
25
  - README.md
26
26
  - Rakefile
27
+ - app/app_delegate.rb
27
28
  - lib/motion-table.rb
29
+ - lib/motion-table/console.rb
28
30
  - lib/motion-table/grouped_table.rb
29
31
  - lib/motion-table/version.rb
30
32
  - motion-table.gemspec
33
+ - spec/console_spec.rb
34
+ - spec/grouped_table_spec.rb
31
35
  homepage: https://github.com/clearsightstudio/motion-table
32
36
  licenses: []
33
37
  post_install_message:
@@ -53,5 +57,7 @@ signing_key:
53
57
  specification_version: 3
54
58
  summary: MotionTable is a RubyMotion gem that makes it easy to handle UITableViews
55
59
  from a UITableViewController.
56
- test_files: []
60
+ test_files:
61
+ - spec/console_spec.rb
62
+ - spec/grouped_table_spec.rb
57
63
  has_rdoc: