ruby_on_skis 0.0.0
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/README.textile +88 -0
- data/Rakefile +67 -0
- data/VERSION +1 -0
- data/bin/init.rb +18 -0
- data/bin/pinit.rb +27 -0
- data/config/environment.rb +189 -0
- data/config/gemconfigure.rb +24 -0
- data/config/requires.yml +15 -0
- data/data/lorem.txt +101 -0
- data/fixtures/messages.yml +7 -0
- data/images/ruby_on_skis.ico +0 -0
- data/lib/extensions/string/truncate.rb +16 -0
- data/lib/models/message.rb +11 -0
- data/lib/wx/app/app_frame.rb +56 -0
- data/lib/wx/app/message_panel.rb +98 -0
- data/lib/wx/app/taskbar_icon.rb +26 -0
- data/lib/wx/app.xrc +1 -0
- data/lib/wx/base/appframebase.rb +46 -0
- data/lib/wx/base/messagepanelbase.rb +45 -0
- data/lib/wx/helpers/app_helper.rb +86 -0
- data/migrate/20081128200300_init.rb +14 -0
- data/package/config.yml +29 -0
- data/package/installer.nsi +185 -0
- data/ruby_on_skis.fbp +742 -0
- data/script/console +11 -0
- data/spec/config/environment_spec.rb +53 -0
- data/spec/extensions/string/truncate_spec.rb +23 -0
- data/spec/models/message_spec.rb +43 -0
- data/spec/spec.opts +7 -0
- data/spec/spec_helper.rb +21 -0
- data/tasks/database.rake +20 -0
- data/tasks/mswin.rake +62 -0
- data/tasks/osx.rake +73 -0
- data/tasks/package_lib.rake +130 -0
- metadata +99 -0
    
        data/script/console
    ADDED
    
    | @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby 
         | 
| 2 | 
            +
            require File.dirname(__FILE__) + '/../config/environment'
         | 
| 3 | 
            +
            env = ENV[Environment.app_env_const] || 'development'
         | 
| 4 | 
            +
            puts "Loading #{env} environment."
         | 
| 5 | 
            +
            Environment.setup(env, false)
         | 
| 6 | 
            +
            require "irb"
         | 
| 7 | 
            +
            require "irb/completion"
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            if __FILE__ == $0
         | 
| 10 | 
            +
              IRB.start(__FILE__)
         | 
| 11 | 
            +
            end
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Environment do
         | 
| 4 | 
            +
              it "should have an data_path method" do
         | 
| 5 | 
            +
                if Environment.mswin?
         | 
| 6 | 
            +
                  Environment.data_path.should == "#{File.expand_path(ENV['APPDATA'])}/#{Environment.app_name.camelize}"
         | 
| 7 | 
            +
                elsif Environment.darwin?
         | 
| 8 | 
            +
                  Environment.data_path.should == "#{ENV['HOME']}/.#{Environment.app_name.underscore.downcase}/"
         | 
| 9 | 
            +
                else
         | 
| 10 | 
            +
                  fail "No test defined for #{RUBY_PLATFORM}"
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              describe "backup_database" do 
         | 
| 15 | 
            +
                before :each do
         | 
| 16 | 
            +
                  Environment.environment = "production" 
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                it "should return the number of backups" do 
         | 
| 20 | 
            +
                  Environment.backup_limit.should == 10
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
                
         | 
| 23 | 
            +
                it "should not perform for other than production environments" do
         | 
| 24 | 
            +
                  Environment.environment = "other"
         | 
| 25 | 
            +
                  FileUtils.should_not_receive(:cp)
         | 
| 26 | 
            +
                  Environment.backup_database
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                
         | 
| 29 | 
            +
                it "should attempt to copy the database if it does not exist" do
         | 
| 30 | 
            +
                  File.should_receive(:exists?).with(Environment.db_file).and_return(false)
         | 
| 31 | 
            +
                  FileUtils.should_not_receive(:cp)
         | 
| 32 | 
            +
                  Environment.backup_database
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
                
         | 
| 35 | 
            +
                it "should perform for production environments" do
         | 
| 36 | 
            +
                  File.stub!(:exists?).and_return(true)
         | 
| 37 | 
            +
                  FileUtils.should_receive(:cp)
         | 
| 38 | 
            +
                  Environment.backup_database
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
                
         | 
