rubymotion_generators 0.0.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 ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ lib/templates/xcode_originals
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubymotion_generators.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubymotion_generators (0.0.1)
5
+ thor (~> 0.15)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.4.11)
11
+ childprocess (>= 0.2.3)
12
+ cucumber (>= 1.1.1)
13
+ ffi (>= 1.0.11)
14
+ rspec (>= 2.7.0)
15
+ builder (3.0.0)
16
+ childprocess (0.3.2)
17
+ ffi (~> 1.0.6)
18
+ cucumber (1.2.0)
19
+ builder (>= 2.1.2)
20
+ diff-lcs (>= 1.1.3)
21
+ gherkin (~> 2.10.0)
22
+ json (>= 1.4.6)
23
+ diff-lcs (1.1.3)
24
+ ffi (1.0.11)
25
+ gherkin (2.10.0)
26
+ json (>= 1.4.6)
27
+ json (1.7.3)
28
+ rspec (2.10.0)
29
+ rspec-core (~> 2.10.0)
30
+ rspec-expectations (~> 2.10.0)
31
+ rspec-mocks (~> 2.10.0)
32
+ rspec-core (2.10.1)
33
+ rspec-expectations (2.10.0)
34
+ diff-lcs (~> 1.1.3)
35
+ rspec-mocks (2.10.1)
36
+ thor (0.15.2)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ aruba (~> 0.4)
43
+ rubymotion_generators!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Andy Waite
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # RubyMotion Generators
2
+
3
+ This project aims to provide boilerplate code templates for RubyMotion, similar to those which can be generated by Xcode.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubymotion_generators'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubymotion_generators
18
+
19
+ ## Usage
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
25
+
26
+ ## ToDo
27
+
28
+ - AppDelegate (TabBar, etc.)
29
+ - iPad option
30
+ - Tests
31
+ - Ability to specify file path
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/rmgen ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'rubymotion_generators'
4
+
5
+ RubymotionGenerators::Core.new.generate(ARGV)
@@ -0,0 +1,3 @@
1
+ module RubymotionGenerators
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,70 @@
1
+ require "rubymotion_generators/version"
2
+ require 'thor'
3
+
4
+ module RubymotionGenerators
5
+ class Core < Thor
6
+ include Thor::Actions
7
+
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
+
11
+ def generate(*args)
12
+ # unsure why this flatten step is needed
13
+ args = args.flatten
14
+ puts args.inspect
15
+ template_name = args[0]
16
+ name = args[1]
17
+ unless name
18
+ puts "Missing name parameter"
19
+ exit 1
20
+ end
21
+ case template_name
22
+ when 'v'
23
+ generate_view name
24
+ when 'tvc'
25
+ generate_table_view_controller name
26
+ when 'vc'
27
+ generate_view_controller name
28
+ when 'tvcell'
29
+ generate_table_view_cell
30
+ else
31
+ puts "Invalid template name '#{template_name}'"
32
+ exit 1
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def generate_view(name)
39
+ output_path = "#{name}_view.rb"
40
+ template('templates/view.rb', output_path)
41
+ class_name = name.capitalize + "View"
42
+ insert_into_file(output_path, class_name, :after => 'class ')
43
+ end
44
+
45
+ def generate_table_view_controller(name)
46
+ output_path = "#{name}_table_view_controller.rb"
47
+ template('templates/table_view_controller.rb', output_path)
48
+ class_name = name.capitalize + "TableViewController"
49
+ insert_into_file(output_path, class_name, :after => 'class ')
50
+ end
51
+
52
+ def generate_view_controller(name)
53
+ output_path = "#{name}_view_controller.rb"
54
+ template('templates/view_controller.rb', output_path)
55
+ class_name = name.capitalize + "ViewController"
56
+ insert_into_file(output_path, class_name, :after => 'class ')
57
+ end
58
+
59
+ def generate_table_view_cell(name)
60
+ output_path = "#{name}_table_view_cell.rb"
61
+ template('templates/table_view_cell.rb', output_path)
62
+ class_name = name.capitalize + "TableViewCell"
63
+ insert_into_file(output_path, class_name, :after => 'class ')
64
+ end
65
+
66
+ def self.source_root
67
+ File.dirname(__FILE__)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,66 @@
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
+
@@ -0,0 +1,6 @@
1
+ class < UITableViewCell
2
+ def setSelected(selected animated:animated)
3
+ super
4
+ # Configure the view for the selected state
5
+ end
6
+ end
@@ -0,0 +1,87 @@
1
+ class < UITableViewController
2
+ def viewDidLoad
3
+ super
4
+ # Uncomment the following line to preserve selection between presentations.
5
+
6
+ # self.clearsSelectionOnViewWillAppear = false
7
+
8
+ # Uncomment the following line to display an Edit button in the navigation
9
+ # bar for this view controller.
10
+
11
+ # self.navigationItem.rightBarButtonItem = self.editButtonItem
12
+ end
13
+
14
+ def viewDidUnload
15
+ super
16
+
17
+ # Release any retained subviews of the main view.
18
+ # e.g. self.myOutlet = nil
19
+ end
20
+
21
+ def shouldAutorotateToInterfaceOrientation(interfaceOrientation)
22
+ interfaceOrientation == UIInterfaceOrientationPortrait
23
+ end
24
+
25
+ ## Table view data source
26
+
27
+ def numberOfSectionsInTableView(tableView)
28
+ # Return the number of sections.
29
+ 0
30
+ end
31
+
32
+ def tableView(tableView, numberOfRowsInSection:section)
33
+ # Return the number of rows in the section.
34
+ 0
35
+ end
36
+
37
+ def tableView(tableView, cellForRowAtIndexPath:indexPath)
38
+ CellIdentifier = "Cell"
39
+ cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier)
40
+ # Configure the cell...
41
+ cell
42
+ end
43
+
44
+ =begin
45
+ # Override to support conditional editing of the table view.
46
+ def tableView(tableView, canEditRowAtIndexPath:indexPath)
47
+ # Return false if you do not want the specified item to be editable.
48
+ true
49
+ end
50
+ =end
51
+
52
+ =begin
53
+ # Override to support editing the table view.
54
+ def tableView(tableView, commitEditingStyle:editingStyle forRowAtIndexPath:indexPath)
55
+ if editingStyle == UITableViewCellEditingStyleDelete
56
+ # Delete the row from the data source
57
+ tableView.deleteRowsAtIndexPaths(indexPath, withRowAnimation:UITableViewRowAnimationFade)
58
+ elsif editingStyle == UITableViewCellEditingStyleInsert
59
+ # Create a new instance of the appropriate class, insert it into the
60
+ # array, and add a new row to the table view
61
+ end
62
+ end
63
+ =end
64
+
65
+ =begin
66
+ # Override to support rearranging the table view.
67
+ def tableView(tableView, moveRowAtIndexPath:fromIndexPath, toIndexPath:toIndexPath)
68
+ end
69
+ =end
70
+
71
+ =begin
72
+ # Override to support conditional rearranging of the table view.
73
+ def tableView(tableView, canMoveRowAtIndexPath:indexPath)
74
+ # Return false if you do not want the item to be re-orderable.
75
+ true
76
+ end
77
+ =end
78
+
79
+ ## Table view delegate
80
+
81
+ def tableView(tableView, didSelectRowAtIndexPath:indexPath)
82
+ # Navigation logic may go here. Create and push another view controller.
83
+ # detailViewController = DetailViewController.alloc.initWithNibName("Nib name", bundle:nil)
84
+ # Pass the selected object to the new view controller.
85
+ # self.navigationController.pushViewController(detailViewController, animated:true)
86
+ end
87
+ end
@@ -0,0 +1,9 @@
1
+ class < UIView
2
+ =begin
3
+ # Only override drawRect if you perform custom drawing.
4
+ # An empty implementation adversely affects performance during animation.
5
+ def drawRect(rect)
6
+ # Drawing code
7
+ end
8
+ =end
9
+ end
@@ -0,0 +1,15 @@
1
+ class < UIViewController
2
+ def viewDidLoad
3
+ super
4
+ # Do any additional setup after loading the view.
5
+ end
6
+
7
+ def viewDidUnload
8
+ super
9
+ # Release any retained subviews of the main view.
10
+ end
11
+
12
+ def shouldAutorotateToInterfaceOrientation(interfaceOrientation)
13
+ interfaceOrientation == UIInterfaceOrientationPortrait
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rubymotion_generators/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Andy Waite"]
6
+ gem.email = ["github.aw@andywaite.com"]
7
+ gem.description = "RubyMotion generators"
8
+ gem.summary = "RubyMotion generators"
9
+ gem.homepage = "https://github.com/andyw8/rubymotion_generators"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "rubymotion_generators"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = RubymotionGenerators::VERSION
17
+ gem.executables = ["rmgen"]
18
+
19
+ gem.add_dependency('thor', '~> 0.15')
20
+ gem.add_development_dependency('aruba', '~> 0.4')
21
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubymotion_generators
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andy Waite
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.15'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.15'
30
+ - !ruby/object:Gem::Dependency
31
+ name: aruba
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.4'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.4'
46
+ description: RubyMotion generators
47
+ email:
48
+ - github.aw@andywaite.com
49
+ executables:
50
+ - rmgen
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/rubymotion_generators.rb
61
+ - lib/rubymotion_generators/version.rb
62
+ - lib/templates/tabbed_app_delegate.rb
63
+ - lib/templates/table_view_cell.rb
64
+ - lib/templates/table_view_controller.rb
65
+ - lib/templates/view.rb
66
+ - lib/templates/view_controller.rb
67
+ - rubymotion_generators.gemspec
68
+ - bin/rmgen
69
+ homepage: https://github.com/andyw8/rubymotion_generators
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.24
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: RubyMotion generators
93
+ test_files: []