fog-local 0.3.1 → 0.4.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: 0e0b4af75c75344097e40217e3f1ec9e84c3043d
4
- data.tar.gz: 7d9e80f6f2e4ccc7f33d2fa2f5e51b700d4dfe0d
3
+ metadata.gz: 2f8d4c17d2d000539b8dad9be95d8495556d6868
4
+ data.tar.gz: 22616d1b9f12d284cdd10e396ce87596c14082e1
5
5
  SHA512:
6
- metadata.gz: 4f32c1dc249f2bc2a88b9f631b9c65a39cf2752f2ab721a1424d9a683e77be4e9d30f7b43236fe55d27a6b92a4797d5d8911ff2728f3b5a1d0bb6af9537a5c78
7
- data.tar.gz: 63f0bf2753a1d7ad7ee77cad0179768d6906bdbef7d6cc71b881aa3bb82a38eaf3c157f6aef373162cbc64e9c9b71e88e855109cf2ef357886ab80e9c47eabe3
6
+ metadata.gz: e18eadc38367b13c82ce00b4fac8b8619d877417f8f976f9a2ff755eb33bf30e15c27f2327ba408532ed73acf700aa2dda6012de7cf0dfd9fee8b025f2b52f1c
7
+ data.tar.gz: f89a42302dc3b2806d9e0f773f62a6bd64219d3df4e728ed7fc451590734e4bd8a31b9e9c8f9d671b0ea0c903093138c43db4e5f363f70db51642e705fbe83ec
@@ -5,10 +5,11 @@ rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
7
  - 2.1.10
8
- - 2.2.5
9
- - 2.3.1
8
+ - 2.2.6
9
+ - 2.3.3
10
+ - 2.4.0
10
11
  - jruby-19mode
11
- - jruby-9.0.5.0
12
+ - jruby-9.1.7.0
12
13
  env:
13
14
  - FOG_MOCK=true
14
15
  - FOG_MOCK=false
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Local
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -18,11 +18,12 @@ module Fog
18
18
  end
19
19
 
20
20
  def get(key, options = {})
21
- if ::File.directory?(service.path_to(key))
22
- new(:key => key)
23
- else
24
- nil
25
- end
21
+ create_directory(key, options) if ::File.directory?(service.path_to(key))
22
+ end
23
+
24
+ private
25
+ def create_directory(key, options)
26
+ options[:path] ? new(key: key + options[:path]) : new(key: key)
26
27
  end
27
28
  end
28
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wesley Beary
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-24 00:00:00.000000000 Z
12
+ date: 2017-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -99,11 +99,8 @@ files:
99
99
  - lib/fog/storage/local/models/files.rb
100
100
  - tests/helper.rb
101
101
  - tests/helpers/collection_helper.rb
102
- - tests/helpers/formats_helper.rb
103
- - tests/helpers/formats_helper_tests.rb
104
102
  - tests/helpers/mock_helper.rb
105
103
  - tests/helpers/model_helper.rb
106
- - tests/helpers/schema_validator_tests.rb
107
104
  - tests/helpers/succeeds_helper.rb
108
105
  - tests/local/models/directories_tests.rb
109
106
  - tests/local/models/directory_tests.rb
@@ -130,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
127
  version: '0'
131
128
  requirements: []
132
129
  rubyforge_project:
133
- rubygems_version: 2.5.1
130
+ rubygems_version: 2.6.12
134
131
  signing_key:
135
132
  specification_version: 4
136
133
  summary: Module for the 'fog' gem to support local filesystem storage.