| 41 | 
            +
                it "should rename all existing backups with an increment of 1 and delete the backup limit if it exists" do
         | 
| 42 | 
            +
                  File.stub!(:exists?).and_return(true)
         | 
| 43 | 
            +
                  FileUtils.should_receive(:cp).with("#{Environment.db_file}", "#{Environment.db_file}.1")
         | 
| 44 | 
            +
                  backup_files = (1..Environment.backup_limit).collect{ | i | "#{Environment.db_file}.#{i}" }
         | 
| 45 | 
            +
                  Dir.should_receive(:glob).with("#{Environment.db_file}.*").and_return(backup_files)
         | 
| 46 | 
            +
                  (1..Environment.backup_limit).each do | i |
         | 
| 47 | 
            +
                    next if i == Environment.backup_limit
         | 
| 48 | 
            +
                    FileUtils.should_receive(:mv).with("#{Environment.db_file}.#{i}", "#{Environment.db_file}.#{i+1}")
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                  Environment.backup_database
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Extensions::String::Truncate do
         | 
| 4 | 
            +
              it "should leave strings of less than 20 unchanged" do
         | 
| 5 | 
            +
                "test".truncate.should == "test"
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              it "should truncate strings of more than 20 chars by default" do
         | 
| 9 | 
            +
                 'Lorem ipsum dolor sit amet, consectetur'.truncate.should == "Lorem ipsum dolor..."
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              it "should take an argument to determine the length of the truncation" do
         | 
| 13 | 
            +
                'Lorem ipsum dolor sit amet, consectetur'.truncate(30).should == "Lorem ipsum dolor sit amet,..."
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              it "should return the original string if the truncation size is less than the size of the ellipses" do
         | 
| 17 | 
            +
                "test".truncate(1).truncate.should == "test"
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
              it "should return the original string if the size of the string would be exactly the same with the ellipsis and the truncation" do
         | 
| 21 | 
            +
                "123".truncate(3).should == "123"
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Message do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              attr_reader :xena
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              before(:each) do
         | 
| 8 | 
            +
                Message.delete_all
         | 
| 9 | 
            +
                @xena = Message.create!(:name => "XenaWarriorPrincess", :content => "some content")
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              describe "validations" do 
         | 
| 13 | 
            +
                it "should require a name" do
         | 
| 14 | 
            +
                  lambda {
         | 
| 15 | 
            +
                    Message.create!(:content => "some content")
         | 
| 16 | 
            +
                  }.should raise_error(ActiveRecord::RecordInvalid, "Validation failed: Name can't be blank")
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                it "should require content" do
         | 
| 20 | 
            +
                  lambda {
         | 
| 21 | 
            +
                    Message.create!(:name => "A Name")
         | 
| 22 | 
            +
                  }.should raise_error(ActiveRecord::RecordInvalid, "Validation failed: Content can't be blank")
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
              
         | 
| 26 | 
            +
              describe "Accessors" do
         | 
| 27 | 
            +
                describe "ordered_by_name" do
         | 
| 28 | 
            +
                  it "should return all users, ordered case-insensitively" do
         | 
| 29 | 
            +
                    abby = Message.create!(:name => "abigail", :content => "some content" )
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    Message.ordered_by_name.should == [abby, xena]
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                describe "names" do
         | 
| 36 | 
            +
                  it "should return a list of names ordered case-insensitively" do 
         | 
| 37 | 
            +
                    abby = Message.create!(:name => "abigail", :content => "Some Content")
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    Message.names.should == ["abigail", "XenaWarriorPrincess"]
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
    
        data/spec/spec.opts
    ADDED
    
    
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../config/environment'
         | 
| 2 | 
            +
            Environment.setup('test', false)
         | 
| 3 | 
            +
            $:.unshift("/opt/local/lib/ruby/gems/1.8/gems/rspec-1.1.11/lib")
         | 
| 4 | 
            +
            require 'spec'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Spec
         | 
| 7 | 
            +
              module Example
         | 
| 8 | 
            +
                module ExampleMethods
         | 
| 9 | 
            +
                  alias_method :__full_description, :full_description
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            def putsh(stuff=nil)
         | 
| 15 | 
            +
              puts "#{ERB::Util.h(stuff.to_s)}<br/>"
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            def ph(stuff=nil)
         | 
| 19 | 
            +
              putsh stuff.inspect
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
    
        data/tasks/database.rake
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            namespace :db do
         | 
