acts_as_citable 3.0.0 → 4.0.0
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/lib/acts_as_citable/version.rb +1 -1
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/test_controller.rb +7 -5
- data/test/dummy/config/environments/production.rb +1 -1
- data/test/dummy/config/environments/test.rb +3 -1
- data/test/dummy/config/locales/responders.en.yml +12 -0
- data/test/dummy/lib/application_responder.rb +8 -0
- data/test/dummy/log/test.log +7102 -0
- data/test/dummy/test/functional/test_controller_test.rb +18 -18
- data/test/dummy/test/unit/inherited_record_test.rb +0 -8
- data/test/dummy/test/unit/record_changed_field_test.rb +0 -7
- data/test/dummy/test/unit/record_test.rb +0 -7
- metadata +9 -7
- data/lib/acts_as_citable/mime_types.rb +0 -4
- data/lib/acts_as_citable/renderers.rb +0 -32
| @@ -1,22 +1,22 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            class TestControllerTest < ActionController::TestCase
         | 
| 4 | 
            -
              test "should respond to bibtex" do
         | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
              test "should respond to bib" do
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
              test "should respond to ris" do
         | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
              test "should not respond to arbitrary format" do
         | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
              end
         | 
| 4 | 
            +
              # test "should respond to bibtex" do
         | 
| 5 | 
            +
              #   get :test, :format => "bibtex"
         | 
| 6 | 
            +
              #   assert_response :success
         | 
| 7 | 
            +
              # end
         | 
| 8 | 
            +
              # test "should respond to bib" do
         | 
| 9 | 
            +
              #   get :test, :format => "bib"
         | 
| 10 | 
            +
              #   assert_response :success
         | 
| 11 | 
            +
              # end
         | 
| 12 | 
            +
              # test "should respond to ris" do
         | 
| 13 | 
            +
              #   get :test, :format => "ris"
         | 
| 14 | 
            +
              #   assert_response :success
         | 
| 15 | 
            +
              # end
         | 
| 16 | 
            +
              # test "should not respond to arbitrary format" do
         | 
| 17 | 
            +
              #   assert_raise ActionController::UnknownFormat do
         | 
| 18 | 
            +
              #     get :test, :format => "bugaboo"
         | 
| 19 | 
            +
              #     assert_response :not_acceptable
         | 
| 20 | 
            +
              #   end
         | 
| 21 | 
            +
              # end
         | 
| 22 22 | 
             
            end
         | 
| @@ -65,14 +65,6 @@ class InheritedRecordTest < ActiveSupport::TestCase | |
| 65 65 | 
             
                assert rec.destroy
         | 
| 66 66 | 
             
              end
         | 
| 67 67 |  | 
| 68 | 
            -
              test "arrays should be able to convert to ris and bibtex" do
         | 
| 69 | 
            -
                arr = Array.new
         | 
| 70 | 
            -
                arr << InheritedRecord.new(:data => "itemType: book", :format => "csf") << InheritedRecord.create(:data => "itemType: book", :format => "csf")
         | 
| 71 | 
            -
                assert arr.to_bibtex
         | 
| 72 | 
            -
                assert arr.to_ris
         | 
| 73 | 
            -
                arr.each {|rec| assert rec.destroy}
         | 
| 74 | 
            -
              end
         | 
| 75 | 
            -
             | 
| 76 68 | 
             
              test "should be able to convert to an export STYLE" do
         | 
| 77 69 | 
             
                rec = InheritedRecord.new(:data => "itemType: book", :format => "csf")
         | 
| 78 70 | 
             
                assert_equal "<div class=\"csl-bib-body\">\n  <div class=\"csl-entry\"> (n.d.).</div>\n</div>", rec.to_apa
         | 
| @@ -56,13 +56,6 @@ class RecordChangedFieldTest < ActiveSupport::TestCase | |
| 56 56 | 
             
                assert rec.destroy
         | 
| 57 57 | 
             
              end
         | 
| 58 58 |  | 
| 59 | 
            -
              test "arrays should be able to convert to ris and bibtex" do
         | 
| 60 | 
            -
                arr = Array.new
         | 
| 61 | 
            -
                arr << RecordChangedField.new(:data => "itemType: book", :from_format => "csf") << RecordChangedField.create(:data => "itemType: book", :from_format => "csf")
         | 
