shaf 0.4.1 → 0.5.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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/shaf/command/base.rb +51 -0
- data/lib/shaf/command/templates/Gemfile.erb +0 -1
- data/lib/shaf/command.rb +1 -47
- data/lib/shaf/extensions/resource_uris.rb +113 -151
- data/lib/shaf/generator/base.rb +61 -0
- data/lib/shaf/generator/migration/base.rb +133 -0
- data/lib/shaf/generator/migration/create_table.rb +4 -4
- data/lib/shaf/generator/migration.rb +1 -111
- data/lib/shaf/generator/serializer.rb +3 -51
- data/lib/shaf/generator/templates/api/controller.rb.erb +2 -0
- data/lib/shaf/generator/templates/api/policy.rb.erb +3 -2
- data/lib/shaf/generator/templates/api/serializer.rb.erb +2 -6
- data/lib/shaf/generator/templates/spec/integration_spec.rb.erb +30 -30
- data/lib/shaf/generator.rb +1 -57
- data/lib/shaf/helpers/cache_control.rb +21 -0
- data/lib/shaf/helpers.rb +4 -2
- data/lib/shaf/rake/db.rb +1 -1
- data/lib/shaf/upgrade/manifest.rb +29 -8
- data/lib/shaf/upgrade/package.rb +51 -27
- data/lib/shaf/version.rb +1 -1
- data/templates/api/controllers/docs_controller.rb +2 -0
- data/templates/api/controllers/root_controller.rb +2 -3
- data/templates/api/policies/base_policy.rb +3 -0
- data/templates/api/serializers/base_serializer.rb +4 -0
- data/templates/api/serializers/error_serializer.rb +3 -2
- data/templates/api/serializers/form_serializer.rb +2 -2
- data/templates/api/serializers/root_serializer.rb +3 -3
- data/templates/config/initializers/db_migrations.rb +24 -11
- data/templates/config/initializers/hal_presenter.rb +0 -5
- data/templates/config/settings.yml +8 -3
- data/upgrades/0.5.0.tar.gz +0 -0
- data.tar.gz.sig +0 -0
- metadata +69 -6
- metadata.gz.sig +0 -0
| @@ -4,10 +4,12 @@ class DocsController < BaseController | |
| 4 4 | 
             
              register_uri :documentation,  '/doc/:resource'
         | 
| 5 5 |  | 
| 6 6 | 
             
              get doc_curie_uri_template do
         | 
| 7 | 
            +
                cache_control(:private, http_cache_max_age: :long)
         | 
| 7 8 | 
             
                doc.link(params[:rel])
         | 
| 8 9 | 
             
              end
         | 
| 9 10 |  | 
| 10 11 | 
             
              get documentation_uri_template do
         | 
| 12 | 
            +
                cache_control(:private, http_cache_max_age: :long)
         | 
| 11 13 | 
             
                doc.to_s
         | 
| 12 14 | 
             
              end
         | 
| 13 15 |  | 
| @@ -1,10 +1,9 @@ | |
| 1 1 | 
             
            class RootController < BaseController
         | 
| 2 2 |  | 
| 3 | 
            -
              HTTP_CACHE_MAX_AGE = 86400 # 60 * 60 * 24 = 1 day
         | 
| 4 3 | 
             
              register_uri :root, '/'
         | 
| 5 4 |  | 
| 6 | 
            -
              get root_uri do
         | 
