swf_ditty 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -21,23 +21,32 @@ Drop this line in your app:
21
21
 
22
22
  == Usage
23
23
 
24
- The following example assumes you're using {haml}[http://haml-lang.com/] and my {ratpack}[http://github.com/zeke/ratpack] helpers.
24
+ The following example assumes you're using {haml}[http://haml-lang.com/] and my {ratpack}[http://github.com/zeke/ratpack] helpers gem
25
+ (for the `javascript_include_tag` method):
25
26
 
26
27
  %html
27
28
  %head
28
- =javascript_include_tag %w(jquery-1.3.2.min.js jquery.swfobject.1-0-7.min)
29
+ =javascript_include_tag %w(jquery-1.3.2.min jquery.swfobject.1-0-7.min)
29
30
  %body
30
31
  = swf 'my_swf.swf'
31
- = swf 'subdirectory/of/public/another.swf', :width => 500, :height => 300, :flashvars => {:foo => 'chacha', :bar => 250}
32
+ = swf 'subdirectory/of/public/another.swf', :width => 500, :height => 300
32
33
  = swf 'http://example.com/yet_another.swf', :wmode => 'opaque'
34
+
35
+ Passing in FlashVars is easy:
36
+
37
+ = swf 'swf/foo.swf', :flashvars => {:foo => 'chacha', :bar => 250}
33
38
 
