Skip to content

Commit

Permalink
Merge pull request #457 from clearsightstudio/pm2
Browse files Browse the repository at this point in the history
ProMotion 2.0 Prelim Pull Request
  • Loading branch information
jamonholmgren committed Jun 22, 2014
2 parents 1ba8cac + d52ed6a commit 90be7d4
Show file tree
Hide file tree
Showing 98 changed files with 1,182 additions and 2,071 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ tmp
*.tmproject
tmtags
*.sublime-workspace

lib/ProMotion/delegate/delegate_module.rb
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
language: objective-c
before_install:
- (ruby --version)
- sudo chown -R travis ~/Library/RubyMotion
- mkdir -p ~/Library/RubyMotion/build
- sudo motion update
gemfile:
- Gemfile
script: bundle exec rake spec
script:
- bundle install
- bundle exec rake clean
- bundle exec rake spec
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Over 20 developers have contributed to ProMotion. We love it when ProMotion users become ProMotion contributors.
Over 30 developers have contributed to ProMotion. We love it when ProMotion users become ProMotion contributors.

## Working on New Features

Expand All @@ -13,8 +13,8 @@ Over 20 developers have contributed to ProMotion. We love it when ProMotion user
1. Fork the project
2. Create a feature branch
3. Code
4. Update or create new specs ** NOTE: your PR is far more likely to be merged if you include comprehensive tests! **
5. Make sure tests are passing by running `rake spec` *(you can run functional and unit specs separately with `rake spec:func` and `rake spec:unit`, and a single spec with `rake spec:single f=test_file_name`)*
6. Submit pull request to `edge` (for new features) or `master` (for bugfixes)
4. Update or create new specs **NOTE: your PR is far more likely to be merged if you include comprehensive tests!**
5. Make sure tests are passing by running `rake spec`
6. Submit pull request to `master`
7. Make a million little nitpicky changes that @jamonholmgren wants
8. Merged, then fame, adoration, kudos everywhere
3 changes: 0 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
source 'https://rubygems.org'

gem 'motion-require'
# Specify your gem's dependencies in ProMotion.gemspec
gemspec
13 changes: 5 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
PATH
remote: .
specs:
ProMotion (1.2.0)
methadone (~> 1.3)
motion-require (~> 0.2)
ProMotion (2.0.0)
methadone (~> 1.4)

GEM
remote: https://rubygems.org/
specs:
methadone (1.3.2)
methadone (1.4.0)
bundler
motion-redgreen (0.1.0)
motion-require (0.2.0)
motion-stump (0.3.2)
rake (10.1.1)
rake (10.3.2)
webstub (1.0.1)

PLATFORMS
Expand All @@ -22,7 +20,6 @@ PLATFORMS
DEPENDENCIES
ProMotion!
motion-redgreen (~> 0.1)
motion-require
motion-stump (~> 0.3)
rake (~> 10.1)
rake (>= 10.0)
webstub (~> 1.0)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Jamon Holmgren
Copyright (c) 2012-2014 Jamon Holmgren

MIT License

Expand Down
32 changes: 17 additions & 15 deletions ProMotion.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
require File.expand_path('../lib/ProMotion/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["Jamon Holmgren", "Silas Matson", "Mark Rickert"]
gem.email = ["jamon@clearsightstudio.com", "silas@clearsightstudio.com", "mark@mohawkapps.com"]
gem.summary = "ProMotion makes it easy to build RubyMotion iOS screen-based apps."
gem.description = "
ProMotion is a RubyMotion gem that makes iOS development more like Ruby and less like Objective-C.
It introduces a clean, Ruby-style syntax for building screens that is easy to learn and remember and
abstracts a ton of boilerplate UIViewController, UINavigationController, and other iOS code into a
simple, Ruby-like DSL.
gem.name = "ProMotion"
gem.authors = ["Jamon Holmgren", "Mark Rickert", "Silas Matson"]
gem.email = ["jamon@clearsightstudio.com", "mark@mohawkapps.com", "silas@clearsightstudio.com"]
gem.description = "ProMotion is a fast way to get started building RubyMotion iOS apps."
gem.summary = "
ProMotion is a fast way to get started building RubyMotion apps. Instead of dealing
with UIViewControllers, UITableViewControllers, and the like, you work with Screens.
We abstract the view controller boilerplate to make iOS development more like Ruby
and less like Objective-C. With a memorable, concise syntax and a friendly, helpful
community, ProMotion is a great way to get started with iOS development.
"
gem.homepage = "https://github.com/clearsightstudio/ProMotion"
gem.license = 'MIT'
gem.license = "MIT"

gem.files = Dir.glob("lib/**/*.rb")
gem.files << "README.md"

gem.files = `git ls-files`.split($\)
gem.executables << "promotion"
gem.test_files = gem.files.grep(%r{^(spec)/})
gem.name = "ProMotion"
gem.test_files = Dir.glob("spec/**/*.rb")
gem.require_paths = ["lib"]
gem.version = ProMotion::VERSION

gem.add_dependency "motion-require", "~> 0.2"
gem.add_runtime_dependency("methadone", "~> 1.3")
gem.add_runtime_dependency("methadone", "~> 1.4")
gem.add_development_dependency("webstub", "~> 1.0")
gem.add_development_dependency("motion-stump", "~> 0.3")
gem.add_development_dependency("motion-redgreen", "~> 0.1")
gem.add_development_dependency("rake", "~> 10.1")
gem.add_development_dependency("rake", ">= 10.0")
end
46 changes: 36 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ It introduces a clean, Ruby-style syntax for building screens that is easy to le
abstracts a ton of boilerplate UIViewController, UINavigationController, and other iOS code into a
simple, Ruby-like DSL.

Watch the [September Motion Meetup](http://www.youtube.com/watch?v=rf7h-3AiMRQ) where Gant Laborde
* Watch Jamon Holmgren give a talk about ProMotion at [RubyMotion #inspect2014](http://confreaks.com/videos/3813-inspect-going-pro-with-promotion-from-prototype-to-production) (video)
* Watch the [September 2013 Motion Meetup](http://www.youtube.com/watch?v=rf7h-3AiMRQ) where Gant Laborde
interviews Jamon Holmgren about ProMotion!

```ruby
# app/app_delegate.rb
class AppDelegate < PM::Delegate
status_bar true, animation: :fade

def on_load(app, options)
open RootScreen.new(nav_bar: true)
end
Expand Down Expand Up @@ -78,16 +81,39 @@ end
2. Watch the excellent [MotionInMotion screencast about ProMotion](https://motioninmotion.tv/screencasts/8) (very reasonably priced subscription required)
3. Follow a tutorial: [Building an ESPN app using RubyMotion, ProMotion, and TDD](http://jamonholmgren.com/building-an-espn-app-using-rubymotion-promotion-and-tdd)

# What's New?
# Changelog

## Version 2.0.0

Overview: In ProMotion 2.0, we removed deprecated APIs, refactored and cleaned up a ton of code, pulled `PushNotification` and `MapScreen` into their own gems, and simplified the API. It now builds 55% faster and is 20%+ lighter.

**API changes**

1. Extracted `PM::MapScreen` into [ProMotion-map](https://github.com/clearsightstudio/ProMotion-map)
2. Extracted `PM::PushNotification` into [ProMotion-push](https://github.com/clearsightstudio/ProMotion-push)
3. You can't pass a UIImage or UIView into a `title` anymore. Instead, pass a string into `title_image` (it'll fetch the image for you and create a UIImageView) or pass any arbitrary view into `title_view`. Now, `title` only takes a string title.
4. `on_create` has been renamed `screen_init` to avoid confusion with Android's `onCreate` method. It may be reintroduced in a future version of ProMotion as an alias of `onCreate`. We recommend using `on_init` instead.
5. `set_nav_bar_right_button` and `set_nav_bar_left_button` have been removed. Use `set_nav_bar_button :right` and `:left` instead.
6. Added `NSString#to_url` and `NSURL#to_url` helper methods to help clean up a lot of code.
7. `present_modal_view_controller` now takes two arguments: the ViewController and an argument hash. You shouldn't have been using it in the first place.
8. `open_in_tab` now properly opens screens in tabs that didn't have a nav_bar. This is probably the closest thing to a new feature in PM 2.0 that we have, even though it should have worked before.
9. Cell hash arbitrary values are no longer applied directly to the cell. Instead, use the style: hash to apply arbitrary attributes. [Example here](https://github.com/clearsightstudio/ProMotion/pull/457/files#discussion_r13211807).
10. Removed cell hash `:subviews` attribute. Instead, subclass `PM::TableViewCell` and add your own subviews there.
11. Actually, there is one new feature. It's called `longpressable`. By adding `longpressable` at the top of your `PM::TableScreen` and then supplying a `long_press_action:` in your cell hash, you can implement a different action for long presses on table cells.
12. We no longer insert the cell hash into the arguments hash passed into your cell tap action. If you need that data, pass it in manually.
13. Removed `add_element`, `add_view`, `remove_element`, `remove_view` aliases for `add` and `remove`.
14. `on_load` now fires on `viewDidLoad` instead of `loadView`. Added a new `load_view` hook for that method & you can set your own view in there. If you don't implement `load_view`, one will be created for you (per Apple's recommendations). This change shouldn't change much in your app except that if you're setting `self.view = something`, you should do it in `load_view`.

## Version 1.2.x
**Internal changes:**

1. Now uses [motion-require](https://github.com/clayallsopp/motion-require) for better compatibility with other libraries [6046dd7f4](https://github.com/clearsightstudio/ProMotion/commit/6046dd7f49ba174f309baaa428eaac80ce0290b6)
2. SplitScreen: New option `swipe:` allows you to specify if a splitscreen master screen can be opened with a swipe. [ffbb76caf](https://github.com/clearsightstudio/ProMotion/commit/ffbb76caf3071297347d4cf43784069999a746b3)
3. FormotionScreen: Removed `PM::FormotionScreen` and the Formotion testing dependency. Use [ProMotion-formotion](https://github.com/rheoli/ProMotion-formotion) instead.
4. Styling: Added a `content_width` helper to PM::Styling (similar to `content_height`) [08a984815](https://github.com/clearsightstudio/ProMotion/commit/08a984815a7c96b9465c31b2e2664ac0086d2e1c)
5. TableScreen: Removed SDWebImage in favor of similar but more reliable JDImageCache [59ed747e9](https://github.com/clearsightstudio/ProMotion/commit/59ed747e93567e32bdb5099fed12297161cea05a)
6. Screen: Allow custom views (including images) for `title` setting [#415](https://github.com/clearsightstudio/ProMotion/pull/415)
1. Removed `motion-require`. ProMotion now relies entirely on RubyMotion's built-in dependency detector.
2. Removed `rake spec:unit`, `rake spec:func`, `rake spec:single filename`. We don't really use these for development anymore.
3. Moved many files around into a more logical, simpler structure.
4. Removed `PM::Conversions`. The only helper we were using was the `objective_c_method_name` method, and that was only used in `PM::Styling`. So we moved it there.
5. New module, `PM::NavBarModule`. Moved any navigation controller methods into this module, cleaning up the `PM::ScreenModule` quite a bit.
6. Lots of code refactoring -- CodeClimate went from 2.47 to 3.42 GPA.
7. Much cleaner `open` code!
8. Converted several *slow* functional tests into *fast* unit tests with the same coverage.

# API Reference

Expand All @@ -97,7 +123,7 @@ We've created a comprehensive and always updated wiki with code examples, usage

# Help

ProMotion is not only an easy DSL to get started. The community is very helpful and
ProMotion is not only an easy DSL to get started. The community is very helpful and
welcoming to new RubyMotion developers. We don't mind newbie questions.

If you need help, feel free to tweet [@jamonholmgren](http://twitter.com/jamonholmgren)
Expand Down
55 changes: 5 additions & 50 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,66 +1,21 @@
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require 'bundler'
Bundler.require(:development)
require 'ProMotion'

Motion::Project::App.setup do |app|
app.name = 'ProMotionTest'
app.version = "0.99.0"
app.redgreen_style = :full # :focused, :full
app.frameworks += %w(CoreLocation MapKit)

# Devices
app.deployment_target = "6.0"
app.device_family = [:ipad] # so we can test split screen capability
end

def all_files
App.config.spec_files
end

def functional_files
Dir.glob('./spec/functional/**/*.rb')
end

def unit_files
Dir.glob('./spec/unit/**/*.rb')
app.name = 'ProMotion'
app.device_family = [ :ipad ] # so we can test split screen capability
app.detect_dependencies = true
end

namespace :spec do
task :unit do
App.config.spec_mode = true
spec_files = all_files
spec_files -= functional_files
spec_files = App.config.spec_files - Dir.glob('./spec/functional/**/*.rb')
App.config.instance_variable_set("@spec_files", spec_files)
Rake::Task["simulator"].invoke
end

task :func do
Rake::Task["spec:functional"].invoke
end

task :functional do
App.config.spec_mode = true
spec_files = all_files
spec_files -= unit_files
App.config.instance_variable_set("@spec_files", spec_files)
Rake::Task["simulator"].invoke
end

task :single do
App.config.spec_mode = true
spec_files = App.config.spec_files
spec_files -= unit_files
spec_files -= functional_files
spec_files += Dir.glob("./spec/unit/**/#{ENV['f'] || ENV['file']}.rb")
spec_files += Dir.glob("./spec/functional/**/#{ENV['f'] || ENV['file']}.rb")
App.config.instance_variable_set("@spec_files", spec_files)
Rake::Task["simulator"].invoke
end

end

task :sim_close do
sh "osascript -e 'tell application \"iphone simulator\" to quit'"
end
2 changes: 1 addition & 1 deletion app/app_delegate.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AppDelegate
class AppDelegate < ProMotion::Delegate

def on_load(app, options)
open BasicScreen.new(nav_bar: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BasicScreen < PM::Screen
def will_appear
@will_appear_ts = NSDate.date
end

def on_appear
@on_appear_ts = NSDate.date
@animation_ts = @on_appear_ts - @will_appear_ts
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions app/test_screens/home_screen.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class HomeScreen < ProMotion::Screen

title "Home"

def on_load
set_nav_bar_button :left, title: "Save", action: :save_something, type: :done
set_nav_bar_button :right, image: UIImage.imageNamed("list.png"), action: :return_to_some_other_screen, type: :plain
end

def on_return(args={})
end

def subview_styles
{
background_color: UIColor.greenColor
}
end

end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ImageTitleScreen < PM::Screen
attr_accessor :button_was_triggered

title UIImage.imageNamed('test.png')
title_image 'test.png'

def will_appear
self.button_was_triggered = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
class ImageViewTitleScreen < PM::Screen
attr_accessor :button_was_triggered

title UIImageView.alloc.initWithImage(UIImage.imageNamed('test.png'))
title_view UIImageView.alloc.initWithImage(UIImage.imageNamed('test.png'))

def will_appear
self.button_was_triggered = false
add UILabel.alloc.initWithFrame([[ 10, 10 ], [ 300, 40 ]]),
text: "Label Here"
add UILabel.alloc.initWithFrame([[ 10, 10 ], [ 300, 40 ]]), { text: "Label Here" }
end

def triggered_button
Expand Down
27 changes: 27 additions & 0 deletions app/test_screens/load_view_screen.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class MyView < UIView; end

class LoadViewScreen < PM::Screen
def load_view
self.view = MyView.new
end

def on_load
self.view.backgroundColor = UIColor.redColor
end
end

class MyTableView < UITableView; end

class LoadViewTableScreen < PM::Screen
def load_view
self.view = MyTableView.new
end

def on_load
self.view.backgroundColor = UIColor.greenColor
end

def table_data
[]
end
end
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ class ScreenModuleViewController < UIViewController
include PM::ScreenModule
title 'Test Title'

# Get rid of such hackiness when RubyMotion bug is fixed...

def self.new(args = {})
s = self.alloc.initWithNibName(nil, bundle:nil)
s.on_create(args) if s.respond_to?(:on_create)
s.screen_init(args) if s.respond_to?(:screen_init)
s
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TabScreen < PM::Screen
title "Tab"
tab_bar_item title: "Tab Item", icon: "list"
tab_bar_item title: "Tab Item", item: "list"
end
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 90be7d4

Please sign in to comment.