ruby-magic-static 0.3.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 +7 -0
 - data/AUTHORS +1 -0
 - data/CHANGELOG.md +60 -0
 - data/COPYRIGHT +1 -0
 - data/LICENSE +202 -0
 - data/NOTICE +466 -0
 - data/README.md +46 -0
 - data/VERSION +1 -0
 - data/ext/magic/common.h +132 -0
 - data/ext/magic/extconf.rb +196 -0
 - data/ext/magic/functions.c +344 -0
 - data/ext/magic/functions.h +67 -0
 - data/ext/magic/ruby-magic.c +1595 -0
 - data/ext/magic/ruby-magic.h +307 -0
 - data/kwilczynski-public.pem +25 -0
 - data/lib/magic.rb +203 -0
 - data/lib/magic/core/file.rb +66 -0
 - data/lib/magic/core/string.rb +33 -0
 - data/lib/magic/version.rb +42 -0
 - metadata +73 -0
 
| 
         @@ -0,0 +1,66 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class File
         
     | 
| 
      
 4 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 5 
     | 
    
         
            +
                #
         
     | 
| 
      
 6 
     | 
    
         
            +
                # call-seq:
         
     | 
| 
      
 7 
     | 
    
         
            +
                #    File.magic( object ) -> string or array
         
     | 
| 
      
 8 
     | 
    
         
            +
                #    File.magic( string ) -> string or array
         
     | 
| 
      
 9 
     | 
    
         
            +
                #
         
     | 
| 
      
 10 
     | 
    
         
            +
                # See also: File::mime and File::type
         
     | 
| 
      
 11 
     | 
    
         
            +
                #
         
     | 
| 
      
 12 
     | 
    
         
            +
                def magic(path, flags = Magic::NONE)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  Magic.open(flags) {|mgc| mgc.file(path) }
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                #
         
     | 
| 
      
 17 
     | 
    
         
            +
                # call-seq:
         
     | 
| 
      
 18 
     | 
    
         
            +
                #    File.mime( string ) -> string or array
         
     | 
| 
      
 19 
     | 
    
         
            +
                #
         
     | 
| 
      
 20 
     | 
    
         
            +
                # See also: File::magic and File::type
         
     | 
| 
      
 21 
     | 
    
         
            +
                #
         
     | 
| 
      
 22 
     | 
    
         
            +
                def mime(path)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  magic(path, Magic::MIME)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                #
         
     | 
| 
      
 27 
     | 
    
         
            +
                # call-seq:
         
     | 
| 
      
 28 
     | 
    
         
            +
                #    File.type( string ) -> string or array
         
     | 
| 
      
 29 
     | 
    
         
            +
                #
         
     | 
| 
      
 30 
     | 
    
         
            +
                # See also: File::magic and File::mime
         
     | 
| 
      
 31 
     | 
    
         
            +
                #
         
     | 
| 
      
 32 
     | 
    
         
            +
                def type(path)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  magic(path, Magic::MIME_TYPE)
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              #
         
     | 
| 
      
 38 
     | 
    
         
            +
              # call-seq:
         
     | 
| 
      
 39 
     | 
    
         
            +
              #    File.magic -> string or array
         
     | 
| 
      
 40 
     | 
    
         
            +
              #
         
     | 
| 
      
 41 
     | 
    
         
            +
              # See also: File#mime and File#type
         
     | 
| 
      
 42 
     | 
    
         
            +
              #
         
     | 
| 
      
 43 
     | 
    
         
            +
              def magic
         
     | 
| 
      
 44 
     | 
    
         
            +
                self.class.magic(self)
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              #
         
     | 
| 
      
 48 
     | 
    
         
            +
              # call-seq:
         
     | 
| 
      
 49 
     | 
    
         
            +
              #    File.mime -> string or array
         
     | 
| 
      
 50 
     | 
    
         
            +
              #
         
     | 
| 
      
 51 
     | 
    
         
            +
              # See also: File#magic and File#type
         
     | 
| 
      
 52 
     | 
    
         
            +
              #
         
     | 
| 
      
 53 
     | 
    
         
            +
              def mime
         
     | 
| 
      
 54 
     | 
    
         
            +
                self.class.mime(self)
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              #
         
     | 
