railsy_backbone 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/LICENSE +51 -0
- data/README.md +28 -24
- data/Rakefile +29 -2
- data/lib/generators/{resource_helper.rb → backbone/helpers.rb} +1 -1
- data/lib/generators/backbone/install/install_generator.rb +20 -17
- data/lib/generators/backbone/install/templates/app.coffee +11 -0
- data/lib/railsy_backbone/version.rb +1 -1
- data/vendor/assets/javascripts/railsy_backbone.datalink.js +28 -0
- data/vendor/assets/javascripts/railsy_backbone.sync.js +43 -47
- metadata +69 -26
- data/MIT-LICENSE +0 -47
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bb1af4f0c455456434c50c08a1d5223423504b6b
         | 
| 4 | 
            +
              data.tar.gz: c1ae2f4fdff40e8cb05baac296e99e196bec3240
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 40ce46134b4a21e1a576a86625793b1431ae6bce5db3b5cea8b789fb203f85012590ef1f08b4f66f3807e2b0d9eaa7cd130f65b88ffef08abb32aaf75c83f4dd
         | 
| 7 | 
            +
              data.tar.gz: b4678c7c8ca149d574d62ac03d2c42a2edc88da9fe96f302b48a94365a528a3ef89373714ad0dcd207fc1484010b6821c527946ab1d5e8dfb739cc5c428f5c79
         | 
    
        data/CHANGELOG.md
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            ## 0.0.2
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            - changed license to BSD-3
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            - setup [travis ci](https://travis-ci.org/westonplatter/railsy_backbone)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            - application.js install generator is fully setup
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            - application.js install generator is full tested
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            - moved location of helpers.rb so it can be required
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            - setup test unit (much thanks to [Ryan Fitzgerald](https://twitter.com/TheRyanFitz))
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
            - updated gemspec for jquery-rails 3
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            - setup groc to document the project. docs available at 
         | 
| 19 | 
            +
            [http://westonplatter.github.io/railsy_backbone](http://westonplatter.github.io/railsy_backbone)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
             | 
| 22 | 
            +
            ## 0.0.1
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            - Updated jquery-rails to be 2.2.x compatible.
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            - Copied repo from https://github.com/codebrew/backbone-rails 
         | 
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            Copyright (c) 2013 Weston Platter
         | 
| 2 | 
            +
            All rights reserved.
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            (BSD-3 License)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Redistribution and use in source and binary forms, with or without
         | 
| 7 | 
            +
            modification, are permitted provided that the following conditions are met:
         | 
| 8 | 
            +
                * Redistributions of source code must retain the above copyright
         | 
| 9 | 
            +
                  notice, this list of conditions and the following disclaimer.
         | 
| 10 | 
            +
                * Redistributions in binary form must reproduce the above copyright
         | 
| 11 | 
            +
                  notice, this list of conditions and the following disclaimer in the
         | 
| 12 | 
            +
                  documentation and/or other materials provided with the distribution.
         | 
| 13 | 
            +
                * Neither the name of the <organization> nor the
         | 
| 14 | 
            +
                  names of its contributors may be used to endorse or promote products
         | 
| 15 | 
            +
                  derived from this software without specific prior written permission.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
         | 
| 18 | 
            +
            ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
         | 
| 19 | 
            +
            WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
         | 
| 20 | 
            +
            DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
         | 
| 21 | 
            +
            DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
         | 
| 22 | 
            +
            (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
         | 
| 23 | 
            +
            LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
         | 
| 24 | 
            +
            ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
         | 
| 25 | 
            +
            (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
         | 
| 26 | 
            +
            SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| 30 | 
            +
            For code pulled from https://github.com/codebrew/backbone-rails
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            Copyright 2011 Ryan Fitzgerald
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 35 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 36 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 37 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 38 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 39 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 40 | 
            +
            the following conditions:
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 43 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 46 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 47 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 48 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 49 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 50 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 51 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,35 +2,37 @@ | |
| 2 2 | 
             
            Backbone 1.0.0  
         | 
| 3 3 | 
             
            Underscore 1.5.1
         | 
| 4 4 |  | 
| 5 | 
            +
            [](https://travis-ci.org/westonplatter/railsy_backbone)
         | 
| 6 | 
            +
             | 
| 5 7 | 
             
            ## Features
         | 
| 6 8 |  | 
| 9 | 
            +
            1. [Nested Model Attributes](#nested-model-attributes)
         | 
| 10 | 
            +
            2. [Automatic Rails CSRF Integration](#automatic-rails-csrf-integration)
         | 
| 11 | 
            +
             | 
| 7 12 | 
             
            ### Nested Model Attributes
         | 
| 8 13 | 
             
            Allows you to specify a namespace for model attributes by defining a  ```paramRoot```  attribute. For example, 
         | 
| 9 14 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
            });
         | 
| 15 | 
            +
                var Book = Backbone.Model.extend({ 
         | 
| 16 | 
            +
                  url: '/books',
         | 
| 17 | 
            +
                  paramRoot: 'book'
         | 
| 18 | 
            +
                });
         | 
| 15 19 |  | 
| 16 | 
            -
            var book_instance = new Book({ 
         | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
            });
         | 
| 20 | 
            +
                var book_instance = new Book({ 
         | 
| 21 | 
            +
                  title:  'the illiad', 
         | 
| 22 | 
            +
                  author: 'homer'
         | 
| 23 | 
            +
                });
         | 
| 20 24 |  | 
| 21 | 
            -
            book_instance.sync();
         | 
| 22 | 
            -
            ```
         | 
| 25 | 
            +
                book_instance.sync();
         | 
| 23 26 |  | 
| 24 27 | 
             
            This will cause the HTTP POST to look like this, 
         | 
| 25 28 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
            ```
         | 
| 29 | 
            +
                Started POST "/books" for 127.0.0.1 at 2013-08-03 18:08:56 -0600
         | 
| 30 | 
            +
                  Processing by BooksController#create as JSON
         | 
| 31 | 
            +
                  Parameters: { "book" => { "title" => "the illiad", "author" => "homer" }}
         | 
| 32 | 
            +
             | 
| 31 33 |  | 
| 32 | 
            -
            ###  | 
| 33 | 
            -
             | 
| 34 | 
            +
            ### Automatic Rails CSRF Integration
         | 
| 35 | 
            +
            Automatically handles the Rails `authenticity_token`. Or, more technically, sets the  `xhr.setRequestHeader`  to the Rails CSRF token supplied in the HTML `header` meta tag.
         | 
| 34 36 |  | 
| 35 37 | 
             
            <br>
         | 
| 36 38 |  | 
| @@ -44,10 +46,12 @@ And then execute: | |
| 44 46 |  | 
| 45 47 | 
             
                $ bundle
         | 
| 46 48 |  | 
| 47 | 
            -
            ##  | 
| 49 | 
            +
            ## Docs
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            [Here's the link to our docs](http://westonplatter.github.io/railsy_backbone/).
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            __We really value clear communication__ (we're serious!). If you think something is missing in the docs, __please__ let us know via a GitHub issue ([create issues here](https://github.com/westonplatter/railsy_backbone/issues)), and we'll look at adding it. 
         | 
| 54 | 
            +
             | 
| 48 55 |  | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 52 | 
            -
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 53 | 
            -
            5. Create new Pull Request
         | 
| 56 | 
            +
            ## Credits
         | 
| 57 | 
            +
            See LICENSE
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -5,9 +5,12 @@ rescue LoadError | |
| 5 5 | 
             
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
             | 
| 8 | 
            +
            ENV['DUMMY_PATH'] = 'test/dummy'
         | 
| 9 | 
            +
            # ENV['ENGINE']
         | 
| 10 | 
            +
            # ENV['TEMPLATE']
         | 
| 11 | 
            +
            require 'rails/dummy/tasks'
         | 
| 9 12 |  | 
| 10 | 
            -
             | 
| 13 | 
            +
            require 'bundler/gem_tasks'
         | 
| 11 14 |  | 
| 12 15 | 
             
            namespace :backbone do
         | 
| 13 16 | 
             
              desc "Download the latest released versions of underscore and backbone.js"
         | 
| @@ -29,3 +32,27 @@ namespace :backbone do | |
| 29 32 | 
             
              end
         | 
| 30 33 | 
             
            end
         | 
| 31 34 |  | 
| 35 | 
            +
             | 
| 36 | 
            +
            # Check for the existence of an executable.
         | 
| 37 | 
            +
            def check(exec, name, url)
         | 
| 38 | 
            +
              return unless `which #{exec}`.empty?
         | 
| 39 | 
            +
              puts "#{name} not found.\nInstall it from #{url}"
         | 
| 40 | 
            +
              exit
         | 
| 41 | 
            +
            end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            desc 'build the docco documentation'
         | 
| 44 | 
            +
            task :doc do
         | 
| 45 | 
            +
              check 'groc', 'groc', 'https://github.com/nevir/groc'
         | 
| 46 | 
            +
              system 'groc'
         | 
| 47 | 
            +
            end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            require 'rake/testtask'
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            Rake::TestTask.new(:test) do |t|
         | 
| 52 | 
            +
              t.libs << 'lib'
         | 
| 53 | 
            +
              t.libs << 'test'
         | 
| 54 | 
            +
              t.pattern = 'test/**/*_test.rb'
         | 
| 55 | 
            +
              t.verbose = false
         | 
| 56 | 
            +
            end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            task :default => :test
         | 
| @@ -1,34 +1,37 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            require 'generators/backbone/helpers'
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Backbone
         | 
| 4 4 | 
             
              module Generators
         | 
| 5 5 | 
             
                class InstallGenerator < Rails::Generators::Base
         | 
| 6 | 
            -
                   | 
| 7 | 
            -
             | 
| 8 | 
            -
                   | 
| 6 | 
            +
                  include Backbone::Generators::Helpers
         | 
| 7 | 
            +
             
         | 
| 8 | 
            +
                  source_root File.expand_path("../templates", __FILE__)
         | 
| 9 9 |  | 
| 10 10 | 
             
                  desc "This generator installs backbone.js with a default folder layout in app/assets/javascripts/backbone"
         | 
| 11 11 |  | 
| 12 | 
            -
                   | 
| 13 | 
            -
                                           | 
| 12 | 
            +
                  class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
         | 
| 13 | 
            +
                                          :desc => "Skip Git ignores and keeps"
         | 
| 14 14 |  | 
| 15 15 | 
             
                  def inject_backbone
         | 
| 16 16 | 
             
                    inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
         | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 17 | 
            +
            "//= require underscore
         | 
| 18 | 
            +
            //= require backbone
         | 
| 19 | 
            +
            //= require railsy_backbone.sync
         | 
| 20 | 
            +
            //= require railsy_backbone.datalink
         | 
| 21 | 
            +
            //= require backbone/#{application_name.underscore}\n"
         | 
| 19 22 | 
             
                    end
         | 
| 20 23 | 
             
                  end
         | 
| 21 24 |  | 
| 22 | 
            -
                   | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
                   | 
| 25 | 
            +
                  def create_dir_layout
         | 
| 26 | 
            +
                    %W{routers models views templates}.each do |dir|
         | 
| 27 | 
            +
                      empty_directory "app/assets/javascripts/backbone/#{dir}" 
         | 
| 28 | 
            +
                      create_file "app/assets/javascripts/backbone/#{dir}/.gitkeep" unless options[:skip_git]
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                  end
         | 
| 28 31 |  | 
| 29 | 
            -
                   | 
| 30 | 
            -
             | 
| 31 | 
            -
                   | 
| 32 | 
            +
                  def create_app_file
         | 
| 33 | 
            +
                    template "app.coffee", "app/assets/javascripts/backbone/#{application_name.underscore}.js.coffee"
         | 
| 34 | 
            +
                  end
         | 
| 32 35 |  | 
| 33 36 | 
             
                end
         | 
| 34 37 | 
             
              end
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            // __NOTE:__ only overriding Backbone when `railsy_backbone (start) ... (end)` 
         | 
| 2 | 
            +
            // is explicitly called out.
         | 
| 3 | 
            +
            // 
         | 
| 4 | 
            +
            // Before addign this to the repo, I'd like to enable a configuration value to 
         | 
| 5 | 
            +
            // turn this feature on and off
         | 
| 6 | 
            +
            // 
         | 
| 7 | 
            +
            // 
         | 
| 8 | 
            +
            // (function($) {
         | 
| 9 | 
            +
            //   return $.extend($.fn, {
         | 
| 10 | 
            +
            //     backboneLink: function(model) {
         | 
| 11 | 
            +
            //       return $(this).find(":input").each(function() {
         | 
| 12 | 
            +
            //         var el, name;
         | 
| 13 | 
            +
            //         el = $(this);
         | 
| 14 | 
            +
            //         name = el.attr("name");
         | 
| 15 | 
            +
            //         model.bind("change:" + name, function() {
         | 
| 16 | 
            +
            //           return el.val(model.get(name));
         | 
| 17 | 
            +
            //         });
         | 
| 18 | 
            +
            //         return $(this).bind("change", function() {
         | 
| 19 | 
            +
            //           var attrs;
         | 
| 20 | 
            +
            //           el = $(this);
         | 
| 21 | 
            +
            //           attrs = {};
         | 
| 22 | 
            +
            //           attrs[el.attr("name")] = el.val();
         | 
| 23 | 
            +
            //           return model.set(attrs);
         | 
| 24 | 
            +
            //         });
         | 
| 25 | 
            +
            //       });
         | 
| 26 | 
            +
            //     }
         | 
| 27 | 
            +
            //   });
         | 
| 28 | 
            +
            // })(jQuery);
         | 
| @@ -1,10 +1,13 @@ | |
| 1 | 
            +
            // __NOTE:__ only overriding Backbone when `railsy_backbone (start) ... (end)` 
         | 
| 2 | 
            +
            // is explicitly called out.
         | 
| 3 | 
            +
            // 
         | 
| 4 | 
            +
            // Overriding Backbone.sync to implement,  
         | 
| 5 | 
            +
            // - Nested model attributes  
         | 
| 6 | 
            +
            // - Rails CSFR Integration  
         | 
| 7 | 
            +
            // 
         | 
| 1 8 | 
             
            ( function($){
         | 
| 2 9 |  | 
| 3 | 
            -
              // Backbone.sync
         | 
| 4 | 
            -
              // -------------
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              // Need to define the methodMap since it's called from within Backbone.sync
         | 
| 7 | 
            -
              //
         | 
| 10 | 
            +
              // Define `methodMap` since it's called from within Backbone.sync
         | 
| 8 11 | 
             
              var methodMap = {
         | 
| 9 12 | 
             
                  'create': 'POST',
         | 
| 10 13 | 
             
                  'update': 'PUT',
         | 
| @@ -17,33 +20,6 @@ | |
| 17 20 | 
             
                throw new Error("A 'url' property or function must be specified");
         | 
| 18 21 | 
             
              };
         | 
| 19 22 |  | 
| 20 | 
            -
              // Overriding Backbone.sync to nest model attributes in within the paramRoot
         | 
| 21 | 
            -
              // key-value JSON hashmap.
         | 
| 22 | 
            -
              // 
         | 
| 23 | 
            -
              // For example, when saving a new Model, 
         | 
| 24 | 
            -
              //
         | 
| 25 | 
            -
              //   var Book = Backbone.Model.extend({ 
         | 
| 26 | 
            -
              //     url: '/books',
         | 
| 27 | 
            -
              //     paramRoot: 'book'
         | 
| 28 | 
            -
              //   });
         | 
| 29 | 
            -
              // 
         | 
| 30 | 
            -
              //   var book_instance = new Book({ 
         | 
| 31 | 
            -
              //     title:  'the illiad', 
         | 
| 32 | 
            -
              //     author: 'homer'
         | 
| 33 | 
            -
              //   });
         | 
| 34 | 
            -
              //
         | 
| 35 | 
            -
              //   book_instance.sync();
         | 
| 36 | 
            -
              //
         | 
| 37 | 
            -
              // This will cause the HTTP POST to look like this, 
         | 
| 38 | 
            -
              //
         | 
| 39 | 
            -
              // Started POST "/books" for 127.0.0.1 at 2013-08-03 18:08:56 -0600
         | 
| 40 | 
            -
              //   Processing by BooksController#create as JSON
         | 
| 41 | 
            -
              //   Parameters: { "book" => { "title" => "the illiad", "author" => "homer" }}
         | 
| 42 | 
            -
              // 
         | 
| 43 | 
            -
              //
         | 
| 44 | 
            -
              // Everything that is not explicitly called out as **railys_backbone** code, is
         | 
| 45 | 
            -
              // unmodified Backbone code.
         | 
| 46 | 
            -
              // 
         | 
| 47 23 | 
             
              Backbone.sync = function(method, model, options) {
         | 
| 48 24 | 
             
                var type = methodMap[method];
         | 
| 49 25 |  | 
| @@ -61,9 +37,10 @@ | |
| 61 37 | 
             
                  params.url = _.result(model, 'url') || urlError();
         | 
| 62 38 | 
             
                }
         | 
| 63 39 |  | 
| 64 | 
            -
                // =========================================================================
         | 
| 65 | 
            -
                // railsy_backbone
         | 
| 66 40 | 
             
                // -------------------------------------------------------------------------
         | 
| 41 | 
            +
                // railsy_backbone (start)  
         | 
| 42 | 
            +
                // __Rails CSFR Integration__  
         | 
| 43 | 
            +
                // 
         | 
| 67 44 | 
             
                // include the Rails CSRF token on HTTP PUTs/POSTs    
         | 
| 68 45 | 
             
                // 
         | 
| 69 46 | 
             
                if(!options.noCSRF){
         | 
| @@ -76,35 +53,54 @@ | |
| 76 53 | 
             
                    if (beforeSend) return beforeSend.apply(this, arguments);
         | 
| 77 54 | 
             
                  };
         | 
| 78 55 | 
             
                }
         | 
| 79 | 
            -
                //  | 
| 56 | 
            +
                // railsy_backbone (end)
         | 
| 57 | 
            +
                // 
         | 
| 58 | 
            +
                // -------------------------------------------------------------------------
         | 
| 80 59 |  | 
| 81 60 | 
             
                // Ensure that we have the appropriate request data.
         | 
| 82 61 | 
             
                if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
         | 
| 83 62 | 
             
                  params.contentType = 'application/json';
         | 
| 84 63 |  | 
| 85 | 
            -
                  // =======================================================================
         | 
| 86 | 
            -
                  // railsy_backbone
         | 
| 87 64 | 
             
                  // -----------------------------------------------------------------------
         | 
| 88 | 
            -
                  //  | 
| 65 | 
            +
                  // railsy_backbone (start)  
         | 
| 66 | 
            +
                  // __Nested Model Attributes__  
         | 
| 89 67 | 
             
                  // 
         | 
| 90 | 
            -
                  // | 
| 68 | 
            +
                  // If Backbone.Model defines `paramRoot`, then store model attributes 
         | 
| 69 | 
            +
                  // within `paramRoot` key-value pair. For example, book attributes 
         | 
| 70 | 
            +
                  // (`title`, `author`) are nested within `book` key-value pair,
         | 
| 71 | 
            +
                  // 
         | 
| 72 | 
            +
                  //      var Book = Backbone.Model.extend({ 
         | 
| 73 | 
            +
                  //        url: '/books',
         | 
| 74 | 
            +
                  //        paramRoot: 'book' 
         | 
| 75 | 
            +
                  //      });
         | 
| 76 | 
            +
                  // 
         | 
| 77 | 
            +
                  //      var book_instance = new Book({ 
         | 
| 78 | 
            +
                  //        title:  'the illiad', 
         | 
| 79 | 
            +
                  //        author: 'homer'
         | 
| 80 | 
            +
                  //      });
         | 
| 81 | 
            +
                  // 
         | 
| 82 | 
            +
                  // The resulting HTTP POST looks like this,
         | 
| 83 | 
            +
                  // 
         | 
| 84 | 
            +
                  //      book_instance.sync();
         | 
| 85 | 
            +
                  // 
         | 
| 86 | 
            +
                  //      Started POST "/books" for 127.0.0.1
         | 
| 87 | 
            +
                  //        Processing by BooksController#create as JSON
         | 
| 88 | 
            +
                  //        { "book" => { "title" => "the illiad", "author" => "home" } }
         | 
| 91 89 | 
             
                  // 
         | 
| 92 | 
            -
                  
         | 
| 93 90 | 
             
                  if(model.paramRoot) {
         | 
| 94 91 | 
             
                    var model_attributes = {}
         | 
| 95 92 | 
             
                    model_attributes[model.paramRoot] = model.toJSON(options);
         | 
| 96 93 | 
             
                    params.data = JSON.stringify(options.attrs || model_attributes );
         | 
| 97 94 | 
             
                  } else {
         | 
| 95 | 
            +
                    // If model does not define a `paramRoot`, use the original Backbone 
         | 
| 96 | 
            +
                    // implementation
         | 
| 98 97 | 
             
                    params.data = JSON.stringify(options.attrs || model.toJSON(options) );
         | 
| 99 98 | 
             
                  }
         | 
| 100 | 
            -
                  
         | 
| 101 | 
            -
                  //  | 
| 102 | 
            -
                  //  | 
| 103 | 
            -
                  //
         | 
| 104 | 
            -
                  // params.data = JSON.stringify(options.attrs || model.toJSON(options) );
         | 
| 105 | 
            -
                  //
         | 
| 106 | 
            -
                  // =========================================================================
         | 
| 99 | 
            +
                  // railsy_backbone (end)  
         | 
| 100 | 
            +
                  // 
         | 
| 101 | 
            +
                  // -----------------------------------------------------------------------
         | 
| 107 102 | 
             
                }
         | 
| 103 | 
            +
                
         | 
| 108 104 |  | 
| 109 105 | 
             
                // For older servers, emulate JSON by encoding the request into an HTML-form.
         | 
| 110 106 | 
             
                if (options.emulateJSON) {
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: railsy_backbone
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Weston Platter
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013- | 
| 11 | 
            +
            date: 2013-09-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         | 
| @@ -28,30 +28,30 @@ dependencies: | |
| 28 28 | 
             
              name: coffee-script
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - -  | 
| 31 | 
            +
                - - '>='
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version:  | 
| 33 | 
            +
                    version: '0'
         | 
| 34 34 | 
             
              type: :runtime
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - -  | 
| 38 | 
            +
                - - '>='
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version:  | 
| 40 | 
            +
                    version: '0'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: jquery-rails
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 | 
            -
                - -  | 
| 45 | 
            +
                - - '>='
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version:  | 
| 47 | 
            +
                    version: '0'
         | 
| 48 48 | 
             
              type: :runtime
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 52 | 
            +
                - - '>='
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version:  | 
| 54 | 
            +
                    version: '0'
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 56 | 
             
              name: ejs
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -70,16 +70,16 @@ dependencies: | |
| 70 70 | 
             
              name: bundler
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 | 
            -
                - -  | 
| 73 | 
            +
                - - '>='
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: ' | 
| 75 | 
            +
                    version: '0'
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 | 
            -
                - -  | 
| 80 | 
            +
                - - '>='
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: ' | 
| 82 | 
            +
                    version: '0'
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: rake
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -98,16 +98,16 @@ dependencies: | |
| 98 98 | 
             
              name: rails
         | 
| 99 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 100 | 
             
                requirements:
         | 
| 101 | 
            -
                - -  | 
| 101 | 
            +
                - - '>='
         | 
| 102 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            -
                    version:  | 
| 103 | 
            +
                    version: '0'
         | 
| 104 104 | 
             
              type: :development
         | 
| 105 105 | 
             
              prerelease: false
         | 
| 106 106 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 107 | 
             
                requirements:
         | 
| 108 | 
            -
                - -  | 
| 108 | 
            +
                - - '>='
         | 
| 109 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            -
                    version:  | 
| 110 | 
            +
                    version: '0'
         | 
| 111 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 112 112 | 
             
              name: sqlite3
         | 
| 113 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -150,27 +150,71 @@ dependencies: | |
| 150 150 | 
             
                - - '>='
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 152 | 
             
                    version: '0'
         | 
| 153 | 
            -
             | 
| 154 | 
            -
               | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: minitest
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - '>='
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '0'
         | 
| 160 | 
            +
              type: :development
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - '>='
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '0'
         | 
| 167 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            +
              name: rails-dummy
         | 
| 169 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 | 
            +
                requirements:
         | 
| 171 | 
            +
                - - '>='
         | 
| 172 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            +
                    version: '0'
         | 
| 174 | 
            +
              type: :development
         | 
| 175 | 
            +
              prerelease: false
         | 
| 176 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 | 
            +
                requirements:
         | 
| 178 | 
            +
                - - '>='
         | 
| 179 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                    version: '0'
         | 
| 181 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 182 | 
            +
              name: mocha
         | 
| 183 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 184 | 
            +
                requirements:
         | 
| 185 | 
            +
                - - '>='
         | 
| 186 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 187 | 
            +
                    version: '0'
         | 
| 188 | 
            +
              type: :development
         | 
| 189 | 
            +
              prerelease: false
         | 
| 190 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 191 | 
            +
                requirements:
         | 
| 192 | 
            +
                - - '>='
         | 
| 193 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 194 | 
            +
                    version: '0'
         | 
| 195 | 
            +
            description: Inspired by backbone-rails with testing & updated Backbone
         | 
| 155 196 | 
             
            email:
         | 
| 156 197 | 
             
            - westonplatter@gmail.com
         | 
| 157 198 | 
             
            executables: []
         | 
| 158 199 | 
             
            extensions: []
         | 
| 159 200 | 
             
            extra_rdoc_files: []
         | 
| 160 201 | 
             
            files:
         | 
| 202 | 
            +
            - lib/generators/backbone/helpers.rb
         | 
| 161 203 | 
             
            - lib/generators/backbone/install/install_generator.rb
         | 
| 162 | 
            -
            - lib/generators/ | 
| 204 | 
            +
            - lib/generators/backbone/install/templates/app.coffee
         | 
| 163 205 | 
             
            - lib/railsy_backbone/version.rb
         | 
| 164 206 | 
             
            - lib/railsy_backbone.rb
         | 
| 165 207 | 
             
            - vendor/assets/javascripts/backbone.js
         | 
| 208 | 
            +
            - vendor/assets/javascripts/railsy_backbone.datalink.js
         | 
| 166 209 | 
             
            - vendor/assets/javascripts/railsy_backbone.sync.js
         | 
| 167 210 | 
             
            - vendor/assets/javascripts/underscore.js
         | 
| 168 | 
            -
            -  | 
| 211 | 
            +
            - LICENSE
         | 
| 169 212 | 
             
            - Rakefile
         | 
| 170 213 | 
             
            - README.md
         | 
| 214 | 
            +
            - CHANGELOG.md
         | 
| 171 215 | 
             
            homepage: http://github.com/westonplatter/railsy_backbone
         | 
| 172 216 | 
             
            licenses:
         | 
| 173 | 
            -
            -  | 
| 217 | 
            +
            - BSD-3
         | 
| 174 218 | 
             
            metadata: {}
         | 
| 175 219 | 
             
            post_install_message: 
         | 
| 176 220 | 
             
            rdoc_options: []
         | 
| @@ -188,9 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 188 232 | 
             
                  version: '0'
         | 
| 189 233 | 
             
            requirements: []
         | 
| 190 234 | 
             
            rubyforge_project: 
         | 
| 191 | 
            -
            rubygems_version: 2.0. | 
| 235 | 
            +
            rubygems_version: 2.0.6
         | 
| 192 236 | 
             
            signing_key: 
         | 
| 193 237 | 
             
            specification_version: 4
         | 
| 194 | 
            -
            summary:  | 
| 195 | 
            -
              Backbone
         | 
| 238 | 
            +
            summary: Inspired by backbone-rails with testing & updated Backbone
         | 
| 196 239 | 
             
            test_files: []
         | 
    
        data/MIT-LICENSE
    DELETED
    
    | @@ -1,47 +0,0 @@ | |
| 1 | 
            -
            Copyright (c) 2013 Weston Platter
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            MIT License
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            -
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            -
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            -
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            -
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            -
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            -
            the following conditions:
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            -
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            -
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            -
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            -
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            -
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            -
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            -
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
            For code pulled from https://github.com/codebrew/backbone-rails
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            Copyright 2011 Ryan Fitzgerald
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 31 | 
            -
            a copy of this software and associated documentation files (the
         | 
| 32 | 
            -
            "Software"), to deal in the Software without restriction, including
         | 
| 33 | 
            -
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 34 | 
            -
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 35 | 
            -
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 36 | 
            -
            the following conditions:
         | 
| 37 | 
            -
             | 
| 38 | 
            -
            The above copyright notice and this permission notice shall be
         | 
| 39 | 
            -
            included in all copies or substantial portions of the Software.
         | 
| 40 | 
            -
             | 
| 41 | 
            -
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 42 | 
            -
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 43 | 
            -
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 44 | 
            -
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 45 | 
            -
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 46 | 
            -
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 47 | 
            -
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         |