| 2 | 
            +
              desc "Reset database"
         | 
| 3 | 
            +
              task :reset do
         | 
| 4 | 
            +
                reset_environment = ENV[Environment.app_env_const] || 'development'
         | 
| 5 | 
            +
                puts "Resetting #{reset_environment} environment."
         | 
| 6 | 
            +
                Environment.require_libs(false)
         | 
| 7 | 
            +
                File.unlink Environment.db_file(reset_environment) rescue {}
         | 
| 8 | 
            +
                Environment.setup(reset_environment, false)
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              desc "Migrate database"
         | 
| 12 | 
            +
              task :migrate do
         | 
| 13 | 
            +
                migrate_environment = ENV[Environment.app_env_const] || 'development'
         | 
| 14 | 
            +
                puts "Migrating #{migrate_environment} environment."
         | 
| 15 | 
            +
                Environment.require_libs(false)
         | 
| 16 | 
            +
                Environment.establish_connection
         | 
| 17 | 
            +
                Environment.migrate
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
    
        data/tasks/mswin.rake
    ADDED
    
    | @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            require 'mkmf'
         | 
| 2 | 
            +
            require 'fileutils' #?
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            namespace :package do 
         | 
| 5 | 
            +
              desc "Create NSIS installer"
         | 
| 6 | 
            +
              task :mswin, "version"  do |t, args|
         | 
| 7 | 
            +
                raise "No Version specified" if args.version.nil?
         | 
| 8 | 
            +
                self.build_version = args.version
         | 
| 9 | 
            +
                assemble
         | 
| 10 | 
            +
                
         | 
| 11 | 
            +
                generate_mswin_shell_wrappers
         | 
| 12 | 
            +
                touch "#{bin_dir}/ubygems.rb" # For dumb RUBYOPTS
         | 
| 13 | 
            +
                puts `#{makensis} /V1 /DAPP_NAME=#{Environment.app_name} /DAPP_NAME_DOWNCASE=#{Environment.app_name.underscore} /DAPP_DOC_EXTENSION=#{app_doc_extension} /DVERSION=#{build_version} /DVERSIONEXTRA=#{build_version + ".0.0"} /DBUILD_DIR=#{build_dir} #{nsis_scriptfile_name}`
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              def app_doc_extension
         | 
| 17 | 
            +
                '.dtt'
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              # Needed to give XP-style widgets
         | 
| 20 | 
            +
              def manifest_file_name
         | 
| 21 | 
            +
                File.join(build_dir, "#{Environment.app_name.underscore}.exe.manifest")
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def generate_manifest_file
         | 
| 25 | 
            +
                File.open(manifest_file_name, 'w') do | f |
         | 
| 26 | 
            +
                  f.puts("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
         | 
| 27 | 
            +
              <assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"><assemblyIdentity version=\"1.8.6.0\" processorArchitecture=\"X86\" name=\"Microsoft.Winweb.Ruby\" type=\"win32\" /><description>#{Environment.app_name} Ruby Interpreter</description><dependency><dependentAssembly><assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" processorArchitecture=\"X86\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\"  /></dependentAssembly></dependency></assembly>")
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def nsis_scriptfile_name
         | 
| 32 | 
            +
                 File.join(Environment.app_root, "/package/installer.nsi")
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def makensis
         | 
| 36 | 
            +
                config["i386-mswin32"][:makensis]
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def nsis_outfile
         | 
| 40 | 
            +
                "#{Environment.app_name.underscore}-install-#{build_version}.exe"
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
              
         | 
| 43 | 
            +
              # The craziness below is solely for the purpose of 
         | 
| 44 | 
            +
              # unsetting RUBYOPT, which can disable the program if not 
         | 
| 45 | 
            +
              # set correctly. Better solutions are welcome
         | 
| 46 | 
            +
              def generate_mswin_shell_wrappers
         | 
| 47 | 
            +
                File.open(bin_dir + "/init.bat", 'w') do | f | 
         | 
| 48 | 
            +
                  f.puts "set RUBYOPT=\n" + 
         | 
| 49 | 
            +
                  "#{app_ruby_executable_name} pinit.rb\n"
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                File.open(bin_dir + "/run.vbs", 'w') do | f | 
         | 
| 53 | 
            +
                  f.puts "Set WshShell = CreateObject(\"WScript.Shell\")\n" + 
         | 