| 
      
 58 
     | 
    
         
            +
              # call-seq:
         
     | 
| 
      
 59 
     | 
    
         
            +
              #    File.type -> string or array
         
     | 
| 
      
 60 
     | 
    
         
            +
              #
         
     | 
| 
      
 61 
     | 
    
         
            +
              # See also: File#magic and File#mime
         
     | 
| 
      
 62 
     | 
    
         
            +
              #
         
     | 
| 
      
 63 
     | 
    
         
            +
              def type
         
     | 
| 
      
 64 
     | 
    
         
            +
                self.class.type(self)
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class String
         
     | 
| 
      
 4 
     | 
    
         
            +
              #
         
     | 
| 
      
 5 
     | 
    
         
            +
              # call-seq:
         
     | 
| 
      
 6 
     | 
    
         
            +
              #    string.magic -> string or array
         
     | 
| 
      
 7 
     | 
    
         
            +
              #
         
     | 
| 
      
 8 
     | 
    
         
            +
              # See also: String#mime and String#type
         
     | 
| 
      
 9 
     | 
    
         
            +
              #
         
     | 
| 
      
 10 
     | 
    
         
            +
              def magic(flags = Magic::NONE)
         
     | 
| 
      
 11 
     | 
    
         
            +
                Magic.open(flags) {|mgc| mgc.buffer(self) }
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              #
         
     | 
| 
      
 15 
     | 
    
         
            +
              # call-seq:
         
     | 
| 
      
 16 
     | 
    
         
            +
              #    string.mime -> string or array
         
     | 
| 
      
 17 
     | 
    
         
            +
              #
         
     | 
| 
      
 18 
     | 
    
         
            +
              # See also: String#magic and String#type
         
     | 
| 
      
 19 
     | 
    
         
            +
              #
         
     | 
| 
      
 20 
     | 
    
         
            +
              def mime
         
     | 
| 
      
 21 
     | 
    
         
            +
                magic(Magic::MIME)
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              #
         
     | 
| 
      
 25 
     | 
    
         
            +
              # call-seq:
         
     | 
| 
      
 26 
     | 
    
         
            +
              #    string.type -> string or array
         
     | 
| 
      
 27 
     | 
    
         
            +
              #
         
     | 
| 
      
 28 
     | 
    
         
            +
              # See also: String#magic and String#mime
         
     | 
| 
      
 29 
     | 
    
         
            +
              #
         
     | 
| 
      
 30 
     | 
    
         
            +
              def type
         
     | 
| 
      
 31 
     | 
    
         
            +
                magic(Magic::MIME_TYPE)
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Magic
         
     | 
| 
      
 4 
     | 
    
         
            +
              #
         
     | 
| 
      
 5 
     | 
    
         
            +
              # Current version of _Magic_.
         
     | 
| 
      
 6 
     | 
    
         
            +
              #
         
     | 
| 
      
 7 
     | 
    
         
            +
              VERSION = '0.2.0'.freeze
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 10 
     | 
    
         
            +
                #
         
     | 
| 
      
 11 
     | 
    
         
            +
                # call-seq:
         
     | 
| 
      
 12 
     | 
    
         
            +
                #    Magic.version_array -> array
         
     | 
| 
      
 13 
     | 
    
         
            +
                #
         
     | 
| 
      
 14 
     | 
    
         
            +
                # Example:
         
     | 
| 
      
 15 
     | 
    
         
            +
                #
         
     | 
| 
      
 16 
     | 
    
         
            +
                #    Magic.version_array #=> [5, 39]
         
     | 
| 
      
 17 
     | 
    
         
            +
                #
         
     | 
| 
      
 18 
     | 
    
         
            +
                # See also: Magic::version and Magic::version_string
         
     | 
| 
      
 19 
     | 
    
         
            +
                #
         
     | 
| 
      
 20 
     | 
    
         
            +
                def version_array
         
     | 
| 
      
 21 
     | 
    
         
            +
                  [self.version / 100, self.version % 100]
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                alias_method :version_to_a, :version_array
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                #
         
     | 
| 
      
 27 
     | 
    
         
            +
                # call-seq:
         
     | 
| 
      
 28 
     | 
    
         
            +
                #    Magic.version_string -> string
         
     | 
