tensai-core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Guardfile +15 -0
- data/lib/tensai/util/initializer.rb +46 -0
- data/lib/tensai/util.rb +5 -0
- data/lib/tensai/version.rb +1 -1
- data/lib/tensai.rb +4 -0
- metadata +5 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 79bafeb0e1ee8acc293938ac8ec9708e3bc37cc73cc5748f66d2e9d7fe3f19f6
         | 
| 4 | 
            +
              data.tar.gz: 2797a5cb139b38517d9e9c4a9a661ccca493fdc52561978bbbf1c79435af7ab8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 59378c4d21b0a40f66e397e6986748a267a6dd6a92ae5d0000bff53e594789f8d074bcc637a27efcfb7e0ad23537cfc352a8cb759a75f6572bc65c567fbe6f4e
         | 
| 7 | 
            +
              data.tar.gz: cc1fec80131c4195f6d91329a1e36d3f9f2d32c7f64cee5d87e9e7dad5855c45a255d5a2433f63bc15b8bae34755a652bc33bd01cd6fc703281dada7de2b6999
         | 
    
        data/Guardfile
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            guard :rspec, cmd: 'bundle exec rspec' do
         | 
| 4 | 
            +
              require 'guard/rspec/dsl'
         | 
| 5 | 
            +
              dsl = Guard::RSpec::Dsl.new(self)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              rspec = dsl.rspec
         | 
| 8 | 
            +
              watch(rspec.spec_helper) { rspec.spec_dir }
         | 
| 9 | 
            +
              watch(rspec.spec_support) { rspec.spec_dir }
         | 
| 10 | 
            +
              watch(rspec.spec_files)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              # Ruby files
         | 
| 13 | 
            +
              ruby = dsl.ruby
         | 
| 14 | 
            +
              dsl.watch_spec_files_for(ruby.lib_files)
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'tensai/types'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Tensai::Util
         | 
| 6 | 
            +
              # @private
         | 
| 7 | 
            +
              class Initializer < Module
         | 
| 8 | 
            +
                def initialize(**args)
         | 
| 9 | 
            +
                  @args = args
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  define_method :__check_argument_type do |argument, value|
         | 
| 12 | 
            +
                    args[argument][value]
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def included(klass)
         | 
| 17 | 
            +
                  klass.class_eval initializer_code, __FILE__, __LINE__ + 10
         | 
| 18 | 
            +
                  @args.keys.each do |arg|
         | 
| 19 | 
            +
                    klass.class_eval "attr_reader :#{arg}", __FILE__, __LINE__
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                private
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def initializer_code
         | 
| 26 | 
            +
                  <<~CODE
         | 
| 27 | 
            +
                    def initialize(#{initializer_signature})
         | 
| 28 | 
            +
                      #{check_argument_types_code}
         | 
| 29 | 
            +
                      #{assign_instance_variables_code}
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
                  CODE
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def initializer_signature
         | 
| 35 | 
            +
                  @args.keys.map { |arg| "#{arg}:" }.join(', ')
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                def check_argument_types_code
         | 
| 39 | 
            +
                  @args.keys.map { |arg| "__check_argument_type(:#{arg}, #{arg})" }.join(';')
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                def assign_instance_variables_code
         | 
| 43 | 
            +
                  @args.keys.map { |arg| "@#{arg} = #{arg}" }.join(';')
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
    
        data/lib/tensai/util.rb
    ADDED
    
    
    
        data/lib/tensai/version.rb
    CHANGED
    
    
    
        data/lib/tensai.rb
    ADDED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: tensai-core
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kevin Fischer
         | 
| @@ -34,7 +34,11 @@ files: | |
| 34 34 | 
             
            - ".rspec"
         | 
| 35 35 | 
             
            - Gemfile
         | 
| 36 36 | 
             
            - Gemfile.lock
         | 
| 37 | 
            +
            - Guardfile
         | 
| 38 | 
            +
            - lib/tensai.rb
         | 
| 37 39 | 
             
            - lib/tensai/types.rb
         | 
| 40 | 
            +
            - lib/tensai/util.rb
         | 
| 41 | 
            +
            - lib/tensai/util/initializer.rb
         | 
| 38 42 | 
             
            - lib/tensai/version.rb
         | 
| 39 43 | 
             
            - tensai-core.gemspec
         | 
| 40 44 | 
             
            homepage: https://github.com/kfischer-okarin/tensai
         |