Permalink
Browse files

Use Syck engine for YAML. Fixes #187

  • Loading branch information...
1 parent 04776bf commit eec25aa4a82b9d175411598991278f1587518848 @wasnotrice wasnotrice committed Mar 10, 2012
View
@@ -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']
View
@@ -9,6 +9,8 @@
require 'tmpdir'
require 'yaml'
+YAML::ENGINE.yamler = 'syck' # Use Syck for backward compatibility
+
class Shy
VERSION = 0x0001
MAGIC = "_shy".freeze
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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
@@ -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 eec25aa

Please sign in to comment.