rubymotion_generators 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,17 +18,26 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- rmgen v welcome #=> app/welcome_view.rb
22
- rmgen tvcell person #=> app/person_table_view_cell.rb
23
- rmgen vc person #=> app/person_view_controller.rb
24
- rmgen tvc people #=> app/people_table_view_controller.rb
21
+ motion_g <template> <name>
22
+
23
+ ## Example
24
+
25
+ motion create MyApp
26
+ motion_g vc welcome #=> app/views/welcome_view_controller.rb
27
+
28
+ ## Available Generators
29
+
30
+ * view - View
31
+ * cell - TableViewCell
32
+ * vc - ViewController
33
+ * tvc - TableViewController
34
+ * tbapp - TabBar app (AppDelegate with two ViewController examples)
25
35
 
26
36
  ## ToDo
27
37
 
28
- - AppDelegate (TabBar, etc.)
29
38
  - iPad option
30
39
  - Tests
31
- - Ability to specify file path
40
+ - Built-in help
32
41
 
33
42
  ## Contributing
34
43
 
File without changes
@@ -1,3 +1,3 @@
1
1
  module RubymotionGenerators
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -6,12 +6,10 @@ module RubymotionGenerators
6
6
  include Thor::Actions
7
7
 
8
8
  desc "generate", "Generate a new file of the specified type"
9
- #desc "generate_table_view_controller", "Generate a new class which inherits from UITableViewController"
10
9
 
11
10
  def generate(*args)
12
11
  # unsure why this flatten step is needed
13
12
  args = args.flatten
14
- puts args.inspect
15
13
  template_name = args[0]
16
14
  name = args[1]
17
15
  unless name
@@ -19,14 +17,18 @@ module RubymotionGenerators
19
17
  exit 1
20
18
  end
21
19
  case template_name
22
- when 'v'
20
+ when 'view'
23
21
  generate_view name
24
- when 'tvc'
25
- generate_table_view_controller name
26
22
  when 'vc'
27
23
  generate_view_controller name
28
- when 'tvcell'
24
+ when 'tvc'
25
+ generate_table_view_controller name
26
+ when 'cell'
29
27
  generate_table_view_cell
28
+ when 'tbapp'
29
+ generate_tab_bar_app_delegate name
30
+ generate_view_controller 'first'
31
+ generate_view_controller 'second'
30
32
  else
31
33
  puts "Invalid template name '#{template_name}'"
32
34
  exit 1
@@ -36,33 +38,38 @@ module RubymotionGenerators
36
38
  private
37
39
 
38
40
  def generate_view(name)
39
- output_path = "#{name}_view.rb"
41
+ output_path = "app/views/#{name}_view.rb"
40
42
  template('templates/view.rb', output_path)
41
43
  class_name = name.capitalize + "View"
42
44
  insert_into_file(output_path, class_name, :after => 'class ')
43
45
  end
44
46
 
45
47
  def generate_table_view_controller(name)
46
- output_path = "#{name}_table_view_controller.rb"
48
+ output_path = "app/controllers/#{name}_table_view_controller.rb"
47
49
  template('templates/table_view_controller.rb', output_path)
48
50
  class_name = name.capitalize + "TableViewController"
49
51
  insert_into_file(output_path, class_name, :after => 'class ')
50
52
  end
51
53
 
52
54
  def generate_view_controller(name)
53
- output_path = "#{name}_view_controller.rb"
55
+ output_path = "app/controllers/#{name}_view_controller.rb"
54
56
  template('templates/view_controller.rb', output_path)
55
57
  class_name = name.capitalize + "ViewController"
56
58
  insert_into_file(output_path, class_name, :after => 'class ')
57
59
  end
58
60
 
59
61
  def generate_table_view_cell(name)
60
- output_path = "#{name}_table_view_cell.rb"
62
+ output_path = "app/views/cells/#{name}_table_view_cell.rb"
61
63
  template('templates/table_view_cell.rb', output_path)
62
64
  class_name = name.capitalize + "TableViewCell"
63
65
  insert_into_file(output_path, class_name, :after => 'class ')
64
66
  end
65
67
 
68
+ def generate_tab_bar_app_delegate(name)
69
+ output_path = "app/app_delegate.rb"
70
+ template('templates/tab_bar_app_delegate.rb', output_path)
71
+ end
72
+
66
73
  def self.source_root
67
74
  File.dirname(__FILE__)
68
75
  end