@@ -1,98 +0,0 @@
1
- require "fog/schema/data_validator"
2
-
3
- # format related hackery
4
- # allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean)
5
- # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String)
6
- module Fog
7
- module Boolean; end
8
- module Nullable
9
- module Boolean; end
10
- module Integer; end
11
- module String; end
12
- module Time; end
13
- module Float; end
14
- module Hash; end
15
- module Array; end
16
- end
17
- end
18
- [FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)}
19
- [FalseClass, TrueClass, NilClass, Fog::Boolean].each {|klass| klass.send(:include, Fog::Nullable::Boolean)}
20
- [NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)}
21
- [NilClass, Time].each {|klass| klass.send(:include, Fog::Nullable::Time)}
22
- [Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)}
23
- [Float, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Float)}
24
- [Hash, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Hash)}
25
- [Array, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Array)}
26
-
27
- module Shindo
28
- class Tests
29
- # Generates a Shindo test that compares a hash schema to the result
30
- # of the passed in block returning true if they match.
31
- #
32
- # The schema that is passed in is a Hash or Array of hashes that
33
- # have Classes in place of values. When checking the schema the
34
- # value should match the Class.
35
- #
36
- # Strict mode will fail if the data has additional keys. Setting
37
- # +strict+ to +false+ will allow additional keys to appear.
38
- #
39
- # @param [Hash] schema A Hash schema
40
- # @param [Hash] options Options to change validation rules
41
- # @option options [Boolean] :allow_extra_keys
42
- # If +true+ does not fail when keys are in the data that are
43
- # not specified in the schema. This allows new values to
44
- # appear in API output without breaking the check.
45
- # @option options [Boolean] :allow_optional_rules
46
- # If +true+ does not fail if extra keys are in the schema
47
- # that do not match the data. Not recommended!
48
- # @yield Data to check with schema
49
- #
50
- # @example Using in a test
51
- # Shindo.tests("comparing welcome data against schema") do
52
- # data = {:welcome => "Hello" }
53
- # data_matches_schema(:welcome => String) { data }
54
- # end
55
- #
56
- # comparing welcome data against schema
57
- # + data matches schema
58
- #
59
- # @example Example schema
60
- # {
61
- # "id" => String,
62
- # "ram" => Integer,
63
- # "disks" => [
64
- # {
65
- # "size" => Float
66
- # }
67
- # ],
68
- # "dns_name" => Fog::Nullable::String,
69
- # "active" => Fog::Boolean,
70
- # "created" => DateTime
71
- # }
72
- #
73
- # @return [Boolean]
74
- def data_matches_schema(schema, options = {})
75
- test('data matches schema') do
76
- validator = Fog::Schema::DataValidator.new
77
- valid = validator.validate(yield, schema, options)
78
- @message = validator.message unless valid
79
- valid
80
- end
81
- end
82
-
83
- # @deprecated #formats is deprecated. Use #data_matches_schema instead
84
- def formats(format, strict = true)
85
- test('has proper format') do
86
- if strict
87
- options = {:allow_extra_keys => false, :allow_optional_rules => true}
88
- else
89
- options = {:allow_extra_keys => true, :allow_optional_rules => true}
90
- end
91
- validator = Fog::Schema::DataValidator.new
92
- valid = validator.validate(yield, format, options)
93
- @message = validator.message unless valid
94
- valid
95
- end
96
- end
97
- end
98
- end
@@ -1,110 +0,0 @@
1
- Shindo.tests('test_helper', 'meta') do
2
-
3
- tests('comparing welcome data against schema') do
4
- data = {:welcome => "Hello" }
5
- data_matches_schema(:welcome => String) { data }
6
- end
7
-
8
- tests('#data_matches_schema') do
9
- tests('when value matches schema expectation') do
10
- data_matches_schema({"key" => String}) { {"key" => "Value"} }
11
- end
12
-
13
- tests('when values within an array all match schema expectation') do
14
- data_matches_schema({"key" => [Integer]}) { {"key" => [1, 2]} }
15
- end
16
-
17
- tests('when nested values match schema expectation') do
18
- data_matches_schema({"key" => {:nested_key => String}}) { {"key" => {:nested_key => "Value"}} }
19
- end
20
-
21
- tests('when collection of values all match schema expectation') do
22
- data_matches_schema([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] }
23
- end
24
-
25
- tests('when collection is empty although schema covers optional members') do
26
- data_matches_schema([{"key" => String}], {:allow_optional_rules => true}) { [] }
27
- end
28
-
29
- tests('when additional keys are passed and not strict') do
30
- data_matches_schema({"key" => String}, {:allow_extra_keys => true}) { {"key" => "Value", :extra => "Bonus"} }
31
- end
32
-
33
- tests('when value is nil and schema expects NilClass') do
34
- data_matches_schema({"key" => NilClass}) { {"key" => nil} }
35
- end
36
-
37
- tests('when value and schema match as hashes') do
38
- data_matches_schema({}) { {} }
39
- end
40
-
41
- tests('when value and schema match as arrays') do
42
- data_matches_schema([]) { [] }
43
- end
44
-
45
- tests('when value is a Time') do
46
- data_matches_schema({"time" => Time}) { {"time" => Time.now} }
47
- end
48
-
49
- tests('when key is missing but value should be NilClass (#1477)') do
50
- data_matches_schema({"key" => NilClass}, {:allow_optional_rules => true}) { {} }
51
- end
52
-
53
- tests('when key is missing but value is nullable (#1477)') do
54
- data_matches_schema({"key" => Fog::Nullable::String}, {:allow_optional_rules => true}) { {} }
55
- end
56
- end
57
-
58
- tests('#formats backwards compatible changes') do
59
-
60
- tests('when value matches schema expectation') do
61
- formats({"key" => String}) { {"key" => "Value"} }
62
- end
63
-
64
- tests('when values within an array all match schema expectation') do
65
- formats({"key" => [Integer]}) { {"key" => [1, 2]} }
66
- end
67
-
68
- tests('when nested values match schema expectation') do
69
- formats({"key" => {:nested_key => String}}) { {"key" => {:nested_key => "Value"}} }
70
- end
71
-
72
- tests('when collection of values all match schema expectation') do
73
- formats([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] }
74
- end
75
-
76
- tests('when collection is empty although schema covers optional members') do
77
- formats([{"key" => String}]) { [] }
78
- end
79
-
80
- tests('when additional keys are passed and not strict') do
81
- formats({"key" => String}, false) { {"key" => "Value", :extra => "Bonus"} }
82
- end
83
-
84
- tests('when value is nil and schema expects NilClass') do
85
- formats({"key" => NilClass}) { {"key" => nil} }
86
- end
87
-
88
- tests('when value and schema match as hashes') do
89
- formats({}) { {} }
90
- end
91
-
92
- tests('when value and schema match as arrays') do
93
- formats([]) { [] }
94
- end
95
-
96
- tests('when value is a Time') do
97
- formats({"time" => Time}) { {"time" => Time.now} }
98
- end
99
-
100
- tests('when key is missing but value should be NilClass (#1477)') do
101
- formats({"key" => NilClass}) { {} }
102
- end
103
-
104
- tests('when key is missing but value is nullable (#1477)') do
105
- formats({"key" => Fog::Nullable::String}) { {} }
106
- end
107
-
108
- end
109
-
110
- end
@@ -1,107 +0,0 @@
1
- Shindo.tests('Fog::Schema::DataValidator', 'meta') do
2
-
3
- validator = Fog::Schema::DataValidator.new
4
-
5
- tests('#validate') do
6
-
7
- tests('returns true') do
8
-
9
- returns(true, 'when value matches schema expectation') do
10
- validator.validate({"key" => "Value"}, {"key" => String})
11
- end
12
-
13
- returns(true, 'when values within an array all match schema expectation') do
14
- validator.validate({"key" => [1, 2]}, {"key" => [Integer]})
15
- end
16
-
17
- returns(true, 'when nested values match schema expectation') do
18
- validator.validate({"key" => {:nested_key => "Value"}}, {"key" => {:nested_key => String}})
19
- end
20
-
21
- returns(true, 'when collection of values all match schema expectation') do
22
- validator.validate([{"key" => "Value"}, {"key" => "Value"}], [{"key" => String}])
23
- end
24
-
25
- returns(true, 'when collection is empty although schema covers optional members') do
26
- validator.validate([], [{"key" => String}])
27
- end
28
-
29
- returns(true, 'when additional keys are passed and not strict') do
30
- validator.validate({"key" => "Value", :extra => "Bonus"}, {"key" => String}, {:allow_extra_keys => true})
31
- end
32
-
33
- returns(true, 'when value is nil and schema expects NilClass') do
34
- validator.validate({"key" => nil}, {"key" => NilClass})
35
- end
36
-
37
- returns(true, 'when value and schema match as hashes') do
38
- validator.validate({}, {})
39
- end
40
-
41
- returns(true, 'when value and schema match as arrays') do
42
- validator.validate([], [])
43
- end
44
-
45
- returns(true, 'when value is a Time') do
46
- validator.validate({"time" => Time.now}, {"time" => Time})
47
- end
48
-
49
- returns(true, 'when key is missing but value should be NilClass (#1477)') do
50
- validator.validate({}, {"key" => NilClass}, {:allow_optional_rules => true})
51
- end
52
-
53
- returns(true, 'when key is missing but value is nullable (#1477)') do
54
- validator.validate({}, {"key" => Fog::Nullable::String}, {:allow_optional_rules => true})
55
- end
56
-
57
- end
58
-
59
- tests('returns false') do
60
-
61
- returns(false, 'when value does not match schema expectation') do
62
- validator.validate({"key" => nil}, {"key" => String})
63
- end
64
-
65
- returns(false, 'when key formats do not match') do
66
- validator.validate({"key" => "Value"}, {:key => String})
67
- end
68
-
69
- returns(false, 'when additional keys are passed and strict') do
70
- validator.validate({"key" => "Missing"}, {})
71
- end
72
-
73
- returns(false, 'when some keys do not appear') do
74
- validator.validate({}, {"key" => String})
75
- end
76
-
77
- returns(false, 'when collection contains a member that does not match schema') do
78
- validator.validate([{"key" => "Value"}, {"key" => 5}], [{"key" => String}])
79
- end
80
-
81
- returns(false, 'when collection has multiple schema patterns') do
82
- validator.validate([{"key" => "Value"}], [{"key" => Integer}, {"key" => String}])
83
- end
84
-
85
- returns(false, 'when hash and array are compared') do
86
- validator.validate({}, [])
87
- end
88
-
89
- returns(false, 'when array and hash are compared') do
90
- validator.validate([], {})
91
- end
92
-
93
- returns(false, 'when a hash is expected but another data type is found') do
94
- validator.validate({"key" => {:nested_key => []}}, {"key" => {:nested_key => {}}})
95
- end
96
-
97
- returns(false, 'when key is missing but value should be NilClass (#1477)') do
98
- validator.validate({}, {"key" => NilClass}, {:allow_optional_rules => false})
99
- end
100
-
101
- returns(false, 'when key is missing but value is nullable (#1477)') do
102
- validator.validate({}, {"key" => Fog::Nullable::String}, {:allow_optional_rules => false})
103
- end
104
-
105
- end
106
- end
107
- end