rubymotion_generators 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -32,6 +32,7 @@ Or install it yourself as:
32
32
  * vc - ViewController
33
33
  * tvc - TableViewController
34
34
  * tbapp - TabBar app (AppDelegate with two ViewController examples)
35
+ * tvapp - TableView app (AppDelegate with a TableViewController example)
35
36
 
36
37
  ## ToDo
37
38
 
@@ -12,10 +12,6 @@ module RubymotionGenerators
12
12
  args = args.flatten
13
13
  template_name = args[0]
14
14
  name = args[1]
15
- unless name
16
- puts "Missing name parameter"
17
- exit 1
18
- end
19
15
  case template_name
20
16
  when 'view'
21
17
  generate_view name
@@ -29,6 +25,9 @@ module RubymotionGenerators
29
25
  generate_tab_bar_app_delegate name
30
26
  generate_view_controller 'first'
31
27
  generate_view_controller 'second'
28
+ when 'tvapp'
29
+ generate_table_view_app_delegate
30
+ generate_table_view_controller 'example'
32
31
  else
33
32
  puts "Invalid template name '#{template_name}'"
34
33
  exit 1
@@ -44,32 +43,37 @@ module RubymotionGenerators
44
43
  insert_into_file(output_path, class_name, :after => 'class ')
45
44
  end
46
45
 
47
- def generate_table_view_controller(name)
46
+ def generate_table_view_controller(name = 'Untitled')
48
47
  output_path = "app/controllers/#{name}_table_view_controller.rb"
49
48
  template('templates/table_view_controller.rb', output_path)
50
49
  class_name = name.capitalize + "TableViewController"
51
50
  insert_into_file(output_path, class_name, :after => 'class ')
52
51
  end
53
52
 
54
- def generate_view_controller(name)
53
+ def generate_view_controller(name = 'Untitled')
55
54
  output_path = "app/controllers/#{name}_view_controller.rb"
56
55
  template('templates/view_controller.rb', output_path)
57
56
  class_name = name.capitalize + "ViewController"
58
57
  insert_into_file(output_path, class_name, :after => 'class ')
59
58
  end
60
59
 
61
- def generate_table_view_cell(name)
60
+ def generate_table_view_cell(name = 'Untitled')
62
61
  output_path = "app/views/cells/#{name}_table_view_cell.rb"
63
62
  template('templates/table_view_cell.rb', output_path)
64
63
  class_name = name.capitalize + "TableViewCell"
65
64
  insert_into_file(output_path, class_name, :after => 'class ')
66
65
  end
67
66
 
68
- def generate_tab_bar_app_delegate(name)
67
+ def generate_tab_bar_app_delegate
69
68
  output_path = "app/app_delegate.rb"
70
69
  template('templates/tab_bar_app_delegate.rb', output_path)
71
70
  end
72
71
 
72
+ def generate_table_view_app_delegate
73
+ output_path = "app/app_delegate.rb"
74
+ template('templates/table_view_app_delegate.rb', output_path)
75
+ end
76
+
73
77
  def self.source_root
74
78
  File.dirname(__FILE__)
75
79
  end
@@ -1,3 +1,3 @@
1
1
  module RubymotionGenerators
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,53 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
+ tabbar = UITabBarController.alloc.init
5
+ table_view_controller = ExampleTableViewController.alloc.init
6
+ #tabbar.title = NSBundle.mainBundle.infoDictionary["CFBundleName"]
7
+ @window.rootViewController = UINavigationController.alloc.initWithRootViewController(table_view_controller)
8
+ @window.makeKeyAndVisible
9
+ true
10
+ end
11
+
12
+ def applicationWillResignActive(application)
13
+ # Sent when the application is about to move from active to inactive state. This can occur for certain types of
14
+ # temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application
15
+ # and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and
16
+ # throttle down OpenGL ES frame rates. Games should use this method to pause the game.
17
+ end
18
+
19
+ def applicationDidEnterBackground(application)
20
+ # Use this method to release shared resources, save user data, invalidate timers, and store enough application
21
+ # state information to restore your application to its current state in case it is terminated later.If your
22
+ # application supports background execution, this method is called instead of applicationWillTerminate: when the
23
+ # user quits.
24
+ end
25
+
26
+ def applicationWillEnterForeground(application)
27
+ # Called as part of the transition from the background to the inactive state; here you can undo many of the
28
+ # changes made on entering the background.
29
+ end
30
+
31
+ def applicationDidBecomeActive(application)
32
+ # Restart any tasks that were paused (or not yet started) while the application was inactive. If the application
33
+ # was previously in the background, optionally refresh the user interface.
34
+ end
35
+
36
+ def applicationWillTerminate(application)
37
+ # Called when the application is about to terminate. Save data if appropriate. See also
38
+ # applicationDidEnterBackground
39
+ end
40
+
41
+ =begin
42
+ # Optional UITabBarControllerDelegate method.
43
+ def tabBarController(tabBarController, didSelectViewController:viewController)
44
+ end
45
+ =end
46
+
47
+ =begin
48
+ # Optional UITabBarControllerDelegate method.
49
+ def tabBarController(tabBarController, didEndCustomizingViewControllers:viewControllers, changed:changed)
50
+ end
51
+ =end
52
+ end
53
+
@@ -35,8 +35,8 @@ class < UITableViewController
35
35
  end
36
36
 
37
37
  def tableView(tableView, cellForRowAtIndexPath:indexPath)
38
- CellIdentifier = "Cell"
39
- cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier)
38
+ cellIdentifier = self.class.name
39
+ cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
40
40
  # Configure the cell...
41
41
  cell
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubymotion_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -60,6 +60,7 @@ files:
60
60
  - lib/rubymotion_generators.rb
61
61
  - lib/rubymotion_generators/version.rb
62
62
  - lib/templates/tab_bar_app_delegate.rb
63
+ - lib/templates/table_view_app_delegate.rb
63
64
  - lib/templates/table_view_cell.rb
64
65
  - lib/templates/table_view_controller.rb
65
66
  - lib/templates/view.rb