| 62 | 
            -
                assert arr.to_bibtex
         | 
| 63 | 
            -
                assert arr.to_ris
         | 
| 64 | 
            -
                arr.each {|rec| assert rec.destroy}
         | 
| 65 | 
            -
              end
         | 
| 66 59 |  | 
| 67 60 | 
             
              test "should be able to convert to an export STYLE" do
         | 
| 68 61 | 
             
                rec = RecordChangedField.new(:data => "itemType: book", :from_format => "csf")
         | 
| @@ -56,13 +56,6 @@ class RecordTest < ActiveSupport::TestCase | |
| 56 56 | 
             
                assert rec.destroy
         | 
| 57 57 | 
             
              end
         | 
| 58 58 |  | 
| 59 | 
            -
              test "arrays should be able to convert to ris and bibtex" do
         | 
| 60 | 
            -
                arr = Array.new
         | 
| 61 | 
            -
                arr << Record.new(:data => "itemType: book", :format => "csf") << Record.create(:data => "itemType: book", :format => "csf")
         | 
| 62 | 
            -
                assert arr.to_bibtex
         | 
| 63 | 
            -
                assert arr.to_ris
         | 
| 64 | 
            -
                arr.each {|rec| assert rec.destroy}
         | 
| 65 | 
            -
              end
         | 
| 66 59 |  | 
| 67 60 | 
             
              test "should be able to convert to an export STYLE" do
         | 
| 68 61 | 
             
                rec = Record.new(:data => "itemType: book", :format => "csf")
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: acts_as_citable
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 4.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - hab278
         | 
| @@ -16,18 +16,18 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - '>='
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 4.0.0
         | 
| 20 20 | 
             
                - - <
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            -
                    version: ' | 
| 22 | 
            +
                    version: '5'
         | 
| 23 23 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 24 24 | 
             
                requirements:
         | 
| 25 25 | 
             
                - - '>='
         | 
| 26 26 | 
             
                  - !ruby/object:Gem::Version
         | 
| 27 | 
            -
                    version:  | 
| 27 | 
            +
                    version: 4.0.0
         | 
| 28 28 | 
             
                - - <
         | 
| 29 29 | 
             
                  - !ruby/object:Gem::Version
         | 
| 30 | 
            -
                    version: ' | 
| 30 | 
            +
                    version: '5'
         | 
| 31 31 | 
             
              prerelease: false
         | 
| 32 32 | 
             
              type: :runtime
         | 
| 33 33 | 
             
            - !ruby/object:Gem::Dependency
         | 
| @@ -179,8 +179,6 @@ extra_rdoc_files: [] | |
| 179 179 | 
             
            files:
         | 
| 180 180 | 
             
            - lib/acts_as_citable.rb
         | 
| 181 181 | 
             
            - lib/acts_as_citable/base.rb
         | 
| 182 | 
            -
            - lib/acts_as_citable/mime_types.rb
         | 
| 183 | 
            -
            - lib/acts_as_citable/renderers.rb
         | 
| 184 182 | 
             
            - lib/acts_as_citable/version.rb
         | 
| 185 183 | 
             
            - lib/tasks/acts_as_citable_tasks.rake
         | 
| 186 184 | 
             
            - MIT-LICENSE
         | 
| @@ -221,11 +219,13 @@ files: | |
| 221 219 | 
             
            - test/dummy/config/initializers/session_store.rb
         | 
| 222 220 | 
             
            - test/dummy/config/initializers/wrap_parameters.rb
         | 
| 223 221 | 
             
            - test/dummy/config/locales/en.yml
         | 
| 222 | 
            +
            - test/dummy/config/locales/responders.en.yml
         | 
| 224 223 | 
             
            - test/dummy/db/development.sqlite3
         | 
| 225 224 | 
             
            - test/dummy/db/schema.rb
         | 
| 226 225 | 
             
            - test/dummy/db/test.sqlite3
         | 
| 227 226 | 
             
            - test/dummy/db/migrate/20130221210429_create_records.rb
         | 
| 228 227 | 
             
            - test/dummy/db/migrate/20130221214225_create_record_changed_fields.rb
         | 
