fedux_org-stdlib 0.0.31 → 0.0.32

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.
@@ -47,7 +47,7 @@ module FeduxOrg
47
47
 
48
48
  # Create directory(ies)
49
49
  #
50
- # @param [String,Array] dir
50
+ # @param [String,Array] dirs
51
51
  # the directories to be created, multiple arguments are possible as well
52
52
  #
53
53
  # @return [String,Array]
@@ -68,7 +68,7 @@ module FeduxOrg
68
68
 
69
69
  # Delete directory(ies)
70
70
  #
71
- # @param [String, Array] dir
71
+ # @param [String, Array] dirs
72
72
  # the directories to be deleted, multiple arguments are possible as well
73
73
  #
74
74
  # @return [String,Array]
@@ -114,7 +114,7 @@ module FeduxOrg
114
114
 
115
115
  # Create a single file
116
116
  #
117
- # @param [String] file_path
117
+ # @param [String] path
118
118
  # the path for the new file (can include directories)
119
119
  #
120
120
  # @param [String] content
@@ -140,14 +140,11 @@ module FeduxOrg
140
140
 
141
141
  # Delete a single file
142
142
  #
143
- # @param [String] file_path
143
+ # @param [String] files
144
144
  # the path for the new file (can include directories)
145
145
  #
146
- # @param [String] content
147
- # the content written to the file
148
- #
149
146
  # @return [String]
150
- # the path to the created file
147
+ # the path to the deleted file
151
148
  def delete_file(*files)
152
149
  raise_if_forbidden_path_for_delete_operation(files)
153
150
 
@@ -163,7 +160,7 @@ module FeduxOrg
163
160
 
164
161
  # Read the content of a file
165
162
  #
166
- # @param [String] file_path
163
+ # @param [String] path
167
164
  # the path to the file
168
165
  #
169
166
  # @return [String,Binary]
@@ -236,7 +233,7 @@ module FeduxOrg
236
233
  # @param [Array, String] paths
237
234
  # the paths to be checked
238
235
  #
239
- # @result [TrueClass, FalseClass]
236
+ # @return [TrueClass, FalseClass]
240
237
  # true if path is valid, false if invalid
241
238
  def path_matches?(strings, regex, *paths)
242
239
  flattend_paths = paths.flatten
@@ -19,6 +19,8 @@ module FeduxOrg
19
19
  YesNoConverter.new
20
20
  when 'on_off'
21
21
  OnOffConverter.new
22
+ when 'y_n'
23
+ YNConverter.new
22
24
  else
23
25
  raise FeduxOrg::Stdlib::LogicConverters::Exceptions::InvalidType, "Unknown type \"#{type}\" for logic converter. Valid types are \"true_false\", \"yes_no\" or \"on_off\"."
24
26
  end
@@ -9,6 +9,15 @@ module FeduxOrg
9
9
  # the logic value which should be converted
10
10
  # @return [String]
11
11
  # the converted value: true => on, false => off, '' => nil
12
+ #
13
+ # @example Parse true
14
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
15
+ # converter.parse( true ) # on
16
+ #
17
+ # @example Parse false
18
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
19
+ # converter.parse( false ) # off
20
+ #
12
21
  def parse( value )
13
22
  case value
14
23
  when true
@@ -9,6 +9,14 @@ module FeduxOrg
9
9
  # the logic value which should be converted
10
10
  # @return [String]
11
11
  # the converted value: true => 'true', false => 'false', '' => nil
12
+ #
13
+ # @example Parse true
14
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
15
+ # converter.parse( true ) # 'true'
16
+ #
17
+ # @example Parse false
18
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
19
+ # converter.parse( false ) # 'false'
12
20
  def parse( value )
13
21
  case value
14
22
  when true
@@ -0,0 +1,35 @@
1
+ require 'fedux_org/stdlib/logic_converters/exceptions'
2
+
3
+ module FeduxOrg
4
+ module Stdlib
5
+ module LogicConverters
6
+ class YNConverter
7
+
8
+ # @param [true,false] value
9
+ # the logic value which should be converted
10
+ # @return [String]
11
+ # the converted value: true => y, false => n, '' => nil
12
+ #
13
+ # @example Parse true
14
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
15
+ # converter.parse( true ) # 'y'
16
+ #
17
+ # @example Parse false
18
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
19
+ # converter.parse( false ) # 'n'
20
+ def parse( value )
21
+ case value
22
+ when true
23
+ 'y'
24
+ when false
25
+ 'n'
26
+ when ''
27
+ nil
28
+ else
29
+ raise FeduxOrg::Stdlib::LogicConverters::Exceptions::InvalidValue, "Unknown logic value \"#{value}\"."
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -8,6 +8,15 @@ module FeduxOrg
8
8
  # the logic value which should be converted
9
9
  # @return [String]
10
10
  # the converted value: true => yes, false => no, '' => nil
11
+ #
12
+ # @example Parse true
13
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
14
+ # converter.parse( true ) # 'yes'
15
+ #
16
+ # @example Parse false
17
+ # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
18
+ # converter.parse( false ) # 'no'
19
+ #
11
20
  def parse( value )
12
21
  case value
13
22
  when true
@@ -1,6 +1,6 @@
1
1
  #main FeduxOrg
2
2
  module FeduxOrg
3
3
  module Stdlib
4
- VERSION = '0.0.31'
4
+ VERSION = '0.0.32'
5
5
  end
6
6
  end
@@ -0,0 +1,17 @@
1
+ require 'fedux_org/stdlib/logic_converters/y_n_converter'
2
+
3
+ describe FeduxOrg::Stdlib::LogicConverters::YNConverter do
4
+ let( :converter ) { FeduxOrg::Stdlib::LogicConverters::YNConverter.new }
5
+
6
+ context '#parse' do
7
+ it 'converts true to on' do
8
+ result = converter.parse( true )
9
+ expect( result ).to eq( 'y' )
10
+ end
11
+
12
+ it 'converts false to off' do
13
+ result = converter.parse( false )
14
+ expect( result ).to eq( 'n' )
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedux_org-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -95,6 +95,7 @@ files:
95
95
  - lib/fedux_org/stdlib/logic_converters/logic_converter.rb
96
96
  - lib/fedux_org/stdlib/logic_converters/on_off_converter.rb
97
97
  - lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
98
+ - lib/fedux_org/stdlib/logic_converters/y_n_converter.rb
98
99
  - lib/fedux_org/stdlib/logic_converters/yes_no_converter.rb
99
100
  - lib/fedux_org/stdlib/models.rb
100
101
  - lib/fedux_org/stdlib/models/base_model.rb
@@ -141,6 +142,7 @@ files:
141
142
  - spec/examples/models/filesystem_based/find_files/cde.rb
142
143
  - spec/logic_converters/on_off_converter_spec.rb
143
144
  - spec/logic_converters/true_false_converter_spec.rb
145
+ - spec/logic_converters/y_n_converter_spec.rb
144
146
  - spec/logic_converters/yes_no_converter_spec.rb
145
147
  - spec/models/base_model_spec.rb
146
148
  - spec/models/class_based_model_spec.rb
@@ -187,6 +189,7 @@ test_files:
187
189
  - spec/examples/models/filesystem_based/find_files/cde.rb
188
190
  - spec/logic_converters/on_off_converter_spec.rb
189
191
  - spec/logic_converters/true_false_converter_spec.rb
192
+ - spec/logic_converters/y_n_converter_spec.rb
190
193
  - spec/logic_converters/yes_no_converter_spec.rb
191
194
  - spec/models/base_model_spec.rb
192
195
  - spec/models/class_based_model_spec.rb