| 54 | 
            +
                    "WshShell.Run chr(34) & \"init.bat\" & Chr(34), 0\n" + 
         | 
| 55 | 
            +
                  "Set WshShell = Nothing\n"
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
              
         | 
| 59 | 
            +
              def ruby_bin_dir
         | 
| 60 | 
            +
                config[RUBY_PLATFORM][:ruby_bin_dir]
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
            end
         | 
    
        data/tasks/osx.rake
    ADDED
    
    | @@ -0,0 +1,73 @@ | |
| 1 | 
            +
            require 'mkmf'
         | 
| 2 | 
            +
            require 'fileutils' # ? 
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            namespace :package do 
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              desc "Create DMG for App"
         | 
| 7 | 
            +
              task :dmg, "version" do | t, args |
         | 
| 8 | 
            +
                raise "No Version specified" if args.version.nil?
         | 
| 9 | 
            +
                self.build_version = args.version
         | 
| 10 | 
            +
                Rake::Task['package:osx_app'].invoke(args.version)
         | 
| 11 | 
            +
                rm_rf dmg_source_name
         | 
| 12 | 
            +
                mkdir_p dmg_source_name 
         | 
| 13 | 
            +
                cp_r app_bundle_name, dmg_source_name
         | 
| 14 | 
            +
                rm_rf dmg_image_name
         | 
| 15 | 
            +
                sh "hdiutil create -fs HFS+ -srcfolder #{dmg_source_name} -format UDBZ " +
         | 
| 16 | 
            +
                   "-volname '#{Environment.app_name} #{build_version}'  #{dmg_image_name}"
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              desc "Create an OSX App bundle"
         | 
| 20 | 
            +
              task :osx_app, "version" do | task, args |
         | 
| 21 | 
            +
                raise "No Version specified" if args.version.nil?
         | 
| 22 | 
            +
                self.build_version = args.version
         | 
| 23 | 
            +
                assemble
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                rm_rf app_bundle_name
         | 
| 26 | 
            +
                generate_osx_shell_wrapper
         | 
| 27 | 
            +
                
         | 
| 28 | 
            +
                includes = config[:common][:include_dirs].inject("-f build/bin ") do | inc, dir |
         | 
| 29 | 
            +
                  inc << "-f build/#{dir} "
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
                    
         | 
| 32 | 
            +
                sh "platypus -a '#{Environment.app_name}' -V #{build_version} " +
         | 
| 33 | 
            +
                   "-f build/lib #{includes}  " + 
         | 
| 34 | 
            +
                   "#{osx_shell_wrapper_name} #{Environment.app_root + '/' + Environment.app_name}.app"
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                require 'rexml/document'
         | 
| 37 | 
            +
                info_plist = File.join(app_bundle_name, 'Contents', 'Info.plist')
         | 
| 38 | 
            +
                doc = REXML::Document.new( File.read(info_plist) )
         | 
| 39 | 
            +
                dict = doc.elements['/plist/dict']
         | 
| 40 | 
            +
                dict_items = dict.children.grep(REXML::Element)
         | 
| 41 | 
            +
                lsui_key = dict_items.find { | elem | elem.text == 'LSUIElement' }
         | 
| 42 | 
            +
                lsui_val = dict_items[ dict_items.index( lsui_key ) + 1 ]
         | 
| 43 | 
            +
                lsui_val.text = '1'
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                File.open(info_plist, 'w') { | plist_file | plist_file.write( doc.to_s ) }
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              def app_bundle_name
         | 
| 49 | 
            +
                @app_bundle ||= Environment.app_name + '.app'
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              def dmg_source_name 
         | 
| 53 | 
            +
                @dmg_source_name ||= File.join(Environment.app_root, 'dmg')
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
              
         | 
| 56 | 
            +
              def dmg_image_name
         | 
| 57 | 
            +
                @dmg_image_name ||= ("#{Environment.app_name}-%s.dmg" % build_version)
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
              def osx_shell_wrapper_name 
         | 
| 61 | 
            +
                @osx_shell_wrapper_name ||= build_dir + "/init.sh"
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
              
         | 
| 64 | 
            +
              def generate_osx_shell_wrapper
         | 
| 65 | 
            +
                File.open(osx_shell_wrapper_name, 'w') do | f | 
         | 
| 66 | 
            +
                  f.puts "#!/bin/sh\n" + 
         | 