| 7 | 
            -
                cache_control(:private,  | 
| 5 | 
            +
              get :root_uri do
         | 
| 6 | 
            +
                cache_control(:private, http_cache_max_age: :long)
         | 
| 8 7 | 
             
                respond_with nil, serializer: RootSerializer
         | 
| 9 8 | 
             
              end
         | 
| 10 9 | 
             
            end
         | 
| @@ -2,17 +2,30 @@ require 'sequel' | |
| 2 2 | 
             
            require 'config/database'
         | 
| 3 3 |  | 
| 4 4 | 
             
            Sequel.extension :migration
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            return if Sequel::Migrator.is_current?(DB, MIGRATIONS_DIR)
         | 
| 5 | 
            +
            Dir[File.join(MIGRATIONS_DIR, "*")]
         | 
| 7 6 |  | 
| 8 | 
            -
             | 
| 7 | 
            +
            def is_current?
         | 
| 8 | 
            +
              return true unless Dir[File.join(MIGRATIONS_DIR, "*")].any?
         | 
| 9 | 
            +
              Sequel::Migrator.is_current?(DB, MIGRATIONS_DIR)
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            def environment
         | 
| 13 | 
            +
              ENV['RACK_ENV']
         | 
| 14 | 
            +
            end
         | 
| 9 15 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
               | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                 | 
| 16 | 
            -
               | 
| 17 | 
            -
             | 
| 16 | 
            +
            def init
         | 
| 17 | 
            +
              return if is_current?
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              if environment == 'test'
         | 
| 20 | 
            +
                $logger.info "Running migrations in 'test' environment.."
         | 
| 21 | 
            +
                Sequel::Migrator.run(DB, "#{APP_ROOT}/db/migrations")
         | 
| 22 | 
            +
              else
         | 
| 23 | 
            +
                msg = "Database for environment '#{environment}' is not " \
         | 
| 24 | 
            +
                  "updated to the latest migration"
         | 
| 25 | 
            +
                STDERR.puts msg
         | 
| 26 | 
            +
                $logger&.warn msg
         | 
| 27 | 
            +
              end
         | 
| 18 28 | 
             
            end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            init
         | 
| 31 | 
            +
             | 
| @@ -1,6 +1,5 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            default: &default
         | 
| 3 | 
            -
              port: 3000
         | 
| 4 3 | 
             
              public_folder: frontend/assets
         | 
| 5 4 | 
             
              views_folder: frontend/views
         | 
| 6 5 | 
             
              documents_dir: doc/api
         | 
| @@ -8,14 +7,20 @@ default: &default | |
| 8 7 | 
             
              fixtures_dir: spec/fixtures
         | 
| 9 8 | 
             
              paginate_per_page: 25
         | 
| 10 9 | 
             
              http_cache: on
         | 
| 10 | 
            +
              http_cache_max_age_long: 86400 # 60 * 60 * 24 = 1 day
         | 
| 11 | 
            +
              http_cache_max_age_short: 3600 #      60 * 60 = 1 hour
         | 
| 12 | 
            +
              hostname: localhost
         | 
| 13 | 
            +
              protocol: http
         | 
| 14 | 
            +
              port: 3000
         | 
| 11 15 |  | 
| 12 16 | 
             
            production:
         | 
| 13 17 | 
             
              <<: *default
         | 
| 14 | 
            -
              port:  | 
| 18 | 
            +
              port: 443
         | 
| 19 | 
            +
              protocol: https
         | 
| 15 20 |  | 
| 16 21 | 
             
            development:
         | 
| 17 22 | 
             
              <<: *default
         | 
| 18 23 |  | 
| 19 24 | 
             
            test:
         | 
| 20 25 | 
             
              <<: *default
         | 
| 21 | 
            -
              port:  | 
| 26 | 
            +
              port: 3030
         | 
| Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: shaf
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sammy Henningsson
         | 
| @@ -30,7 +30,7 @@ cert_chain: | |
| 30 30 | 
             
              ZMhjYR7sRczGJx+GxGU2EaR0bjRsPVlC4ywtFxoOfRG3WaJcpWGEoAoMJX6Z0bRv
         | 
| 31 31 | 
             
              M40=
         | 
| 32 32 | 
             
              -----END CERTIFICATE-----
         | 
| 33 | 
            -
            date: 2018- | 
| 33 | 
            +
            date: 2018-08-25 00:00:00.000000000 Z
         | 
| 34 34 | 
             
            dependencies:
         | 
| 35 35 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 36 36 | 
             
              name: rake
         | 
| @@ -39,19 +39,75 @@ dependencies: | |
| 39 39 | 
             
                - - "~>"
         | 
| 40 40 | 
             
                  - !ruby/object:Gem::Version
         | 
| 41 41 | 
             
                    version: '12.0'
         | 
| 42 | 
            +
              type: :development
         | 
| 43 | 
            +
              prerelease: false
         | 
| 44 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 45 | 
            +
                requirements:
         | 
| 46 | 
            +
                - - "~>"
         | 
| 47 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 48 | 
            +
                    version: '12.0'
         | 
| 49 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 50 | 
            +
              name: sinatra
         | 
| 51 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 52 | 
            +
                requirements:
         | 
| 53 | 
            +
                - - "~>"
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                    version: '2.0'
         | 
| 56 | 
            +
              type: :development
         | 
| 57 | 
            +
              prerelease: false
         | 
| 58 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - "~>"
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: '2.0'
         | 
| 63 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 64 | 
            +
              name: sequel
         | 
| 65 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - "~>"
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '5'
         | 
| 70 | 
            +
              type: :development
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - "~>"
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '5'
         | 
| 77 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 78 | 
            +
              name: minitest
         | 
| 79 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 80 | 
            +
                requirements:
         | 
| 81 | 
            +
                - - "~>"
         | 
| 82 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 83 | 
            +
                    version: '5'
         | 
| 42 84 | 
             
                - - ">="
         | 
| 43 85 | 
             
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            -
                    version: '10 | 
| 86 | 
            +
                    version: '5.10'
         | 
| 45 87 | 
             
              type: :development
         | 
| 46 88 | 
             
              prerelease: false
         | 
| 47 89 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 48 90 | 
             
                requirements:
         | 
| 49 91 | 
             
                - - "~>"
         | 
| 50 92 | 
             
                  - !ruby/object:Gem::Version
         | 
| 51 | 
            -
                    version: ' | 
| 93 | 
            +
                    version: '5'
         | 
| 52 94 | 
             
                - - ">="
         | 
| 53 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: '10 | 
| 96 | 
            +
                    version: '5.10'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: sqlite3
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - "~>"
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '1.3'
         | 
| 104 | 
            +
              type: :development
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - "~>"
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '1.3'
         | 
| 55 111 | 
             
            description: A framework for building hypermedia driven APIs with sinatra and sequel.
         | 
| 56 112 | 
             
            email: sammy.henningsson@gmail.com
         | 
| 57 113 | 
             
            executables:
         | 
| @@ -65,6 +121,7 @@ files: | |
| 65 121 | 
             
            - lib/shaf/api_doc/document.rb
         | 
| 66 122 | 
             
            - lib/shaf/app.rb
         | 
| 67 123 | 
             
            - lib/shaf/command.rb
         | 
| 124 | 
            +
            - lib/shaf/command/base.rb
         | 
| 68 125 | 
             
            - lib/shaf/command/console.rb
         | 
| 69 126 | 
             
            - lib/shaf/command/generate.rb
         | 
| 70 127 | 
             
            - lib/shaf/command/new.rb
         | 
| @@ -81,10 +138,12 @@ files: | |
| 81 138 | 
             
            - lib/shaf/extensions/symbolic_routes.rb
         | 
| 82 139 | 
             
            - lib/shaf/formable.rb
         | 
| 83 140 | 
             
            - lib/shaf/generator.rb
         | 
| 141 | 
            +
            - lib/shaf/generator/base.rb
         | 
| 84 142 | 
             
            - lib/shaf/generator/controller.rb
         | 
| 85 143 | 
             
            - lib/shaf/generator/migration.rb
         | 
| 86 144 | 
             
            - lib/shaf/generator/migration/add_column.rb
         | 
| 87 145 | 
             
            - lib/shaf/generator/migration/add_index.rb
         | 
| 146 | 
            +
            - lib/shaf/generator/migration/base.rb
         | 
| 88 147 | 
             
            - lib/shaf/generator/migration/create_table.rb
         | 
| 89 148 | 
             
            - lib/shaf/generator/migration/drop_column.rb
         | 
| 90 149 | 
             
            - lib/shaf/generator/migration/empty.rb
         | 
| @@ -101,6 +160,7 @@ files: | |
| 101 160 | 
             
            - lib/shaf/generator/templates/spec/model.rb.erb
         | 
| 102 161 | 
             
            - lib/shaf/generator/templates/spec/serializer_spec.rb.erb
         | 
| 103 162 | 
             
            - lib/shaf/helpers.rb
         | 
| 163 | 
            +
            - lib/shaf/helpers/cache_control.rb
         | 
| 104 164 | 
             
            - lib/shaf/helpers/json_html.rb
         | 
| 105 165 | 
             
            - lib/shaf/helpers/paginate.rb
         | 
| 106 166 | 
             
            - lib/shaf/helpers/payload.rb
         | 
| @@ -135,6 +195,8 @@ files: | |
| 135 195 | 
             
            - templates/api/controllers/base_controller.rb
         | 
| 136 196 | 
             
            - templates/api/controllers/docs_controller.rb
         | 
| 137 197 | 
             
            - templates/api/controllers/root_controller.rb
         | 
| 198 | 
            +
            - templates/api/policies/base_policy.rb
         | 
| 199 | 
            +
            - templates/api/serializers/base_serializer.rb
         | 
| 138 200 | 
             
            - templates/api/serializers/error_serializer.rb
         | 
| 139 201 | 
             
            - templates/api/serializers/form_serializer.rb
         | 
| 140 202 | 
             
            - templates/api/serializers/root_serializer.rb
         | 
| @@ -159,6 +221,7 @@ files: | |
| 159 221 | 
             
            - templates/spec/serializers/root_serializer_spec.rb
         | 
| 160 222 | 
             
            - templates/spec/spec_helper.rb
         | 
| 161 223 | 
             
            - upgrades/0.4.0.tar.gz
         | 
| 224 | 
            +
            - upgrades/0.5.0.tar.gz
         | 
| 162 225 | 
             
            homepage: https://github.com/sammyhenningsson/shaf
         | 
| 163 226 | 
             
            licenses:
         | 
| 164 227 | 
             
            - MIT
         | 
| @@ -180,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 180 243 | 
             
                  version: '0'
         | 
| 181 244 | 
             
            requirements: []
         | 
| 182 245 | 
             
            rubyforge_project: 
         | 
| 183 | 
            -
            rubygems_version: 2.6 | 
| 246 | 
            +
            rubygems_version: 2.7.6
         | 
| 184 247 | 
             
            signing_key: 
         | 
| 185 248 | 
             
            specification_version: 4
         | 
| 186 249 | 
             
            summary: Sinatra Hypermedia Api Framework
         | 
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |