Permalink
Browse files

initial commit; with app generator

  • Loading branch information...
0 parents commit 68e784fa92009a6e5f37faff3c84a6bc21843c0e @drnic committed Jun 28, 2008
@@ -0,0 +1,3 @@
+.DS_Store
+pkg
+log
@@ -0,0 +1,4 @@
+== 0.0.1 2008-06-28
+
+* 1 major enhancement:
+ * Initial release
@@ -0,0 +1,20 @@
+Copyright (c) 2008 FIXME full name
+
+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.
@@ -0,0 +1,25 @@
+History.txt
+License.txt
+Manifest.txt
+PostInstall.txt
+README.rdoc
+Rakefile
+config/hoe.rb
+config/requirements.rb
+lib/iphoneruby.rb
+lib/iphoneruby/version.rb
+script/console
+script/destroy
+script/generate
+script/txt2html
+setup.rb
+tasks/deployment.rake
+tasks/environment.rake
+tasks/website.rake
+test/test_helper.rb
+test/test_iphoneruby.rb
+website/index.html
+website/index.txt
+website/javascripts/rounded_corners_lite.inc.js
+website/stylesheets/screen.css
+website/template.html.erb
@@ -0,0 +1,7 @@
+
+For more information on iphoneruby, see http://iphoneruby.rubyforge.org
+
+NOTE: Change this information in PostInstall.txt
+You can also delete it if you don't want it.
+
+
@@ -0,0 +1,48 @@
+= iphoneruby
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2008 FIXME full name
+
+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.
@@ -0,0 +1,4 @@
+require 'config/requirements'
+require 'config/hoe' # setup Hoe + all gem configuration
+
+Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,5 @@
+Description:
+
+
+Usage:
+
@@ -0,0 +1,68 @@
+class IphonerubyGenerator < RubiGen::Base
+
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
+ Config::CONFIG['ruby_install_name'])
+
+ default_options :author => nil
+
+ attr_reader :name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+ usage if args.empty?
+ @destination_root = File.expand_path(args.shift)
+ @name = base_name
+ extract_options
+ end
+
+ def manifest
+ record do |m|
+ # Ensure appropriate folder(s) exists
+ m.directory ''
+ BASEDIRS.each { |path| m.directory path }
+
+ # Create stubs
+ m.file_copy_each ["Rakefile"]
+ m.file "dot_autotest", ".autotest"
+ m.file_copy_each ["test/test_helper.rb"]
+
+ m.dependency "install_rubigen_scripts", [destination_root, 'iphoneruby'],
+ :shebang => options[:shebang], :collision => :force
+ end
+ end
+
+ protected
+ def banner
+ <<-EOS
+Want to write unit tests in Ruby? Run this generator
+in the root folder of your Xcode project for your iPhone app.
+
+USAGE: #{spec.name} name
+EOS
+ end
+
+ def add_options!(opts)
+ opts.separator ''
+ opts.separator 'Options:'
+ # For each option below, place the default
+ # at the top of the file next to "default_options"
+ # opts.on("-a", "--author=\"Your Name\"", String,
+ # "Some comment about this option",
+ # "Default: none") { |options[:author]| }
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
+ end
+
+ def extract_options
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
+ # Templates can access these value via the attr_reader-generated methods, but not the
+ # raw instance variable value.
+ # @author = options[:author]
+ end
+
+ # Installation skeleton. Intermediate directories are automatically
+ # created so don't sweat their absence here.
+ BASEDIRS = %w(
+ Classes
+ test
+ )
+end
@@ -0,0 +1,49 @@
+require "rubygems"
+require "rake"
+require "rake/testtask"
+
+task :default => :test
+
+Rake::TestTask.new do |t|
+ t.libs << "test" << "test/bundles"
+ t.test_files = FileList['test/test*.rb']
+ t.verbose = true
+end
+
+namespace :objc do
+ desc "Compiles all Objective-C bundles for testing"
+ task :compile
+end
+
+task :compile => "objc:compile"
+
+task :test => :compile
+
+namespace :objc do
+ # look for Classes/*.m files containing a line "void Init_ClassName"
+ # These are the primary classes for bundles; make a bundle for each
+ model_file_paths = `find Classes/*.m -exec grep -l "^void Init_" {} \\;`.split("\n")
+ model_file_paths.each do |path|
+ path =~ /Classes\/(.*)\.m/
+ model_name = $1
+
+ task :compile => model_name do
+ if Dir.glob("**/#{model_name}.bundle").length == 0
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ STDERR.puts "Bundle actually failed to build."
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ exit(1)
+ end
+ end
+
+ task model_name.to_sym => "build/bundles/#{model_name}.bundle"
+
+ file "build/bundles/#{model_name}.bundle" => "Classes/#{model_name}.m" do |t|
+ FileUtils.mkdir_p "build/bundles"
+ FileUtils.rm Dir["build/bundles/#{model_name}.bundle"]
+ sh "gcc -o build/bundles/#{model_name}.bundle -bundle -framework Foundation Classes/#{model_name}.m"
+ end
+ end
+
+end
+
@@ -0,0 +1,18 @@
+class String
+ def underscore
+ gsub(/::/, '/').
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
+ downcase
+ end
+end
+
+Autotest.add_hook :initialize do |at|
+ at.add_mapping(/Classes\/(.*)\.[mh]/) do |_, m|
+ ["test/test_#{m[1].underscore}.rb"]
+ end
+end
+
+Autotest.add_hook :run_command do |at|
+ system "rake compile"
+end
@@ -0,0 +1,8 @@
+require "test/unit"
+
+require "rubygems"
+require "Shoulda"
+
+require "osx/cocoa"
+
+$:.unshift File.dirname(__FILE__) + "/../build/bundles"
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'rubigen'
+
+if %w(-v --version).include? ARGV.first
+ require 'iphoneruby/version'
+ puts "#{File.basename($0)} #{Iphoneruby::VERSION::STRING}"
+ exit(0)
+end
+
+require 'rubigen/scripts/generate'
+source = RubiGen::PathSource.new(:application,
+ File.join(File.dirname(__FILE__), "../app_generators"))
+RubiGen::Base.reset_sources
+RubiGen::Base.append_sources source
+RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'iphoneruby')
@@ -0,0 +1,70 @@
+require 'iphoneruby/version'
+
+AUTHOR = 'Dr Nic Williams'
+EMAIL = "drnicwilliams@gmail.com"
+DESCRIPTION = "Provides a testing framework for iPhone Xcode projects, using RubyCocoa"
+GEM_NAME = 'iphoneruby' # what ppl will type to install your gem
+RUBYFORGE_PROJECT = 'iphoneruby' # The unix name for your project
+HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
+DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
+EXTRA_DEPENDENCIES = [
+# ['activesupport', '>= 1.3.1']
+] # An array of rubygem dependencies [name, version]
+
+@config_file = "~/.rubyforge/user-config.yml"
+@config = nil
+RUBYFORGE_USERNAME = "unknown"
+def rubyforge_username
+ unless @config
+ begin
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
+ rescue
+ puts <<-EOS
+ERROR: No rubyforge config file found: #{@config_file}
+Run 'rubyforge setup' to prepare your env for access to Rubyforge
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
+ EOS
+ exit
+ end
+ end
+ RUBYFORGE_USERNAME.replace @config["username"]
+end
+
+
+VERS = IPhoneRuby::VERSION::STRING
+RDOC_OPTS = ['--quiet', '--title', 'iphoneruby documentation',
+ "--opname", "index.html",
+ "--line-numbers",
+ "--main", "README",
+ "--inline-source"]
+
+class Hoe
+ def extra_deps
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
+ @extra_deps
+ end
+end
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.new(GEM_NAME, VERS) do |p|
+ p.developer(AUTHOR, EMAIL)
+ p.description = DESCRIPTION
+ p.summary = DESCRIPTION
+ p.url = HOMEPATH
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
+ p.test_globs = ["test/**/test_*.rb"]
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
+
+ # == Optional
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ #p.extra_deps = EXTRA_DEPENDENCIES
+
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
+ end
+
+CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
+PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
+$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
+$hoe.rsync_args = '-av --delete --ignore-errors'
+$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
+require 'fileutils'
+include FileUtils
+
+require 'rubygems'
+%w[rake hoe newgem rubigen].each do |req_gem|
+ begin
+ require req_gem
+ rescue LoadError
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
+ puts "Installation: gem install #{req_gem} -y"
+ exit
+ end
+end
+
+$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1,6 @@
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+module IPhoneRuby
+
+end
Oops, something went wrong.

0 comments on commit 68e784f

Please sign in to comment.