39
+ By default, a DOM element is automatically created based on a variation of the swf filename, but you can override it like so:
40
+
41
+ = swf 'swf/foo.swf', :dom_id => 'custom_dom_dom_doobie', :create_dom_container => false
42
+
34
43
  See full auto-generated documentation at {rdoc.info/projects/zeke/swf_ditty}[http://rdoc.info/projects/zeke/swf_ditty]
35
44
 
36
45
  == Colophon
37
46
 
38
47
  * Thanks to the Sinatra page on {Writing Extensions}[http://www.sinatrarb.com/extensions.html]
39
- * Tests modified from {http://github.com/wbzyl/sinatra-static-assets/}[wbzyl/sinatra-static-assets]
40
- * Gem built with {http://github.com/technicalpickles/jeweler/}[Jeweler]
48
+ * Tests modified from {wbzyl/sinatra-static-assets}[http://github.com/wbzyl/sinatra-static-assets]
49
+ * Gem built with {Jeweler}[http://github.com/technicalpickles/jeweler]
41
50
 
42
51
  == Copyright
43
52
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -3,11 +3,21 @@ require 'sinatra/base'
3
3
  module Sinatra
4
4
  module SwfDitty
5
5
 
6
- def render_swf(swf, *args)
6
+ # Outputs javscript to embed your SWF.
7
+ # The only required argument is the swf_file path, relative to the public directory.
8
+ # swf_file can also of course be a full URL.
9
+ #
10
+ # swf 'foo.swf'
11
+ # swf 'foo.swf', :height => 50, :flashvars => {:a => 1, :b => 'two'}
12
+ #
13
+ # By default, a DOM container is generated, but if you don't want that just pass in your
14
+ # custom `dom_id` and set `create_dom_container` to false
15
+ # swf 'swf/foo.swf', :dom_id => 'dombo', :create_dom_container => false)
16
+ def swf(swf_file, *args)
7
17
  options = {
8
- :swf => swf,
9
- :dom_id => filename_to_dom_id(swf),
10
- :name => filename_to_dom_id(swf),
18
+ :swf => swf_file,
19
+ :dom_id => filename_to_dom_id(swf_file),
20
+ :name => filename_to_dom_id(swf_file),
11
21
  :width => "100%",
12
22
  :height => "100%",
13
23
  :wmode => "opaque",
@@ -46,7 +56,7 @@ module Sinatra
46
56
  result.downcase
47
57
  end
48
58
 
49
- # Convert a hash to a string of k:v pairs, delimited by commas
59
+ # Convert a hash to a string of key:value pairs, delimited by commas
50
60
  # Wrap in quotes unless numeric or flashvars hash
51
61
  def hash_to_key_value_string(hash)
52
62
  hash.each_pair.map do |k,v|
data/swf_ditty.gemspec ADDED
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{swf_ditty}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Zeke Sikelianos"]
12
+ s.date = %q{2009-11-02}
13
+ s.description = %q{A simple and flexible Sinatra helper for embedding SWFs in your views. Depends on jQuery and jQuery SWFObject}
14
+ s.email = %q{zeke@sikelianos.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/sinatra/swf_ditty.rb",
27
+ "swf_ditty.gemspec",
28
+ "test/helper.rb",
29
+ "test/sinatra_app.rb",
30
+ "test/test_swf_ditty.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/zeke/swf_ditty}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.5}
36
+ s.summary = %q{A simple and flexible Sinatra helper for embedding SWFs in your views.}
37
+ s.test_files = [
38
+ "test/helper.rb",
39
+ "test/sinatra_app.rb",
40
+ "test/test_swf_ditty.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ end
55
+ end
56
+
data/test/sinatra_app.rb CHANGED
@@ -5,24 +5,24 @@ require 'rubygems'
5
5
  require 'sinatra'
6
6
  require 'sinatra/swf_ditty'
7
7
 
8
- get "/render_swf_plain" do
8
+ get "/swf_plain" do
9
9
  content_type "text/plain"
10
10
  <<"EOD"
11
- #{render_swf("swf/foo.swf")}
11
+ #{swf("swf/foo.swf")}
12
12
  EOD
13
13
  end
14
14
 
15
- get "/render_swf_with_custom_dom_id" do
15
+ get "/swf_with_custom_dom_id" do
16
16
  content_type "text/plain"
17
17
  <<"EOD"
18
- #{render_swf("swf/foo.swf", :dom_id => "dombo", :create_dom_container => false)}
18
+ #{swf("swf/foo.swf", :dom_id => "dombo", :create_dom_container => false)}
19
19
  EOD
20
20
  end
21
21
 
22
- get "/render_swf_with_flashvars" do
22
+ get "/swf_with_flashvars" do
23
23
  content_type "text/plain"
24
24
  <<"EOD"
25
- #{render_swf("foo.swf", :height => 50, :flashvars => {:a => 1, :b => 'two'})}
25
+ #{swf("foo.swf", :height => 50, :flashvars => {:a => 1, :b => 'two'})}
26
26
  EOD
27
27
  end
28
28
 
@@ -12,8 +12,8 @@ class TestSwfDitty < Test::Unit::TestCase
12
12
  Sinatra::Application
13
13
  end
14
14
 
15
- def test_render_swf_plain
16
- get '/render_swf_plain'
15
+ def test_swf_plain
16
+ get '/swf_plain'
17
17
  assert last_response.ok?
18
18
  assert_equal last_response.body, <<EOD
19
19
  <script type='text/javascript' charset='utf-8'>$(document).ready(function(){$('#foo_swf').flash({allowScriptAccess:'sameDomain', height:'100%', name:'foo_swf', swf:'swf/foo.swf', width:'100%', wmode:'opaque'});});</script>
@@ -21,16 +21,16 @@ class TestSwfDitty < Test::Unit::TestCase
21
21
  EOD
22
22
  end
23
23
 
24
- def test_render_swf_with_custom_dom_id
25
- get '/render_swf_with_custom_dom_id'
24
+ def test_swf_with_custom_dom_id
25
+ get '/swf_with_custom_dom_id'
26
26
  assert last_response.ok?
27
27
  assert_equal last_response.body, <<EOD
28
28
  <script type='text/javascript' charset='utf-8'>$(document).ready(function(){$('#dombo').flash({allowScriptAccess:'sameDomain', height:'100%', name:'foo_swf', swf:'swf/foo.swf', width:'100%', wmode:'opaque'});});</script>
29
29
  EOD
30
30
  end
31
31
 
32
- def test_render_swf_with_flashvars
33
- get '/render_swf_with_flashvars'
32
+ def test_swf_with_flashvars
33
+ get '/swf_with_flashvars'
34
34
  assert last_response.ok?
35
35
  assert_equal last_response.body, <<EOD
36
36
  <script type='text/javascript' charset='utf-8'>$(document).ready(function(){$('#foo_swf').flash({allowScriptAccess:'sameDomain', flashvars:{a:1, b:'two'}, height:50, name:'foo_swf', swf:'foo.swf', width:'100%', wmode:'opaque'});});</script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swf_ditty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeke Sikelianos
@@ -39,6 +39,7 @@ files:
39
39
  - Rakefile
40
40
  - VERSION
41
41
  - lib/sinatra/swf_ditty.rb
42
+ - swf_ditty.gemspec
42
43
  - test/helper.rb
43
44
  - test/sinatra_app.rb
44
45
  - test/test_swf_ditty.rb