codus 0.0.1.6 → 0.0.1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascript/yojs/README.md +55 -0
 - data/app/assets/javascript/yojs/yojs.js +70 -0
 - data/codus.gemspec +16 -1
 - data/lib/codus/version.rb +1 -1
 - metadata +4 -2
 
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            yojs
         
     | 
| 
      
 2 
     | 
    
         
            +
            =====
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Javascript library for declaring and calling functions and variables using namespaces.
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Usage
         
     | 
| 
      
 7 
     | 
    
         
            +
            --------------------
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Function definition: 
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ```javascript
         
     | 
| 
      
 12 
     | 
    
         
            +
            yojs.define("yojs_test", function() {
         
     | 
| 
      
 13 
     | 
    
         
            +
              //your code goes here
         
     | 
| 
      
 14 
     | 
    
         
            +
            });
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            yojs.define("yojs_test.comments.new", function() {
         
     | 
| 
      
 17 
     | 
    
         
            +
              //your code goes here
         
     | 
| 
      
 18 
     | 
    
         
            +
            });
         
     | 
| 
      
 19 
     | 
    
         
            +
            ```
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            Function call:
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ```javascript
         
     | 
| 
      
 24 
     | 
    
         
            +
            yojs.call("yojs_test");
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            yojs.call("yojs_test.comments.new");
         
     | 
| 
      
 27 
     | 
    
         
            +
            ```
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Store objects and values:
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            ```javascript
         
     | 
| 
      
 32 
     | 
    
         
            +
            yojs.set("yojs_test.my_value", 42);
         
     | 
| 
      
 33 
     | 
    
         
            +
            yojs.set("yojs_test.ns2.n3.my_json", { foo: "bar"} );
         
     | 
| 
      
 34 
     | 
    
         
            +
            ```
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            Retrieve stored object and values:
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            ```javascript
         
     | 
| 
      
 39 
     | 
    
         
            +
            var value = yojs.get("yojs_test.my_value");
         
     | 
| 
      
 40 
     | 
    
         
            +
            var json = yojs.get("yojs_test.ns2.n3.my_json");
         
     | 
| 
      
 41 
     | 
    
         
            +
            ```
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            Namespace lookup:
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            ```javascript
         
     | 
| 
      
 46 
     | 
    
         
            +
            yojs.define("my.deep.namespace.teste", function() {
         
     | 
| 
      
 47 
     | 
    
         
            +
              yojs.call("itworks");
         
     | 
| 
      
 48 
     | 
    
         
            +
            });
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            yojs.define("my.deep.namespace.itworks", function() {
         
     | 
| 
      
 51 
     | 
    
         
            +
              console.log("yay");
         
     | 
| 
      
 52 
     | 
    
         
            +
            });
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            yojs.call("my.deep.namespace.teste") // -> yay
         
     | 
| 
      
 55 
     | 
    
         
            +
            ```
         
     | 