| 228 | 
            +
            - test/dummy/lib/application_responder.rb
         | 
| 229 229 | 
             
            - test/dummy/log/development.log
         | 
| 230 230 | 
             
            - test/dummy/log/test.log
         | 
| 231 231 | 
             
            - test/dummy/public/404.html
         | 
| @@ -298,11 +298,13 @@ test_files: | |
| 298 298 | 
             
            - test/dummy/config/initializers/session_store.rb
         | 
| 299 299 | 
             
            - test/dummy/config/initializers/wrap_parameters.rb
         | 
| 300 300 | 
             
            - test/dummy/config/locales/en.yml
         | 
| 301 | 
            +
            - test/dummy/config/locales/responders.en.yml
         | 
| 301 302 | 
             
            - test/dummy/db/development.sqlite3
         | 
| 302 303 | 
             
            - test/dummy/db/schema.rb
         | 
| 303 304 | 
             
            - test/dummy/db/test.sqlite3
         | 
| 304 305 | 
             
            - test/dummy/db/migrate/20130221210429_create_records.rb
         | 
| 305 306 | 
             
            - test/dummy/db/migrate/20130221214225_create_record_changed_fields.rb
         | 
| 307 | 
            +
            - test/dummy/lib/application_responder.rb
         | 
| 306 308 | 
             
            - test/dummy/log/development.log
         | 
| 307 309 | 
             
            - test/dummy/log/test.log
         | 
| 308 310 | 
             
            - test/dummy/public/404.html
         | 
| @@ -1,32 +0,0 @@ | |
| 1 | 
            -
            class Array
         | 
| 2 | 
            -
              # Allow array of objects to be translated to ris
         | 
| 3 | 
            -
              def to_ris
         | 
| 4 | 
            -
                 self.collect { |r| r.to_ris if r.respond_to? :to_ris}.join("\n\n")
         | 
| 5 | 
            -
               end
         | 
| 6 | 
            -
             | 
| 7 | 
            -
               # Allow array of objects to be translated to ris
         | 
| 8 | 
            -
               def to_bibtex
         | 
| 9 | 
            -
                 self.collect { |r| r.to_bibtex if r.respond_to? :to_bibtex }.join("\n\n")
         | 
| 10 | 
            -
               end
         | 
| 11 | 
            -
            end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            # Adds a renderer for RIS.
         | 
| 14 | 
            -
            ActionController::Renderers.add :ris do |ris, options|
         | 
| 15 | 
            -
              ris = ris.first if ris.is_a? Array and ris.count == 1
         | 
| 16 | 
            -
              filename = (ris.respond_to?(:to_param) and ris.class.respond_to?(:acts_as_citable)) ? ris.to_param : "export"
         | 
| 17 | 
            -
              ris = ris.respond_to?(:to_ris) ? ris.to_ris() : ris  
         | 
| 18 | 
            -
              ris = "#{options[:callback]}(#{ris})" unless options[:callback].blank?
         | 
| 19 | 
            -
              self.content_type ||= Mime::Type.lookup(:ris)
         | 
| 20 | 
            -
              self.send_data ris, filename: "#{filename}.ris"
         | 
| 21 | 
            -
            end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
            # Adds a renderer for BibTeX.
         | 
| 24 | 
            -
            ActionController::Renderers.add :bibtex do |bibtex, options|
         | 
| 25 | 
            -
              bibtex = bibtex.first if bibtex.is_a? Array and bibtex.count == 1
         | 
| 26 | 
            -
              filename = (bibtex.respond_to?(:to_param) and bibtex.class.respond_to?(:acts_as_citable)) ? bibtex.to_param : "export"
         | 
| 27 | 
            -
              bibtex = bibtex.respond_to?(:to_bibtex) ? bibtex.to_bibtex() : bibtex  
         | 
| 28 | 
            -
              bibtex = "#{options[:callback]}(#{bibtex})" unless options[:callback].blank?
         | 
| 29 | 
            -
              self.content_type ||= Mime::Type.lookup(:bibtex)
         | 
| 30 | 
            -
              self.send_data bibtex, filename: "#{filename}.bib"
         | 
| 31 | 
            -
            end
         | 
| 32 | 
            -
             |