| 67 | 
            +
                  "export DYLD_LIBRARY_PATH=\"$1/Contents/Resources/bin\" && exec" + 
         | 
| 68 | 
            +
                  " \"$1/Contents/Resources/bin/#{app_ruby_executable_name}\" " +
         | 
| 69 | 
            +
                  "-I\"$1/Contents/Resources/config\" " + 
         | 
| 70 | 
            +
                  "\"$1/Contents/Resources/bin/pinit.rb\" \"$1\""
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
            end
         | 
| @@ -0,0 +1,130 @@ | |
| 1 | 
            +
            require 'set'
         | 
| 2 | 
            +
            namespace :package do 
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              desc "Zip the project, with version."
         | 
| 5 | 
            +
              task :zip, :version do | t, args |
         | 
| 6 | 
            +
                if args.version.nil? 
         | 
| 7 | 
            +
                  puts "usage: rake zip[version]"
         | 
| 8 | 
            +
                  exit 1
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
                sh "zip -lry #{File.expand_path(Environment.app_root + '/..')}/#{Environment.app_name.downcase}-#{args.version}.zip #{Environment.app_root}"
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              desc "Clean up build products."
         | 
| 14 | 
            +
              task :clean do 
         | 
| 15 | 
            +
                [ "*.dmg", '*.app', 'build', 'mkmf.log', 'dmg', 'package/*.exe' ].each do | product |
         | 
| 16 | 
            +
                  targets =  Dir.glob( "#{Environment.app_root}/#{product}" )
         | 
| 17 | 
            +
                  rm_rf( targets ) unless targets.empty?
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def config
         | 
| 22 | 
            +
                @config ||= YAML.load_file(Environment.app_root + '/package/config.yml')
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def assemble
         | 
| 26 | 
            +
                rm_rf build_dir
         | 
| 27 | 
            +
                mkdir build_dir
         | 
| 28 | 
            +
                mkdir bin_dir
         | 
| 29 | 
            +
                mkdir lib_dir
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                copy_source_files_and_libraries
         | 
| 32 | 
            +
                
         | 
| 33 | 
            +
                cp File.expand_path(File.join(Environment.app_root, 'bin', 'pinit.rb')), bin_dir
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                cp "#{ruby_executable_name}", "#{bin_dir}/#{app_ruby_executable_name}"
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                config[:common][:include_dirs].each do | dir |
         | 
| 38 | 
            +
                  cp_r "#{Environment.app_root}/#{dir}", build_dir
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                (config[:common][:include_files] + include_files).each do | file |
         | 
| 42 | 
            +
                  if file.is_a?(Hash)
         | 
| 43 | 
            +
                    target = "#{build_dir}/#{file[:target]}"
         | 
| 44 | 
            +
                    mkdir_p(target)  unless File.exists?(target)
         | 
| 45 | 
            +
                    cp file[:source], target
         | 
| 46 | 
            +
                  else
         | 
| 47 | 
            +
                    target_dir = "#{build_dir}/#{File.dirname(file)}"
         | 
| 48 | 
            +
                    mkdir_p(target_dir)  unless File.exists?(target_dir)
         | 
| 49 | 
            +
                    cp Environment.app_root + "/#{file}", target_dir
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              def copy_source_files_and_libraries
         | 
| 55 | 
            +
                ENV['ASSEMBLING'] = "true"
         | 
| 56 | 
            +
                load File.join(Environment.app_root, 'bin', 'init.rb')
         | 
| 57 | 
            +
                libraries = Set.new
         | 
| 58 | 
            +
                $LOADED_FEATURES.each do | feature |
         | 
| 59 | 
            +
                  next if feature == "enumerator.so" # Not sure why we have to do this.
         | 
| 60 | 
            +
                  if path = $LOAD_PATH.detect{ | path | File.exists?(File.join(path, feature)) }
         | 
| 61 | 
            +
                    dest_path = File.join(lib_dir, File.dirname(feature)) 
         | 
| 62 | 
            +
                    FileUtils.mkdir_p(dest_path) unless File.exists?(dest_path)
         | 
| 63 | 
            +
                    cp File.join(path,feature), dest_path
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    unless feature =~ /\.rb$/
         | 
