mack-orm 0.7.1.1 → 0.8.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.
    
        data/lib/mack-orm.rb
    CHANGED
    
    | 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'genosaurus'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'configatron'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            configatron.mack.set_default(:disable_transactional_tests, false)
         
     | 
| 
       3 
6 
     | 
    
         | 
| 
       4 
7 
     | 
    
         
             
            base = File.join(File.dirname(__FILE__), "mack-orm")
         
     | 
| 
       5 
8 
     | 
    
         
             
            require File.join(base, "database")
         
     | 
| 
         @@ -7,6 +10,7 @@ require File.join(base, "database_migrations") 
     | 
|
| 
       7 
10 
     | 
    
         
             
            require File.join(base, "generators")
         
     | 
| 
       8 
11 
     | 
    
         
             
            require File.join(base, "genosaurus_helpers")
         
     | 
| 
       9 
12 
     | 
    
         
             
            require File.join(base, "model_column")
         
     | 
| 
      
 13 
     | 
    
         
            +
            require File.join(base, "test_extensions")
         
     | 
| 
       10 
14 
     | 
    
         
             
            require File.join(base, "scaffold_generator", "scaffold_generator")
         
     | 
| 
       11 
15 
     | 
    
         | 
| 
       12 
16 
     | 
    
         
             
            Mack::Environment.after_class_method(:load) do
         
     | 
| 
         @@ -18,12 +18,12 @@ show_template: 
     | 
|
| 
       18 
18 
     | 
    
         
             
              type: file
         
     | 
| 
       19 
19 
     | 
    
         
             
              template_path: <%= File.join(templates_directory_path, "app", "views", "show.html.erb.template") %>
         
     | 
| 
       20 
20 
     | 
    
         
             
              output_path: <%= File.join("app", "views", @name_plural, "show.html.erb") %>
         
     | 
| 
       21 
     | 
    
         
            -
            <% if  
     | 
| 
      
 21 
     | 
    
         
            +
            <% if configatron.mack.testing_framework.to_s == "test_case" -%>
         
     | 
| 
       22 
22 
     | 
    
         
             
            functional_test_template:
         
     | 
| 
       23 
23 
     | 
    
         
             
              type: file
         
     | 
| 
       24 
24 
     | 
    
         
             
              template_path: <%= File.join(templates_directory_path, "test", "controllers", "test_case.rb.template") %>
         
     | 
| 
       25 
25 
     | 
    
         
             
              output_path: <%= File.join("test", "controllers", "#{@name_plural}_controller_test.rb") %>
         
     | 
| 
       26 
     | 
    
         
            -
            <% elsif  
     | 
| 
      
 26 
     | 
    
         
            +
            <% elsif configatron.mack.testing_framework.to_s == "rspec" -%>
         
     | 
| 
       27 
27 
     | 
    
         
             
            functional_test_template:
         
     | 
| 
       28 
28 
     | 
    
         
             
              type: file
         
     | 
| 
       29 
29 
     | 
    
         
             
              template_path: <%= File.join(templates_directory_path, "test", "controllers", "rspec.rb.template") %>
         
     | 
| 
         @@ -11,7 +11,7 @@ class ScaffoldGenerator < Genosaurus 
     | 
|
| 
       11 
11 
     | 
    
         
             
                @name_plural = param(:name).plural.underscore
         
     | 
| 
       12 
12 
     | 
    
         
             
                @name_singular_camel = @name_singular.camelcase
         
     | 
| 
       13 
13 
     | 
    
         
             
                @name_plural_camel = @name_plural.camelcase
         
     | 
| 
       14 
     | 
    
         
            -
                @test_framework =  
     | 
| 
      
 14 
     | 
    
         
            +
                @test_framework = configatron.mack.testing_framework
         
     | 
| 
       15 
15 
     | 
    
         
             
              end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
              def after_generate # :nodoc:
         
     | 
| 
         @@ -0,0 +1,80 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'spec'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            if Mack.env == "test"
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Mack
         
     | 
| 
      
 6 
     | 
    
         
            +
                module Testing # :nodoc: 
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              # Wrap it so we don't accidentally alias the run method n times and run out of db connections!
         
     | 
| 
      
 11 
     | 
    
         
            +
              unless Mack::Testing.const_defined?("LOADED")
         
     | 
| 
      
 12 
     | 
    
         
            +
                
         
     | 
| 
      
 13 
     | 
    
         
            +
                LOADED = true
         
     | 
| 
      
 14 
     | 
    
         
            +
                module Mack
         
     | 
| 
      
 15 
     | 
    
         
            +
                  module Testing
         
     | 
| 
      
 16 
     | 
    
         
            +
                    
         
     | 
| 
      
 17 
     | 
    
         
            +
                    # Implement this method to give transactional test support
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # to both RSpec and Test::Unit::TestCase for your ORM.
         
     | 
| 
      
 19 
     | 
    
         
            +
                    def rollback_transaction
         
     | 
| 
      
 20 
     | 
    
         
            +
                      yield
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end # rollback_transaction
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  end # Testing
         
     | 
| 
      
 24 
     | 
    
         
            +
                end # Mack
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                module Spec # :nodoc:
         
     | 
| 
      
 28 
     | 
    
         
            +
                  module Example # :nodoc:
         
     | 
| 
      
 29 
     | 
    
         
            +
                    module ExampleMethods # :nodoc:
         
     | 
