Project

swftly

0.0
No commit activity in last 3 years
No release in over 3 years
swftly abstracts and automates interactions with Swiffy, Google's hosted swf converter.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

~> 0.8.4
 Project Readme

Swftly - I don't like swf files.

Swftly is a tiny gem that abstracts interactions with Google's Swiffy service, which does a decent job of providing a Javascript-driven equivalent/alternative to a swf file. This project came about because I needed to push something like 6,000 individual swfs through Swiffy. I guess I could have used Google's Flash extension, but making a gem seemed like more fun.

License

Check the LICENSE file.

Dependencies

Installation...

$ gem install swftly

Or, in your Gemfile:

gem 'swftly'

Using Swftly

the_swf = '/absolute/path/to/yourfile.swf'
swftly = Swftly.new(the_swf) #fire her up
swftly.swiff #send the_swf off to Google's hosted service for conversion

#the runtime class has info about Swiffy's client-side runtime.js
swftly.runtime.version #=> "v5.2"
swftly.runtime.url     #=> "https://www.gstatic.com/swiffy/v5.2/runtime.js"

#the converted class lets you work with the markup/javascript generated by Swiffy
swftly.converted.markup           #=> returns the complete html document generated by Swiffy
swftly.converted.json_definition  #=> returns just the javascript that creates the swiffyobject json object

#Without auto_processig
the_swf = '/absolute/path/to/yourfile.swf'
swftly = Swftly.new(the_swf, false) #don't auto process
swftly.swiff #send the_swf off to Google's hosted service for conversion

if swftly.converter_response_code == 200 #success!
  swftly.process! #buildout the Runtime and Converted stuffs
  ...
  #do some persistence or rendering or whatevs
else
  ...
  #do something fancy here like raise a warning or requeue
end

Under the Hood

Swftly takes two arguments, both optional, when instantiating. The first is a String representing the path to a swf file and is accessible on the object as swf_path. The second, available on the object as auto_process, is a boolean that, when true, automatically triggers post-processing the conversion result. This post-processing creates and populates the Runtime and Converted class objects.

If auto_process is false, calling Swftly#swiff will post the swf to Swiffy and set Swftly.converter_response_code and Swftly.raw. This is helpful if you're batching many swfs for conversion because it allows for confirmation of a successful conversion (response code == 200) before trying to do any of the post-processing.

Also, both swf_path and auto_process are attr_accessible. Setting a new swf_path and calling Swftly#swiff will generate a new set of conversion data, allowing one instance to perform many conversions.

Development & Contact

Please feel free to contribute fixes and features via fork'n'pull. Drop tests into spec/. If you wanna talk about Swftly (or most anything else, really), I'm most reachable at @_jnf.