From 68a37bd4a18d865ee08ec848a4889e513707c2bc Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Mon, 30 Sep 2013 17:17:44 +0200 Subject: [PATCH] v0.5, matching JS version --- LICENSE | 20 ++++++++++ README.mdown | 3 ++ lib/umodule-source.rb | 1 + lib/umodule/source.rb | 13 +++++++ lib/umodule/source/umodule.js | 70 +++++++++++++++++++++++++++++++++++ umodule-source.gemspec | 16 ++++++++ 6 files changed, 123 insertions(+) create mode 100644 LICENSE create mode 100644 README.mdown create mode 100644 lib/umodule-source.rb create mode 100644 lib/umodule/source.rb create mode 100644 lib/umodule/source/umodule.js create mode 100644 umodule-source.gemspec diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c772868 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2012 Loic Nageleisen + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.mdown b/README.mdown new file mode 100644 index 0000000..069f1db --- /dev/null +++ b/README.mdown @@ -0,0 +1,3 @@ +# umodule-source + +Ruby gem containing [umodule-js](https://github.com/lloeki/umodule-js) source. diff --git a/lib/umodule-source.rb b/lib/umodule-source.rb new file mode 100644 index 0000000..90d44e1 --- /dev/null +++ b/lib/umodule-source.rb @@ -0,0 +1 @@ +require 'umodule/source' diff --git a/lib/umodule/source.rb b/lib/umodule/source.rb new file mode 100644 index 0000000..323a5a5 --- /dev/null +++ b/lib/umodule/source.rb @@ -0,0 +1,13 @@ +module Umodule + module Source + VERSION = 0.5 + + def self.bundled_path + File.expand_path('../source/umodule.js', __FILE__) + end + + def self.contents + @contents ||= File.read(bundled_path) + end + end +end diff --git a/lib/umodule/source/umodule.js b/lib/umodule/source/umodule.js new file mode 100644 index 0000000..ef7984f --- /dev/null +++ b/lib/umodule/source/umodule.js @@ -0,0 +1,70 @@ +// Generated by CoffeeScript 1.6.2 +/* +# umodule.js v0.5 +# (c) 2013 Loic Nageleisen +# Licensed under 3-clause BSD +*/ + + +(function() { + var Module, require, root, + __slice = [].slice; + + root = typeof global !== "undefined" && global !== null ? global : window; + + require = function(id) { + var item, target, _i, _len, _ref; + + target = Module.root; + _ref = id.split('/'); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + item = _ref[_i]; + target = target[item]; + } + if (typeof target === 'undefined') { + throw new Error("module not found: " + id); + } + return target.exports; + }; + + Module = (function() { + function Module(id) { + this.id = id; + this.exports = {}; + } + + Module.define = function(target, name, block) { + var item, top, _i, _len, _ref, _ref1; + + if (arguments.length < 3) { + _ref = [Module.root].concat(__slice.call(arguments)), target = _ref[0], name = _ref[1], block = _ref[2]; + } + top = target; + _ref1 = name.split('/'); + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + item = _ref1[_i]; + target = target[item] || (target[item] = new Module(item)); + } + block.call(target, target.exports, target.require, target); + return target; + }; + + Module.prototype.require = function() { + return require(); + }; + + return Module; + + })(); + + Module.root = new Module('root'); + + Module.root.exports = root; + + Module.root.module = new Module('module'); + + Module.root.module.exports = Module; + + root.require = require; + +}).call(this); diff --git a/umodule-source.gemspec b/umodule-source.gemspec new file mode 100644 index 0000000..cdf9060 --- /dev/null +++ b/umodule-source.gemspec @@ -0,0 +1,16 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path('../lib', __FILE__) +require 'umodule/source' + +Gem::Specification.new do |s| + s.name = 'umodule-source' + s.version = Umodule::Source::VERSION + s.authors = ['Loic Nageleisen'] + s.email = ['loic.nageleisen@gmail.com'] + s.homepage = 'http://github.com/lloeki/umodule-source' + s.summary = %q{uModule source as a Ruby gem.} + s.description = %q{uModule source as a Ruby gem.} + s.files = %W[ lib/umodule-source.rb + lib/umodule/source.rb + lib/umodule/source/umodule.js ] +end