typor 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c87625f3cae6d7328f8834d24c3eadedbec284aa
4
- data.tar.gz: b0c7a4bc55b3ff78827dedad21a5b83b9ab04670
3
+ metadata.gz: 3419e76752de2076b933f9a4065172a77ed2a5dd
4
+ data.tar.gz: d52a70ed0734e16a9488d43b892b3b695f8cecd5
5
5
  SHA512:
6
- metadata.gz: 0789f297779f2b5288d450d2f450ffb06d4d284cc4bb03bd11bdfc729e75b24d634a9aab876139ddb3b83eb7e86f68cdfe8c7c681ac6f9ab1f5113a8d1e5e6a8
7
- data.tar.gz: c116a0ac26ae1a6a756812a7b4c156e17b10f26158b7b9dbbc43489053b98d5cc03e89f39f061a066393e390e7fa4553a68d6e9f00d2a5ab34514103373766eb
6
+ metadata.gz: d960ce5600f42d80225ff2cdbb5e4aa9a98c64829cd1e2326c8b597ad90536bf9cd2858c5df653908fc8e49cf0756910aa29fd50860a105b21f53ceea9897e7d
7
+ data.tar.gz: 9280f609bdb40ec468a02c90f31f8993102011f64e2867d124d5ad70f9985c1e3095dc07cfef4377272e82cda1cc70bd036f5438208fce3021773cd4d1de5778
@@ -8,20 +8,20 @@ require 'aromat'
8
8
  require 'typor/version'
9
9
  require 'typor/magic'
10
10
 
11
- # Typor Module
12
- # Root Module for Typor
11
+ # Typor Module:
12
+ # Root Module for Typor.
13
13
  module Typor
14
14
 
15
- # Get File Type
16
- # Determines MIME Type of Local File
15
+ # Get File Type:
16
+ # Determines MIME Type of Local File.
17
17
  # @param [String] f Path to a File
18
18
  # @return [String] MIME Type
19
19
  def self.file f
20
20
  (Magic.detect_magic(File.read(f)) || []).try :first
21
21
  end
22
22
 
23
- # Get Data Type
24
- # Determine MIME Type of Data String
23
+ # Get Data Type:
24
+ # Determine MIME Type of Data String.
25
25
  # @param [String] d Data String
26
26
  # @return [String] MIME Type
27
27
  def self.data d
@@ -400,12 +400,19 @@ module Typor
400
400
  ['text/x-tex', [[0, '%']]]
401
401
  ]
402
402
 
403
- # Detect Magic
403
+ # Detect Magic:
404
+ # Finds a Magic Definition matching data.
405
+ # @param [String] data A chunk of data to identify
406
+ # @return [Array] A magic array ([type, magic])
404
407
  def self.detect_magic data
405
408
  MAGIC.find { |_type, magic| check_magic data, magic }
406
409
  end
407
410
 
408
- # Check Magic
411
+ # Check Magic:
412
+ # Determines whether a given chunk of data matches a certain magic array (an array of pattern matchers).
413
+ # @param [String] data A chunk of data to identify
414
+ # @param [Array] magic An array of pattern matchers ([offset/range, value, sub-checks])
415
+ # @return [Boolean] True if the data matches the magic, False otherwise
409
416
  def self.check_magic data, magic
410
417
  magic.any? { |off, val, sub| ((Range === off) ? (data.slice(off) || '').include?(val) : (data.slice(off, val.size) == val)) && (!sub || check_magic(data, sub)) }
411
418
  end
@@ -5,5 +5,5 @@
5
5
  module Typor
6
6
 
7
7
  # Version
8
- VERSION = '0.1.1'
8
+ VERSION = '1.0.0'
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eresse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler