cliutils 2.0.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c6e6e5b1a7f34b7dcfa6c887f2d1a704379f667
4
- data.tar.gz: 67434a07cf330007da7640ee0e73f20355c70133
3
+ metadata.gz: fdf67aa4209a6fcb36db63a0b84313c539c7d2f3
4
+ data.tar.gz: c180f98c6075639be2c28ab114ea2b331abaf111
5
5
  SHA512:
6
- metadata.gz: 86e74f6a482775f620e316fecf3e96cf5bb6e8ef3f0afb447f41d5cfb5069482e76238bd9bd882b0808baa1c0847778094d1b3dedd0338ad6512d3529efa24e3
7
- data.tar.gz: a33d59a428bbd13e22f972ec9f56718fece03e952124171dd454046c7494253382551e1ef7aa678cfbf22d79b4fbe7772745c492914f939f4f1c97b555f8a024
6
+ metadata.gz: fa8a999f929b9bd694983ce2e4f2e6430ec1c8c21bb03b715d1fe8215e40cccc4c55df1e7d95ac968fe4099fd1ab250d078eb909d67580056980ed584207c0af
7
+ data.tar.gz: 41f09163ab9109af87277c860cdd0955d1382bef320b151206882e31074af675098de80ba3139325cea8de81b5aed41f288231f07d87a5a7ee225492c52ecc78
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.0.2 (2014-04-16)
2
+
3
+ * Created backup method in Configurator
4
+ * Modified YARD documentation
5
+
1
6
  # 2.0.1 (2014-04-16)
2
7
 
3
8
  * Modified PrettyIO word wrapping to coerce to String first
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'yaml'
2
3
 
3
4
  module CLIUtils
@@ -55,6 +56,18 @@ module CLIUtils
55
56
  end
56
57
  end
57
58
 
59
+ # Convenience method to backup the configuration file
60
+ # in the same directory that the original inhabits.
61
+ # @return [String] The backed-up filepath
62
+ def backup
63
+ backup_path = ''
64
+ unless @config_path.nil? || @config_path.empty?
65
+ backup_path = "#{ @config_path }-#{ Time.now.to_i }"
66
+ FileUtils.cp(@config_path, backup_path)
67
+ end
68
+ backup_path
69
+ end
70
+
58
71
  # Compares the current version (if it exists) to
59
72
  # the last version that needed a configuration
60
73
  # change (if it exists). Assuming they exist and
@@ -97,7 +110,7 @@ module CLIUtils
97
110
  # Hook that fires when a non-existent method is called.
98
111
  # Allows this module to return data from the config
99
112
  # Hash when given a method name that matches a key.
100
- # @return [Hash]
113
+ # @return [Hash] The hash with the method's name as key
101
114
  def method_missing(name, *args, &block)
102
115
  @data[name.to_sym] || @data.merge!(name.to_sym => {})
103
116
  end
@@ -1,5 +1,5 @@
1
1
  # Stores constants to use.
2
2
  module CLIUtils
3
3
  # The current version of the gem
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  end
@@ -5,7 +5,7 @@ class Hash
5
5
  # Deep merges a hash into the current one.
6
6
  # @param [Hash] other_hash The hash to merge in
7
7
  # @yield &block
8
- # @return [Hash]
8
+ # @return [Hash] The original Hash
9
9
  def deep_merge!(other_hash, &block)
10
10
  other_hash.each_pair do |k, v|
11
11
  tv = self[k]
@@ -20,28 +20,28 @@ class Hash
20
20
 
21
21
  # Recursively turns all Hash keys into strings and
22
22
  # returns the new Hash.
23
- # @return [Hash]
23
+ # @return [Hash] A new copy of the original Hash
24
24
  def deep_stringify_keys
25
25
  deep_transform_keys { |key| key.to_s }
26
26
  end
27
27
 
28
28
  # Same as deep_stringify_keys, but destructively
29
29
  # alters the original Hash.
30
- # @return [Hash]
30
+ # @return [Hash] The original Hash
31
31
  def deep_stringify_keys!
32
32
  deep_transform_keys! { |key| key.to_s }
33
33
  end
34
34
 
35
35
  # Recursively turns all Hash keys into symbols and
36
36
  # returns the new Hash.
37
- # @return [Hash]
37
+ # @return [Hash] A new copy of the original Hash
38
38
  def deep_symbolize_keys
39
39
  deep_transform_keys { |key| key.to_sym rescue key }
40
40
  end
41
41
 
42
42
  # Same as deep_symbolize_keys, but destructively
43
43
  # alters the original Hash.
44
- # @return [Hash]
44
+ # @return [Hash] The original Hash
45
45
  def deep_symbolize_keys!
46
46
  deep_transform_keys! { |key| key.to_sym rescue key }
47
47
  end
@@ -49,7 +49,7 @@ class Hash
49
49
  # Generic method to perform recursive operations on a
50
50
  # Hash.
51
51
  # @yield &block
52
- # @return [Hash]
52
+ # @return [Hash] A new copy of the original Hash
53
53
  def deep_transform_keys(&block)
54
54
  _deep_transform_keys_in_object(self, &block)
55
55
  end
@@ -57,7 +57,7 @@ class Hash
57
57
  # Same as deep_transform_keys, but destructively
58
58
  # alters the original Hash.
59
59
  # @yield &block
60
- # @return [Hash]
60
+ # @return [Hash] The original Hash
61
61
  def deep_transform_keys!(&block)
62
62
  _deep_transform_keys_in_object!(self, &block)
63
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Bach