| 
         @@ -0,0 +1,70 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // git@github.com:codus/yojs.git
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Version: 0.0.1
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            if(!Array.prototype.last) {
         
     | 
| 
      
 5 
     | 
    
         
            +
              Array.prototype.last = function() {
         
     | 
| 
      
 6 
     | 
    
         
            +
                return this[this.length - 1];
         
     | 
| 
      
 7 
     | 
    
         
            +
              }
         
     | 
| 
      
 8 
     | 
    
         
            +
            }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            var yojs = (function(){
         
     | 
| 
      
 11 
     | 
    
         
            +
              var nameFunctionHash = {};
         
     | 
| 
      
 12 
     | 
    
         
            +
              var parentsNamespaces = [];
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              var getNameSpaceResult = function(namespace, arguments) {
         
     | 
| 
      
 15 
     | 
    
         
            +
                if (typeof(nameFunctionHash[namespace]) == 'function') {
         
     | 
| 
      
 16 
     | 
    
         
            +
                  return nameFunctionHash[namespace].apply(this, arguments);
         
     | 
| 
      
 17 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 18 
     | 
    
         
            +
                  return nameFunctionHash[namespace];
         
     | 
| 
      
 19 
     | 
    
         
            +
                }
         
     | 
| 
      
 20 
     | 
    
         
            +
              }
         
     | 
| 
      
 21 
     | 
    
         
            +
              return {
         
     | 
| 
      
 22 
     | 
    
         
            +
                define: function(namespace, value) {
         
     | 
| 
      
 23 
     | 
    
         
            +
                  if (this.isDefined(namespace)) {
         
     | 
| 
      
 24 
     | 
    
         
            +
                    var errorMessage = "Error: trying to define namespace '" + namespace + "'' twice";
         
     | 
| 
      
 25 
     | 
    
         
            +
                    throw errorMessage;
         
     | 
| 
      
 26 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 27 
     | 
    
         
            +
                    nameFunctionHash[namespace] = value;
         
     | 
| 
      
 28 
     | 
    
         
            +
                  }
         
     | 
| 
      
 29 
     | 
    
         
            +
                  return;
         
     | 
| 
      
 30 
     | 
    
         
            +
                },
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                set: function(namespace, value) {
         
     | 
| 
      
 33 
     | 
    
         
            +
                  nameFunctionHash[namespace] = value;
         
     | 
| 
      
 34 
     | 
    
         
            +
                },
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                call: function(namespace){
         
     | 
| 
      
 37 
     | 
    
         
            +
                  var parentNamespaceArray = namespace.split(".");
         
     | 
| 
      
 38 
     | 
    
         
            +
                  var lastNameCalled = parentNamespaceArray.pop();
         
     | 
| 
      
 39 
     | 
    
         
            +
                  var currentParentNamespace = parentNamespaceArray.join(".");
         
     | 
| 
      
 40 
     | 
    
         
            +
                  var returnValue = null;
         
     | 
| 
      
 41 
     | 
    
         
            +
                  var lastParentNamespace = parentsNamespaces.last();
         
     | 
| 
      
 42 
     | 
    
         
            +
                  var functionWithLastParentClassNamespace = lastParentNamespace + "." + lastNameCalled;
         
     | 
| 
      
 43 
     | 
    
         
            +
                  var errorMessage = "";
         
     | 
| 
      
 44 
     | 
    
         
            +
                  var calledFunctionArguments = Array.prototype.slice.apply(arguments, [1]);
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  parentsNamespaces.push(currentParentNamespace);
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  if (this.isDefined(namespace)) {
         
     | 
| 
      
 49 
     | 
    
         
            +
                    returnValue = getNameSpaceResult(namespace, calledFunctionArguments);
         
     | 
| 
      
 50 
     | 
    
         
            +
                  } else if (this.isDefined(functionWithLastParentClassNamespace)) {
         
     | 
| 
      
 51 
     | 
    
         
            +
                    returnValue = getNameSpaceResult(functionWithLastParentClassNamespace, calledFunctionArguments);
         
     | 
| 
      
 52 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 53 
     | 
    
         
            +
                    var errorMessage = "Error: called namespace '" + namespace + "'. But it doesn't exist.";
         
     | 
| 
      
 54 
     | 
    
         
            +
                    throw errorMessage;
         
     | 
| 
      
 55 
     | 
    
         
            +
                  }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  parentsNamespaces.pop();
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  return returnValue;
         
     | 
| 
      
 60 
     | 
    
         
            +
                },
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                get: function(namespace) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                  return this.call(namespace);
         
     | 
| 
      
 64 
     | 
    
         
            +
                }, 
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                isDefined: function(namespace) {
         
     | 
| 
      
 67 
     | 
    
         
            +
                  return nameFunctionHash.hasOwnProperty(namespace);
         
     | 
| 
      
 68 
     | 
    
         
            +
                }  
         
     | 
| 
      
 69 
     | 
    
         
            +
              } 
         
     | 
| 
      
 70 
     | 
    
         
            +
            }());
         
     | 
    
        data/codus.gemspec
    CHANGED
    
    | 
         @@ -15,7 +15,22 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       15 
15 
     | 
    
         
             
              spec.homepage      = "https://github.com/codus/codus"
         
     | 
| 
       16 
16 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
              spec 
     | 
| 
      
 18 
     | 
    
         
            +
              # normal spec stuff above
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.files = `git ls-files`.split("\n")
         
     | 
| 
      
 20 
     | 
    
         
            +
             
         
     | 
| 
      
 21 
     | 
    
         
            +
              # get an array of submodule dirs by executing 'pwd' inside each submodule
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
         
     | 
| 
      
 23 
     | 
    
         
            +
              `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
         
     | 
| 
      
 24 
     | 
    
         
            +
                Dir.chdir(submodule_path) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  submodule_relative_path = submodule_path.sub gem_dir, ""
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # issue git ls-files in submodule's directory and
         
     | 
| 
      
 27 
     | 
    
         
            +
                  # prepend the submodule path to create absolute file paths
         
     | 
| 
      
 28 
     | 
    
         
            +
                  `git ls-files`.split($\).each do |filename|
         
     | 
| 
      
 29 
     | 
    
         
            +
                    spec.files << "#{submodule_relative_path}/#{filename}"
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       19 
34 
     | 
    
         
             
              spec.executables  = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
         
     | 
| 
       20 
35 
     | 
    
         
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
       21 
36 
     | 
    
         
             
              spec.require_paths = ["lib"]
         
     | 
    
        data/lib/codus/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: codus
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0.1.6
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1.6.1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013-07- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-07-30 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -68,6 +68,8 @@ files: 
     | 
|
| 
       68 
68 
     | 
    
         
             
            - spec/codus/view_helpers/yojs_helper_spec.rb
         
     | 
| 
       69 
69 
     | 
    
         
             
            - spec/codus/view_helpers_spec.rb
         
     | 
| 
       70 
70 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - app/assets/javascript/yojs/README.md
         
     | 
| 
      
 72 
     | 
    
         
            +
            - app/assets/javascript/yojs/yojs.js
         
     | 
| 
       71 
73 
     | 
    
         
             
            homepage: https://github.com/codus/codus
         
     | 
| 
       72 
74 
     | 
    
         
             
            licenses:
         
     | 
| 
       73 
75 
     | 
    
         
             
            - MIT
         
     |