Code Monkey home page Code Monkey logo

swftly's Introduction

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.

swftly's People

Stargazers

 avatar General Westerfeld avatar Carla Anne avatar Ben Praeger avatar ? avatar Taras Kalapun avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

urras

swftly's Issues

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec,

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Even for projects that already specify a license, including a license in your gemspec is a good practice, since it is easily
discoverable there without having to check the readme or for a license file.

For example, there is a License Finder gem to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough
issue that even Bundler now generates gems with a default 'MIT' license.

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file),
github has created a license picker tool.

In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally
looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :).

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue and let me know. In either case, I'll follow up. Thanks!

p.s. I've written a blog post about this project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.