taipu 0.0.3 → 0.1.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: 705e5d57b69d89d6c094af24c0bee0e84e4daae8
4
- data.tar.gz: 8f5f0ccee8368f81fee5aa49e66b8baa088ad3fb
3
+ metadata.gz: cfee3a374d43ad532676775aa0d84ed7bc9ab6ab
4
+ data.tar.gz: 30ba72d8cc8228212b8e654fdb7568256747ed76
5
5
  SHA512:
6
- metadata.gz: 8c7f8a9082a8ab6721d592c8c8adf09b1a769b199078815cdaa4c35ff70144a9fd33eb6f79e6c8a2cf4ba11eedb2ac8c991ee912ef464296a41fce180d2921eb
7
- data.tar.gz: 62352199ef97fd14e28e0f1bece8d63f5782bd545b5ac33d9325f98590a0054826f350a7595ca3b56cbbdf3b329633e54bc68def576967b36e8078821d5e1d99
6
+ metadata.gz: c2d95c99fd44093531cfcab899d7c1becde076ba05fd740c93daad8f522d849f180a1a7fb007d26c822dd79809f6400eae101c0a9704e96df32404ee16fe4da4
7
+ data.tar.gz: cbd23d9c8732aec8fbcdd0093a0662d0a0ff9ec164d50ebed5386251ab912a82ac1ddc2ec69305100e3de4f45e32decdf497ebc3275cc6f2b5f4d149cb096b21
data/README.md CHANGED
@@ -39,9 +39,27 @@ Or install it yourself as:
39
39
 
40
40
  ```ruby
41
41
  type = Taipu::Number.new(min: 42)
42
- type.to_h # => { min: 42, max: nil, type: :number }
42
+
43
+ type.valid?(100) # => true
44
+ type.valid?(4) # => false
45
+ type.valid?('foobar') # => false
46
+
47
+ type.to_h # => { min: 42, max: nil, type: :number }
43
48
  ```
44
49
 
50
+ ## Security
51
+
52
+ As a basic form of security __Taipu__ provides a set of SHA512 checksums for
53
+ every Gem release. These checksums can be found in the `checksum/` directory.
54
+ Although these checksums do not prevent malicious users from tampering with a
55
+ built Gem they can be used for basic integrity verification purposes.
56
+
57
+ The checksum of a file can be checked using the `sha512sum` command. For
58
+ example:
59
+
60
+ $ sha512sum pkg/taipu-0.0.1.gem
61
+ 813cfbcff03d6022a001e4b108d706d17c705afffaeb478f082355533acb324b1983d88a80a71b31bb9de74931073cab07b329549ac2c48469733a4edb187846 pkg/taipu-0.0.1.gem
62
+
45
63
  ## Versioning
46
64
 
