Skip to content

Commit

Permalink
Initial commt.
Browse files Browse the repository at this point in the history
  • Loading branch information
markrickert committed Dec 6, 2013
0 parents commit c289e85
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
.repl_history
build
tags
app/pixate_code.rb
resources/*.nib
resources/*.momd
resources/*.storyboardc
.DS_Store
nbproject
.redcar
#*#
*~
*.sw[po]
*.gem
.eprj
.sass-cache
.idea
3 changes: 3 additions & 0 deletions Gemfile
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gemspec
7 changes: 7 additions & 0 deletions LICENSE
@@ -0,0 +1,7 @@
Copyright (c) 2013 Mohawk Apps, LLC (Mark Rickert - mark@mohawkapps.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 changes: 42 additions & 0 deletions README.md
@@ -0,0 +1,42 @@
# motion-takeoff

A RubyMotion specific iOS gem that helps you do things at launch.

Currently, there is only one module in this gem: `Messages`. The `Messages` module will allow you to schedule alerts to users at certain launch counts. More modules are planned for the future.

This gem is in its infancy. Please help me make it better!

## Installation

Add this line to your application's Gemfile:

gem 'motion-takeoff'

And run: `bundle`

## Usage: Messages Module

Open your app delegate and in your `applicationDidBecomeActive:` method do something like this:

```ruby
def applicationDidBecomeActive(application)
messages = MotionTakeoff::Messages.new
messages.message launch:1, title:"Welcome to #{App.name}!", message:"Thanks for checking it out!"
messages.message launch:3, title:"Quick Tip:", message:"This is the 3rd time you've launched this application!"
messages.message launch:500, title:"Quick Tip:", message:"This is the 500th time you've launched this application!"
messages.takeoff
end
```
This will display an alert to the user on the 1st, 3rd, and 500th launches of the app.

## Future plans

I'd like it to be able to be a multi-purpose tool for doing things at launch other than just alerting users. Things like asking for ratings in the iTunes store and scheduling other activities likes clearing caches on the 10th load or checking a server every load, etc.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
17 changes: 17 additions & 0 deletions Rakefile
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require './lib/motion-takeoff'

begin
require 'bundler'
require 'motion/project/template/gem/gem_tasks'
Bundler.require
require "bubble-wrap/core"
rescue LoadError
end

Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'motion-takeoff'
end
5 changes: 5 additions & 0 deletions app/app_delegate.rb
@@ -0,0 +1,5 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
true
end
end
13 changes: 13 additions & 0 deletions lib/motion-takeoff.rb
@@ -0,0 +1,13 @@
unless defined?(Motion::Project::Config)
raise "This file must be required within a RubyMotion project Rakefile."
end

require "bubble-wrap/core"

module MotionTakeoff
end

lib_dir_path = File.dirname(File.expand_path(__FILE__))
Motion::Project::App.setup do |app|
app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
end
33 changes: 33 additions & 0 deletions lib/project/messages.rb
@@ -0,0 +1,33 @@
module MotionTakeoff
class Messages

def initialize
@messages = []
@launch_key = 'motion_takeoff_launch_count'
handle_launch
end

def message(opts={})
@messages << opts
end

def takeoff
@messages.each do |message|
if message[:launch] == App::Persistence[@launch_key]
App.alert(message[:title], message:message[:message])
end
end
end

private
def handle_launch
if App::Persistence[@launch_key].nil?
App::Persistence[@launch_key] = 1
else
App::Persistence[@launch_key] = App::Persistence[@launch_key] + 1
end
end

end
end

3 changes: 3 additions & 0 deletions lib/project/version.rb
@@ -0,0 +1,3 @@
module MotionTakeoff
VERSION = '0.0.1'
end
23 changes: 23 additions & 0 deletions motion-takeoff.gemspec
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/project/version', __FILE__)

Gem::Specification.new do |spec|
spec.name = "motion-takeoff"
spec.version = MotionTakeoff::VERSION
spec.authors = ["Mark Rickert"]
spec.email = ["mjar81@gmail.com"]
spec.description = %q{A RubyMotion specific iOS gem that helps you do things at launch.}
spec.summary = %q{A RubyMotion specific iOS gem that helps you do things at launch. You can use this gem to display messages at certain launch counts.}
spec.homepage = "https://www.github.com/MohawkApps/motion-takeoff"
spec.license = "MIT"

files = []
files << 'README.md'
files.concat(Dir.glob('lib/**/*.rb'))
spec.files = files
spec.test_files = spec.files.grep(%r{^(spec)/})
spec.require_paths = ["lib"]

spec.add_development_dependency "rake"
spec.add_runtime_dependency "bubble-wrap", ">1.0.0"
end
9 changes: 9 additions & 0 deletions spec/main_spec.rb
@@ -0,0 +1,9 @@
describe "Application 'motion-takeoff'" do
before do
@app = UIApplication.sharedApplication
end

it "has one window" do
@app.windows.size.should == 1
end
end

0 comments on commit c289e85

Please sign in to comment.