| 
      
 29 
     | 
    
         
            +
                #
         
     | 
| 
      
 30 
     | 
    
         
            +
                # Example:
         
     | 
| 
      
 31 
     | 
    
         
            +
                #
         
     | 
| 
      
 32 
     | 
    
         
            +
                #    Magic.version_string #=> "5.39"
         
     | 
| 
      
 33 
     | 
    
         
            +
                #
         
     | 
| 
      
 34 
     | 
    
         
            +
                # See also: Magic::version and Magic::version_array
         
     | 
| 
      
 35 
     | 
    
         
            +
                #
         
     | 
| 
      
 36 
     | 
    
         
            +
                def version_string
         
     | 
| 
      
 37 
     | 
    
         
            +
                  '%d.%02d' % self.version_array
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                alias_method :version_to_s, :version_string
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,73 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: ruby-magic-static
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Krzysztof Wilczyński
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain:
         
     | 
| 
      
 11 
     | 
    
         
            +
            - kwilczynski-public.pem
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2021-03-25 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 14 
     | 
    
         
            +
            description: |
         
     | 
| 
      
 15 
     | 
    
         
            +
              File Magic in Ruby.
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              Simple interface to libmagic for Ruby Programming Language.
         
     | 
| 
      
 18 
     | 
    
         
            +
            email: kw@linux.com
         
     | 
| 
      
 19 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 20 
     | 
    
         
            +
            extensions:
         
     | 
| 
      
 21 
     | 
    
         
            +
            - ext/magic/extconf.rb
         
     | 
| 
      
 22 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 23 
     | 
    
         
            +
            files:
         
     | 
| 
      
 24 
     | 
    
         
            +
            - AUTHORS
         
     | 
| 
      
 25 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
      
 26 
     | 
    
         
            +
            - COPYRIGHT
         
     | 
| 
      
 27 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 28 
     | 
    
         
            +
            - NOTICE
         
     | 
| 
      
 29 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 30 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 31 
     | 
    
         
            +
            - ext/magic/common.h
         
     | 
| 
      
 32 
     | 
    
         
            +
            - ext/magic/extconf.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
            - ext/magic/functions.c
         
     | 
| 
      
 34 
     | 
    
         
            +
            - ext/magic/functions.h
         
     | 
| 
      
 35 
     | 
    
         
            +
            - ext/magic/ruby-magic.c
         
     | 
| 
      
 36 
     | 
    
         
            +
            - ext/magic/ruby-magic.h
         
     | 
| 
      
 37 
     | 
    
         
            +
            - kwilczynski-public.pem
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/magic.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/magic/core/file.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/magic/core/string.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/magic/version.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            homepage: https://github.com/kwilczynski/ruby-magic
         
     | 
| 
      
 43 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 44 
     | 
    
         
            +
            - Apache-2.0
         
     | 
| 
      
 45 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 46 
     | 
    
         
            +
              bug_tracker_uri: https://github.com/kwilczynski/ruby-magic/issues
         
     | 
| 
      
 47 
     | 
    
         
            +
              source_code_uri: https://gitlab.com/gitlab-org/ruby-magic
         
     | 
| 
      
 48 
     | 
    
         
            +
              changelog_uri: https://github.com/kwilczynski/ruby-magic/blob/master/CHANGELOG.md
         
     | 
| 
      
 49 
     | 
    
         
            +
              documentation_uri: https://www.rubydoc.info/gems/ruby-magic
         
     | 
| 
      
 50 
     | 
    
         
            +
              wiki_uri: https://github.com/kwilczynski/ruby-magic/wiki
         
     | 
| 
      
 51 
     | 
    
         
            +
            post_install_message: 'Thank you for installing!
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            '
         
     | 
| 
      
 54 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 55 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 58 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 59 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 60 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 61 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 62 
     | 
    
         
            +
                  version: 2.5.0
         
     | 
| 
      
 63 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 64 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 65 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 66 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 67 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 68 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 69 
     | 
    
         
            +
            rubygems_version: 3.1.4
         
     | 
| 
      
 70 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 71 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 72 
     | 
    
         
            +
            summary: File Magic in Ruby
         
     | 
| 
      
 73 
     | 
    
         
            +
            test_files: []
         
     |