@@ -0,0 +1,55 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
+ tabbar = UITabBarController.alloc.init
5
+ first_view_controller = FirstViewController.alloc.init
6
+ second_view_controller = SecondViewController.alloc.init
7
+ tabbar.viewControllers = [first_view_controller, second_view_controller]
8
+ tabbar.title = NSBundle.mainBundle.infoDictionary["CFBundleName"]
9
+ @window.rootViewController = UINavigationController.alloc.initWithRootViewController(tabbar)
10
+ @window.makeKeyAndVisible
11
+ true
12
+ end
13
+
14
+ def applicationWillResignActive(application)
15
+ # Sent when the application is about to move from active to inactive state. This can occur for certain types of
16
+ # temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application
17
+ # and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and
18
+ # throttle down OpenGL ES frame rates. Games should use this method to pause the game.
19
+ end
20
+
21
+ def applicationDidEnterBackground(application)
22
+ # Use this method to release shared resources, save user data, invalidate timers, and store enough application
23
+ # state information to restore your application to its current state in case it is terminated later.If your
24
+ # application supports background execution, this method is called instead of applicationWillTerminate: when the
25
+ # user quits.
26
+ end
27
+
28
+ def applicationWillEnterForeground(application)
29
+ # Called as part of the transition from the background to the inactive state; here you can undo many of the
30
+ # changes made on entering the background.
31
+ end
32
+
33
+ def applicationDidBecomeActive(application)
34
+ # Restart any tasks that were paused (or not yet started) while the application was inactive. If the application
35
+ # was previously in the background, optionally refresh the user interface.
36
+ end
37
+
38
+ def applicationWillTerminate(application)
39
+ # Called when the application is about to terminate. Save data if appropriate. See also
40
+ # applicationDidEnterBackground
41
+ end
42
+
43
+ =begin
44
+ # Optional UITabBarControllerDelegate method.
45
+ def tabBarController(tabBarController, didSelectViewController:viewController)
46
+ end
47
+ =end
48
+
49
+ =begin
50
+ # Optional UITabBarControllerDelegate method.
51
+ def tabBarController(tabBarController, didEndCustomizingViewControllers:viewControllers, changed:changed)
52
+ end
53
+ =end
54
+ end
55
+
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "rubymotion_generators"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = RubymotionGenerators::VERSION
17
- gem.executables = ["rmgen"]
17
+ gem.executables = ["motion_g"]
18
18
 
19
19
  gem.add_dependency('thor', '~> 0.15')
20
20
  gem.add_development_dependency('aruba', '~> 0.4')
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -47,7 +47,7 @@ description: RubyMotion generators
47
47
  email:
48
48
  - github.aw@andywaite.com
49
49
  executables:
50
- - rmgen
50
+ - motion_g
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
@@ -59,13 +59,13 @@ files:
59
59
  - Rakefile
60
60
  - lib/rubymotion_generators.rb
61
61
  - lib/rubymotion_generators/version.rb
62
- - lib/templates/tabbed_app_delegate.rb
62
+ - lib/templates/tab_bar_app_delegate.rb
63
63
  - lib/templates/table_view_cell.rb
64
64
  - lib/templates/table_view_controller.rb
65
65
  - lib/templates/view.rb
66
66
  - lib/templates/view_controller.rb
67
67
  - rubymotion_generators.gemspec
68
- - bin/rmgen
68
+ - bin/motion_g
69
69
  homepage: https://github.com/andyw8/rubymotion_generators
70
70
  licenses: []
71
71
  post_install_message:
@@ -1,66 +0,0 @@
1
- class AppDelegate
2
- def application(application, didFinishLaunchingWithOptions:launchOptions)
3
- self.window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
- # Override point for customization after application launch.
5
- nibs = nil
6
- if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
7
- nibs = ["FirstViewController_iPhone", "SecondViewController_iPhone"]
8
- else
9
- nibs = ["FirstViewController_iPad", "SecondViewController_iPad"]
10
- end
11
- viewController1 = FirstViewController.alloc.initWithNibName(nibs[0], bundle:nil)
12
- viewController2 = SecondViewController.alloc.initWithNibName(nibs[1], bundle:nil)
13
- self.tabBarController = UITabBarController.alloc.init
14
- self.tabBarController.viewControllers = [viewController1, viewController2]
15
- self.window.rootViewController = self.tabBarController
16
- self.window.makeKeyAndVisible
17
- true
18
- end
19
-
20
- def applicationWillResignActive(application)
21
- # Sent when the application is about to move from active to inactive state.
22
- # This can occur for certain types of temporary interruptions (such as an
23
- # incoming phone call or SMS message) or when the user quits the application
24
- # and it begins the transition to the background state.
25
- # Use this method to pause ongoing tasks, disable timers, and throttle down
26
- # OpenGL ES frame rates. Games should use this method to pause the game.
27
- end
28
-
29
- def applicationDidEnterBackground(application)
30
- # Use this method to release shared resources, save user data, invalidate
31
- # timers, and store enough application state information to restore your
32
- # application to its current state in case it is terminated later.
33
- # If your application supports background execution, this method is called
34
- # instead of applicationWillTerminate: when the user quits.
35
- end
36
-
37
- def applicationWillEnterForeground(application)
38
- # Called as part of the transition from the background to the inactive
39
- # state; here you can undo many of the changes made on entering the
40
- # background.
41
- end
42
-
43
- def applicationDidBecomeActive(application)
44
- # Restart any tasks that were paused (or not yet started) while the
45
- # application was inactive. If the application was previously in the
46
- # background, optionally refresh the user interface.
47
- end
48
-
49
- def applicationWillTerminate(application)
50
- # Called when the application is about to terminate. Save data if
51
- # appropriate. See also applicationDidEnterBackground:.
52
- end
53
-
54
- =begin
55
- # Optional UITabBarControllerDelegate method.
56
- def tabBarController(tabBarController, didSelectViewController:viewController)
57
- end
58
- =end
59
-
60
- =begin
61
- # Optional UITabBarControllerDelegate method.
62
- def tabBarController(tabBarController, didEndCustomizingViewControllers:viewControllers, changed:changed)
63
- end
64
- =end
65
- end
66
-