| 66 | 
            +
                      `otool -L #{File.join(path,feature)}`.grep(/\s+\//).each do  | line | 
         | 
| 67 | 
            +
                        library = line.strip.split(/\s+/)[0] 
         | 
| 68 | 
            +
                        libraries << library if File.exists?(library) 
         | 
| 69 | 
            +
                      end
         | 
| 70 | 
            +
                    end
         | 
| 71 | 
            +
                  else
         | 
| 72 | 
            +
                    raise "Could not find #{feature} in filesystem."
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
                
         | 
| 76 | 
            +
                libraries.each do | file | 
         | 
| 77 | 
            +
                  cp file, bin_dir
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              def ruby_executable_name
         | 
| 82 | 
            +
                @ruby_executable_name ||= File.join( Config::CONFIG['bindir'],
         | 
| 83 | 
            +
                  Config::CONFIG['RUBY_INSTALL_NAME'] +
         | 
| 84 | 
            +
                  Config::CONFIG['EXEEXT'] 
         | 
| 85 | 
            +
                )
         | 
| 86 | 
            +
              end
         | 
| 87 | 
            +
              
         | 
| 88 | 
            +
              def include_files
         | 
| 89 | 
            +
                config[RUBY_PLATFORM][:include_files]
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              def include_libs
         | 
| 93 | 
            +
                config[RUBY_PLATFORM][:include_libs]
         | 
| 94 | 
            +
              end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
              def build_dir
         | 
| 97 | 
            +
                @build_dir ||= Environment.app_root + '/build'
         | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
              
         | 
| 100 | 
            +
              def bin_dir
         | 
| 101 | 
            +
                @bin_dir ||= "#{build_dir}/bin"
         | 
| 102 | 
            +
              end
         | 
| 103 | 
            +
              
         | 
| 104 | 
            +
              def lib_dir
         | 
| 105 | 
            +
                @lib_dir ||= "#{build_dir}/lib"
         | 
| 106 | 
            +
              end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
              def build_version
         | 
| 109 | 
            +
                raise "No build_version specified" if @build_version.nil?
         | 
| 110 | 
            +
                @build_version
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
              
         | 
| 113 | 
            +
              def build_version=(version)
         | 
| 114 | 
            +
                @build_version = version
         | 
| 115 | 
            +
              end
         | 
| 116 | 
            +
              
         | 
| 117 | 
            +
              def app_ruby_executable_name
         | 
| 118 | 
            +
                if @app_ruby_executable_name.nil?
         | 
| 119 | 
            +
                  @app_ruby_executable_name = case RUBY_PLATFORM
         | 
| 120 | 
            +
                  when "i686-darwin9"
         | 
| 121 | 
            +
                    Environment.app_name
         | 
| 122 | 
            +
                  when "i386-mswin32"
         | 
| 123 | 
            +
                    Environment.app_name.underscore + '.exe'
         | 
| 124 | 
            +
                  else
         | 
| 125 | 
            +
                    raise "No app_ruby_exectable_name defined fer #{RUBY_PLATFORM}"
         | 
| 126 | 
            +
                  end
         | 
| 127 | 
            +
                end
         | 
| 128 | 
            +
                @app_ruby_executable_name
         | 
| 129 | 
            +
              end
         | 
| 130 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,99 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: ruby_on_skis
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              prerelease: false
         | 
| 5 | 
            +
              segments: 
         | 
| 6 | 
            +
              - 0
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 0
         | 
| 9 | 
            +
              version: 0.0.0
         | 
| 10 | 
            +
            platform: ruby
         | 
| 11 | 
            +
            authors: 
         | 
| 12 | 
            +
            - Daniel P. Zepeda
         | 
| 13 | 
            +
            autorequire: 
         | 
| 14 | 
            +
            bindir: bin
         | 
| 15 | 
            +
            cert_chain: []
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            date: 2010-03-18 00:00:00 -05:00
         | 
| 18 | 
            +
            default_executable: 
         | 
| 19 | 
            +
            dependencies: []
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            description: "      The aim of Ruby on Skis is to provide a starting structure within which to program your wxRuby project. \n      The template provides a directory structure, a set of Rakefiles to manage, and most importantly, to \n      package your Ruby application for distribution as a standalone program when completed. It also includes \n      an environment to get the application running and provide basic services to the program code. \n      For now, the template only supports packaging for Mac OSX and Windows, although various flavors of \n      Linux should be easily accommodated and are planned for the future    \n"
         | 
| 22 | 
            +
            email: duskhacker@duskhacker.com
         | 
| 23 | 
            +
            executables: 
         | 
| 24 | 
            +
            - init.rb
         | 
| 25 | 
            +
            - pinit.rb
         | 
| 26 | 
            +
            extensions: []
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            extra_rdoc_files: 
         | 
| 29 | 
            +
            - README.textile
         | 
| 30 | 
            +
            files: 
         | 
| 31 | 
            +
            - README.textile
         | 
| 32 | 
            +
            - Rakefile
         | 
| 33 | 
            +
            - VERSION
         | 
| 34 | 
            +
            - bin/init.rb
         | 
| 35 | 
            +
            - bin/pinit.rb
         | 
| 36 | 
            +
            - config/environment.rb
         | 
| 37 | 
            +
            - config/gemconfigure.rb
         | 
| 38 | 
            +
            - config/requires.yml
         | 
| 39 | 
            +
            - data/lorem.txt
         | 
| 40 | 
            +
            - fixtures/messages.yml
         | 
| 41 | 
            +
            - images/ruby_on_skis.ico
         | 
| 42 | 
            +
            - lib/extensions/string/truncate.rb
         | 
| 43 | 
            +
            - lib/models/message.rb
         | 
| 44 | 
            +
            - lib/wx/app.xrc
         | 
| 45 | 
            +
            - lib/wx/app/app_frame.rb
         | 
| 46 | 
            +
            - lib/wx/app/message_panel.rb
         | 
| 47 | 
            +
            - lib/wx/app/taskbar_icon.rb
         | 
| 48 | 
            +
            - lib/wx/base/appframebase.rb
         | 
| 49 | 
            +
            - lib/wx/base/messagepanelbase.rb
         | 
| 50 | 
            +
            - lib/wx/helpers/app_helper.rb
         | 
| 51 | 
            +
            - migrate/20081128200300_init.rb
         | 
| 52 | 
            +
            - package/config.yml
         | 
| 53 | 
            +
            - package/installer.nsi
         | 
| 54 | 
            +
            - ruby_on_skis.fbp
         | 
| 55 | 
            +
            - script/console
         | 
| 56 | 
            +
            - spec/config/environment_spec.rb
         | 
| 57 | 
            +
            - spec/extensions/string/truncate_spec.rb
         | 
| 58 | 
            +
            - spec/models/message_spec.rb
         | 
| 59 | 
            +
            - spec/spec.opts
         | 
| 60 | 
            +
            - spec/spec_helper.rb
         | 
| 61 | 
            +
            - tasks/database.rake
         | 
| 62 | 
            +
            - tasks/mswin.rake
         | 
| 63 | 
            +
            - tasks/osx.rake
         | 
| 64 | 
            +
            - tasks/package_lib.rake
         | 
| 65 | 
            +
            has_rdoc: true
         | 
| 66 | 
            +
            homepage: http://github.com/duskhacker/ruby_on_skis
         | 
| 67 | 
            +
            licenses: []
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            post_install_message: 
         | 
| 70 | 
            +
            rdoc_options: 
         | 
| 71 | 
            +
            - --charset=UTF-8
         | 
| 72 | 
            +
            require_paths: 
         | 
| 73 | 
            +
            - lib
         | 
| 74 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 75 | 
            +
              requirements: 
         | 
| 76 | 
            +
              - - ">="
         | 
| 77 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 78 | 
            +
                  segments: 
         | 
| 79 | 
            +
                  - 0
         | 
| 80 | 
            +
                  version: "0"
         | 
| 81 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 82 | 
            +
              requirements: 
         | 
| 83 | 
            +
              - - ">="
         | 
| 84 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 85 | 
            +
                  segments: 
         | 
| 86 | 
            +
                  - 0
         | 
| 87 | 
            +
                  version: "0"
         | 
| 88 | 
            +
            requirements: []
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            rubyforge_project: 
         | 
| 91 | 
            +
            rubygems_version: 1.3.6
         | 
| 92 | 
            +
            signing_key: 
         | 
| 93 | 
            +
            specification_version: 3
         | 
| 94 | 
            +
            summary: Provide a starting structure within which to program your wxRuby project
         | 
| 95 | 
            +
            test_files: 
         | 
| 96 | 
            +
            - spec/config/environment_spec.rb
         | 
| 97 | 
            +
            - spec/extensions/string/truncate_spec.rb
         | 
| 98 | 
            +
            - spec/models/message_spec.rb
         | 
| 99 | 
            +
            - spec/spec_helper.rb
         |