47
65
  __Taipu__ follows [Semantic Versioning 2.0](http://semver.org/).
data/VERSION.semver CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.1.0
@@ -0,0 +1 @@
1
+ 813cfbcff03d6022a001e4b108d706d17c705afffaeb478f082355533acb324b1983d88a80a71b31bb9de74931073cab07b329549ac2c48469733a4edb187846
@@ -0,0 +1 @@
1
+ e7aac20a4cf80a278ac17934b41a769ef9591492246ec06aef92082cfaee5de6bd291413d7ba22927172b410ba5afc2fdb56fe52dbca7ab884424216fae9628c
@@ -0,0 +1 @@
1
+ 16e50f42e22b4c892cd4476694d29bff07f0aab27cd6af3fec9d50e2837a4b086efd277dbde3d225dbebfe02c796c419751526fa6e96d2cdb456272d063a2766
@@ -0,0 +1 @@
1
+ e6579de91fc34ffc70325c8e94693aeb0faa9228f738d6c69054f9be14448db5b8e2bff0fb31dc66350725ae208d650ddeb8769a3dce1cf38dd5ca77e9d4e297
data/lib/taipu/array.rb CHANGED
@@ -4,5 +4,8 @@ require_relative 'base'
4
4
  module Taipu
5
5
  # The type number.
6
6
  class Array < Base
7
+ def valid?(value)
8
+ value.is_a?(::Array)
9
+ end
7
10
  end
8
11
  end
data/lib/taipu/base.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'matchi'
2
+
1
3
  # Namespace for the Taipu library.
2
4
  module Taipu
3
5
  # Abstract class.
data/lib/taipu/boolean.rb CHANGED
@@ -4,5 +4,8 @@ require_relative 'base'
4
4
  module Taipu
5
5
  # The type boolean.
6
6
  class Boolean < Base
7
+ def valid?(value)
8
+ value.equal?(true) || value.equal?(false)
9
+ end
7
10
  end
8
11
  end
data/lib/taipu/file.rb CHANGED
@@ -4,5 +4,8 @@ require_relative 'base'
4
4
  module Taipu
5
5
  # The type file.
6
6
  class File < Base
7
+ def valid?(value)
8
+ value.is_a?(::IO)
9
+ end
7
10
  end
8
11
  end
data/lib/taipu/hash.rb CHANGED
@@ -4,5 +4,8 @@ require_relative 'base'
4
4
  module Taipu
5
5
  # The type number.
6
6
  class Hash < Base
7
+ def valid?(value)
8
+ value.is_a?(::Hash)
9
+ end
7
10
  end
8
11
  end
data/lib/taipu/number.rb CHANGED
@@ -11,6 +11,14 @@ module Taipu
11
11
  @max = max
12
12
  end
13
13
 
14
+ def valid?(value)
15
+ return false unless value.is_a?(::Numeric)
16
+ return false if !@min.nil? && value < @min
17
+ return false if !@max.nil? && value > @max
18
+
19
+ true
20
+ end
21
+
14
22
  def constraints
15
23
  {
16
24
  min: @min,
data/lib/taipu/string.rb CHANGED
@@ -13,6 +13,15 @@ module Taipu
13
13
  @pattern = pattern
14
14
  end
15
15
 
16
+ def valid?(value)
17
+ return false unless value.is_a?(::String)
18
+ return false if !@minlen.nil? && value.length < @minlen
19
+ return false if !@maxlen.nil? && value.length > @maxlen
20
+ return false if !@pattern.nil? && @pattern.match(value).nil?
21
+
22
+ true
23
+ end
24
+
16
25
  def constraints
17
26
  {
18
27
  minlen: @minlen,
data/pkg_checksum ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'digest/sha2'
4
+
5
+ gemname = :taipu
6
+ ARGV[0] = File.read('VERSION.semver').chomp if ARGV[0].nil?
7
+ built_gem_path = "pkg/#{gemname}-#{ARGV[0]}.gem"
8
+ checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
9
+ checksum_path = "checksum/#{gemname}-#{ARGV[0]}.gem.sha512"
10
+
11
+ File.open(checksum_path, 'w') { |f| f.write("#{checksum}\n") }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taipu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
@@ -112,6 +112,10 @@ files:
112
112
  - VERSION.semver
113
113
  - bin/console
114
114
  - bin/setup
115
+ - checksum/taipu-0.0.1.gem.sha512
116
+ - checksum/taipu-0.0.2.gem.sha512
117
+ - checksum/taipu-0.0.3.gem.sha512
118
+ - checksum/taipu-0.1.0.gem.sha512
115
119
  - lib/taipu.rb
116
120
  - lib/taipu/array.rb
117
121
  - lib/taipu/base.rb
@@ -120,6 +124,7 @@ files:
120
124
  - lib/taipu/hash.rb
121
125
  - lib/taipu/number.rb
122
126
  - lib/taipu/string.rb
127
+ - pkg_checksum
123
128
  - taipu.gemspec
124
129
  homepage: https://github.com/cyril/taipu.rb
125
130
  licenses: