skn_utils 4.0.1 → 4.0.3

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: a3753d9ee00c1e673e9a0871893dcb890daf35f0
4
- data.tar.gz: d4c099ccade3b20002992624012fc5281f5e7901
3
+ metadata.gz: 3b781eb4f6fba46c539596b6c1b6a680406c45e2
4
+ data.tar.gz: 982c1dc1cb0537726c1869787ed9253cd0183fb7
5
5
  SHA512:
6
- metadata.gz: 4bba7536ad36ebcfb79bf9dd4f73757de8ce7c56ea99f6227dfcd5b29c3464e5c2d807c34cb1668c266aed078c80c4e15aefa98d1b75aa3606ee6edf67ad0f79
7
- data.tar.gz: 5f41b41a42d3f15197122936145357e89109411f126c189c92f6bb33d1a240c74769e0bdccd529073934fd8d30fc58da9c9dc8740969934446ef7da5c0223a8b
6
+ metadata.gz: 9530d15532ebf9018bef8efc1969bef703f554be3095ef6acb2c9b90290f852ee6b5501084ca70b853d650055af50b1702f5977e7c926839bf26172cc61cf611
7
+ data.tar.gz: 19785e5090992c7baa117d3835b6fcf161b30ebd67e04c192aabe9511283d034d66508abeb78909291dc7bc28fcdaa7048d4b5ae20ca1b68e396db6c9ef0f499
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.4.1
1
+ ruby-2.4.2
data/README.md CHANGED
@@ -55,6 +55,9 @@ There are many more use cases for Ruby's Hash that this gem just makes easier to
55
55
  * SknUtils::CoreObjectExtensions
56
56
 
57
57
  ## History
58
+ 02/04/2018 V4.0.2
59
+ Added `bin/install` to copy default settings.yml files to the project's config directory
60
+
58
61
  02/04/2018 V4.0.0
59
62
  Added SknUtils::CoreObjectExtensions, this module contains those popular Rails ActiveSupport extensions like `:present?`.
60
63
  - However, it is contructed with the Ruby `:refine` and `using SknUtils::CoreObjectExtensions` constraints, so as not to intefer with existing monkey-patches.
@@ -0,0 +1,4 @@
1
+ test.yml---
2
+ Packaging:
3
+ isDevelopment: true
4
+ configName: development
@@ -0,0 +1,4 @@
1
+ ---
2
+ Packaging:
3
+ isProduction: true
4
+ configName: production
@@ -0,0 +1,4 @@
1
+ ---
2
+ Packaging:
3
+ isStaging: true
4
+ configName: stage
@@ -0,0 +1,3 @@
1
+ ---
2
+ Packaging:
3
+ configName: test.local
@@ -0,0 +1,4 @@
1
+ ---
2
+ Packaging:
3
+ isTest: true
4
+ configName: test
@@ -0,0 +1,14 @@
1
+ ---
2
+ Packaging:
3
+ pomVersion: 1.0.0
4
+ isTest: false
5
+ isDevelopment: false
6
+ isStaging: false
7
+ isProduction: false
8
+ configName: default
9
+ short_name: skn
10
+
11
+ # Create a EnvStringHandler to support: SknSettings.env.development?
12
+ # Yes, its YAML trick
13
+ env: !ruby/string:SknUtils::EnvStringHandler <%= ENV['RACK_ENV'] %>
14
+ root: <%= Dir.pwd %>
data/bin/console CHANGED
@@ -3,5 +3,6 @@
3
3
  require 'bundler/setup'
4
4
  require 'skn_utils'
5
5
 
6
+
6
7
  require 'pry'
7
8
  Pry.start
data/bin/install ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'thor'
5
+ require 'thor/group'
6
+
7
+ class InstallCommand < Thor::Group
8
+ include Thor::Actions
9
+
10
+ # Define arguments and options
11
+ argument :dir_name, :default => 'config'
12
+
13
+ desc "Install SknSettings YAML files."
14
+
15
+ def self.source_root
16
+ File.expand_path('bin', Dir.pwd)
17
+ end
18
+
19
+ def copy_app_settings_directory
20
+ directory 'configs', "#{dir_name}/", :verbose => true
21
+ end
22
+
23
+ end
24
+
25
+ InstallCommand.start
@@ -17,6 +17,7 @@
17
17
  # in config/settings.yml
18
18
  # ...
19
19
  # env: !ruby/string:SknUtils::EnvStringHandler <%= ENV['RACK_ENV'] %>
20
+ # root: !ruby/string:SknUtils::EnvStringHandler <%= Dir.pwd %>
20
21
  # ...
21
22
  # #
22
23
  module SknUtils
@@ -24,15 +25,22 @@ module SknUtils
24
25
  private
25
26
 
26
27
  def respond_to_missing?(method_name, _include_private = false)
27
- method_name[-1] == '?'
28
+ method_name[-1] == '?' || method_name.to_s.eql?('join') || super
28
29
  end
29
30
 
30
31
  def method_missing(method_name, *arguments)
31
32
  if method_name[-1] == '?'
32
33
  self == method_name[0..-2]
34
+
35
+ # Only handle the :join method, else to super
36
+ elsif Pathname.public_instance_methods(false).include?(method_name)
37
+ method_name.to_s.eql?('join') ?
38
+ Pathname(self).send(method_name, *arguments).realdirpath.to_s : super
39
+
33
40
  else
34
41
  super
35
42
  end
36
43
  end
44
+
37
45
  end
38
46
  end
@@ -338,10 +338,11 @@ module SknUtils
338
338
  elsif method.to_s.end_with?('?') # order of tests is significant,
339
339
  attribute?(method_nsym)
340
340
 
341
- else # TODO: replace following with nil to match OpenStruct behavior when key not found
342
- e = NoMethodError.new "undefined method `#{method}' for #{self.class.name}", method, args
343
- e.set_backtrace caller(1)
344
- raise e
341
+ else # TODO: replace following with nil to match OpenStruct or Hash behavior when key not found
342
+ nil
343
+ # e = NoMethodError.new "undefined method `#{method}' for #{self.class.name}", method, args
344
+ # e.set_backtrace caller(1)
345
+ # raise e
345
346
 
346
347
  end
347
348
  end # end method_missing: errors from enable_dot..., initialize_hash..., and attribute? are possible
@@ -3,7 +3,7 @@ module SknUtils
3
3
  class Version
4
4
  MAJOR = 4
5
5
  MINOR = 0
6
- PATCH = 1
6
+ PATCH = 3
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
data/skn_utils.gemspec CHANGED
@@ -32,6 +32,7 @@ EOF
32
32
 
33
33
  spec.add_runtime_dependency 'deep_merge', '~> 1'
34
34
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1'
35
+ spec.add_runtime_dependency 'thor', '~> 0'
35
36
 
36
37
  spec.add_development_dependency "bundler", "~> 1"
37
38
  spec.add_development_dependency "rake", "~> 10"
@@ -11,5 +11,5 @@ Packaging:
11
11
  # Create a EnvStringHandler to support: SknSettings.env.development?
12
12
  # Yes, its YAML trick
13
13
  env: !ruby/string:SknUtils::EnvStringHandler <%= ENV['RACK_ENV'] %>
14
- root: <%= Dir.pwd %>
14
+ root: !ruby/string:SknUtils::EnvStringHandler <%= Dir.pwd %>
15
15
 
@@ -110,7 +110,8 @@ RSpec.shared_examples 'plain old ruby object' do
110
110
  end
111
111
 
112
112
  it 'Raises NoMethodError in response to invalid key access' do
113
- expect{object.sixty_two}.to raise_exception(NoMethodError)
113
+ expect{object.sixty_two}.not_to raise_exception
114
+ expect(object.sixty_two).to be_nil
114
115
  end
115
116
 
116
117
  context '#attribute? present? like feature operates as expected' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skn_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Scott Jr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +147,6 @@ extra_rdoc_files: []
133
147
  files:
134
148
  - ".gitignore"
135
149
  - ".rspec"
136
- - ".ruby-gemset"
137
150
  - ".ruby-version"
138
151
  - CODE_OF_CONDUCT.md
139
152
  - Gemfile
@@ -143,7 +156,14 @@ files:
143
156
  - Rakefile
144
157
  - _config.yml
145
158
  - bin/bench_nested_result.rb
159
+ - bin/configs/settings.yml
160
+ - bin/configs/settings/development.yml
161
+ - bin/configs/settings/production.yml
162
+ - bin/configs/settings/stage.yml
163
+ - bin/configs/settings/test.local.yml
164
+ - bin/configs/settings/test.yml
146
165
  - bin/console
166
+ - bin/install
147
167
  - lib/skn_container.rb
148
168
  - lib/skn_hash.rb
149
169
  - lib/skn_settings.rb
@@ -191,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
211
  version: '0'
192
212
  requirements: []
193
213
  rubyforge_project:
194
- rubygems_version: 2.6.11
214
+ rubygems_version: 2.6.14
195
215
  signing_key:
196
216
  specification_version: 4
197
217
  summary: SknUtils contains a small collection of Ruby utilities, the first being a
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- SknUtils