Skip to content
Browse files

Merge branch 'develop' of github.com:shoes/shoes into develop

  • Loading branch information...
2 parents 3b51125 + 1670f09 commit 2a7da6ac4ec6747b2ce5639a0b7a25a24289844e @mpapis mpapis committed Mar 15, 2012
View
1 .gitignore
@@ -14,3 +14,4 @@ tags
*.so
Makefile
mkmf.log
+.DS_Store
View
32 Rakefile
@@ -1,11 +1,15 @@
-require 'rubygems'
require 'rake'
require 'rake/clean'
# require_relative 'platform/skel'
require 'fileutils'
require 'find'
-require 'yaml'
include FileUtils
+require 'yaml'
+
+YAML::ENGINE.yamler = 'syck' # Use Syck for backward compatibility
+
+# Use Syck for backward compatibility
+YAML::ENGINE.yamler = 'syck'
APP = YAML.load_file(File.join(ENV['APP'] || ".", "app.yaml"))
APPNAME = APP['name']
@@ -58,7 +62,7 @@ APPARGS = APP['run']
FLAGS = %w[DEBUG]
BIN = "*.{bundle,jar,o,so,obj,pdb,pch,res,lib,def,exp,exe,ilk}"
-CLEAN.include ["{bin,shoes}/#{BIN}", "req/**/#{BIN}", "dist", "*.app"]
+CLEAN.include ["{bin,shoes}/#{BIN}", "req/**/#{BIN}", "dist/**/*", "dist", "*.app"]
RUBY_SO = RbConfig::CONFIG['RUBY_SO_NAME']
RUBY_V = RbConfig::CONFIG['ruby_version']
@@ -320,6 +324,14 @@ namespace :osx do
end
end
+ # Find additional dylibs needed by other_lib (ignoring duplicates)
+ def additional_dylibs dylibs, other_lib
+ dylibs_to_change(other_lib).delete_if do |d|
+ basenames = dylibs.map { |lib| File.basename(lib) }
+ basenames.include? File.basename(d)
+ end
+ end
+
task :change_install_names do
cd "dist" do
["#{NAME}-bin", "pango-querymodules", *Dir['*.dylib'], *Dir['pango/modules/*.so']].each do |f|
@@ -350,18 +362,12 @@ namespace :osx do
# Start with dependencies of shoes-bin and pango-querymodules, and then
# add the dependencies of those dependencies.
dylibs = dylibs_to_change("dist/#{NAME}-bin")
- dylibs.concat dylibs_to_change("dist/pango-querymodules")
- dupes = []
- dylibs.each do |dylib|
- dylibs_to_change(dylib).each do |d|
- if dylibs.map {|lib| File.basename(lib)}.include?(File.basename(d))
- dupes << d
- else
- dylibs << d
- end
- end
+ dylibs.dup.each do |dylib|
+ dylibs.concat additional_dylibs(dylibs, dylib)
end
dylibs.each {|libn| cp "#{libn}", "dist/"}
+ # Verbose mode raises an exception (ruby bug?)
+ chmod_R "u+w", "dist/", :verbose => false
end
task :copy_files_to_dist do
View
2 lib/shoes/cache.rb
@@ -48,7 +48,7 @@
'LDFLAGS' => "-L. -L#{DIR}"
}
RbConfig::CONFIG.merge! config
-Config::MAKEFILE_CONFIG.merge! config
+RbConfig::MAKEFILE_CONFIG.merge! config
GEM_CENTRAL_DIR = File.join(DIR, 'ruby/gems/' + RbConfig::CONFIG['ruby_version'])
Dir[GEM_CENTRAL_DIR + "/gems/*"].each do |gdir|
$: << "#{gdir}/lib"
View
2 lib/shoes/shy.rb
@@ -9,6 +9,8 @@
require 'tmpdir'
require 'yaml'
+YAML::ENGINE.yamler = 'syck' # Use Syck for backward compatibility
+
class Shy
VERSION = 0x0001
MAGIC = "_shy".freeze
View
BIN spec/fixtures/argon_flyer.shy
Binary file not shown.
View
BIN spec/fixtures/argon_flyer/argon_flyer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
42 spec/fixtures/argon_flyer/argon_flyer.rb
@@ -0,0 +1,42 @@
+WIDTH = 400
+HEIGHT = 400
+
+Shoes.app :width => WIDTH, :height => HEIGHT, :resizable => false do
+ background hotpink
+ stack do
+ #@argon = banner "ARGON FLYER", :stroke => lawngreen, :align => 'center'
+ @argon = image "argon_flyer.png"
+ end
+
+ animate 10 do
+ left = new_position(WIDTH, @argon.width, @argon.left)
+ top = new_position(HEIGHT, @argon.height, @argon.top)
+ @argon.move left, top
+ end
+
+ def keep_in_frame(frame_max, object_size, starting_point, position)
+ if (position < 0)
+ position += 2
+ elsif position + object_size > frame_max
+ position -= 2
+ end
+ position
+ end
+
+ def new_position(frame_max, object_size, starting_point)
+ position = random_position(starting_point)
+ keep_in_frame(frame_max, object_size, starting_point, position)
+ end
+
+ def random_position(starting_point)
+ starting_point + (random_amount * random_direction)
+ end
+
+ def random_amount
+ rand(20)
+ end
+
+ def random_direction
+ rand(2) == 1 ? 1 : -1
+ end
+end
View
35 spec/shy_spec.rb
@@ -0,0 +1,35 @@
+require 'shoes/shy'
+
+describe 'Shy' do
+ let(:shy_meta_yaml) { "--- !hackety.org,2007/shy \ncreator: Fearless Aeronaut\nlaunch: argon_flyer.rb\nname: Argon Flyer\nversion: 0.1.2\n" }
+ let(:shy_meta) {
+ s = Shy.new
+ s.name = "Argon Flyer"
+ s.creator = "Fearless Aeronaut"
+ s.version = "0.1.2"
+ s.launch = "argon_flyer.rb"
+ s
+ }
+
+ it "uses the Syck YAML library" do
+ YAML.should eq(Syck)
+ end
+
+ it "serializes metadata in Shoes format (Syck)" do
+ shy_meta.to_yaml.should eq(shy_meta_yaml)
+ end
+
+ it "roundtrips .shy metadata" do
+ new_shy_meta = YAML.load(shy_meta.to_yaml)
+ new_shy_meta.should be_instance_of(Shy)
+ new_shy_meta.name.should eq(shy_meta.name)
+ new_shy_meta.creator.should eq(shy_meta.creator)
+ new_shy_meta.version.should eq(shy_meta.version)
+ new_shy_meta.launch.should eq(shy_meta.launch)
+ end
+
+ it "extracts metadata from a .shy file into a Shy object" do
+ shy = Shy.meta(File.join(File.dirname(__FILE__), "fixtures", "argon_flyer.shy"))
+ shy.should be_instance_of(Shy)
+ end
+end

0 comments on commit 2a7da6a

Please sign in to comment.
Something went wrong with that request. Please try again.