| 
      
 30 
     | 
    
         
            +
                      include Mack::Testing
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                      alias_instance_method :execute, :mack_spec_execute
         
     | 
| 
      
 33 
     | 
    
         
            +
                      
         
     | 
| 
      
 34 
     | 
    
         
            +
                      def before_spec_extension
         
     | 
| 
      
 35 
     | 
    
         
            +
                      end
         
     | 
| 
      
 36 
     | 
    
         
            +
                      
         
     | 
| 
      
 37 
     | 
    
         
            +
                      def after_spec_extension
         
     | 
| 
      
 38 
     | 
    
         
            +
                      end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                      def execute(options, instance_variables)
         
     | 
| 
      
 41 
     | 
    
         
            +
                        before_spec_extension
         
     | 
| 
      
 42 
     | 
    
         
            +
                        unless configatron.mack.disable_transactional_tests
         
     | 
| 
      
 43 
     | 
    
         
            +
                          rollback_transaction do
         
     | 
| 
      
 44 
     | 
    
         
            +
                            @__res = mack_spec_execute(options, instance_variables)
         
     | 
| 
      
 45 
     | 
    
         
            +
                          end
         
     | 
| 
      
 46 
     | 
    
         
            +
                        else
         
     | 
| 
      
 47 
     | 
    
         
            +
                          @__res = mack_spec_execute(options, instance_variables)
         
     | 
| 
      
 48 
     | 
    
         
            +
                        end
         
     | 
| 
      
 49 
     | 
    
         
            +
                        after_spec_extension
         
     | 
| 
      
 50 
     | 
    
         
            +
                        return @__res
         
     | 
| 
      
 51 
     | 
    
         
            +
                      end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    end # ExampleGroup
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end # Example
         
     | 
| 
      
 55 
     | 
    
         
            +
                end # Spec
         
     | 
| 
      
 56 
     | 
    
         
            +
              
         
     | 
| 
      
 57 
     | 
    
         
            +
                module Test # :nodoc:
         
     | 
| 
      
 58 
     | 
    
         
            +
                  module Unit # :nodoc:
         
     | 
| 
      
 59 
     | 
    
         
            +
                    class TestCase # :nodoc:
         
     | 
| 
      
 60 
     | 
    
         
            +
                      include Mack::Testing
         
     | 
| 
      
 61 
     | 
    
         
            +
              
         
     | 
| 
      
 62 
     | 
    
         
            +
                      # Let's alias the run method in the class above us so we can create a new one here
         
     | 
| 
      
 63 
     | 
    
         
            +
                      # but still reference it.
         
     | 
| 
      
 64 
     | 
    
         
            +
                      alias_instance_method :run, :mack_test_case_run # :nodoc:
         
     | 
| 
      
 65 
     | 
    
         
            +
              
         
     | 
| 
      
 66 
     | 
    
         
            +
                      # We need to wrap the run method so we can do things like
         
     | 
| 
      
 67 
     | 
    
         
            +
                      # run a cleanup method if it exists
         
     | 
| 
      
 68 
     | 
    
         
            +
                      def run(result, &progress_block) # :nodoc:
         
     | 
| 
      
 69 
     | 
    
         
            +
                        rollback_transaction do
         
     | 
| 
      
 70 
     | 
    
         
            +
                          mack_test_case_run(result, &progress_block)
         
     | 
| 
      
 71 
     | 
    
         
            +
                        end
         
     | 
| 
      
 72 
     | 
    
         
            +
                      end
         
     | 
| 
      
 73 
     | 
    
         
            +
              
         
     | 
| 
      
 74 
     | 
    
         
            +
                    end # TestCase
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end # Unit
         
     | 
| 
      
 76 
     | 
    
         
            +
                end # Test
         
     | 
| 
      
 77 
     | 
    
         
            +
              
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
              
         
     | 
| 
      
 80 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mack-orm
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.8.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - markbates
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2008- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-10-06 00:00:00 -04:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
         @@ -39,6 +39,7 @@ files: 
     | 
|
| 
       39 
39 
     | 
    
         
             
            - lib/mack-orm/tasks/db_create_drop_tasks.rake
         
     | 
| 
       40 
40 
     | 
    
         
             
            - lib/mack-orm/tasks/db_migration_tasks.rake
         
     | 
| 
       41 
41 
     | 
    
         
             
            - lib/mack-orm/tasks/test_tasks.rake
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/mack-orm/test_extensions.rb
         
     | 
| 
       42 
43 
     | 
    
         
             
            - lib/mack-orm.rb
         
     | 
| 
       43 
44 
     | 
    
         
             
            - lib/mack-orm_tasks.rb
         
     | 
| 
       44 
45 
     | 
    
         
             
            - README
         
     | 
| 
         @@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       65 
66 
     | 
    
         
             
            requirements: []
         
     | 
| 
       66 
67 
     | 
    
         | 
| 
       67 
68 
     | 
    
         
             
            rubyforge_project: magrathea
         
     | 
| 
       68 
     | 
    
         
            -
            rubygems_version: 1. 
     | 
| 
      
 69 
     | 
    
         
            +
            rubygems_version: 1.3.0
         
     | 
| 
       69 
70 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       70 
71 
     | 
    
         
             
            specification_version: 2
         
     | 
| 
       71 
72 
     | 
    
         
             
            summary: Common ORM support for Mack
         
     |