app_config_for 0.0.6.1 → 0.0.6.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
  SHA256:
3
- metadata.gz: 7f85a6a8ca8b5be3a0fcbccc544519908b2f257760199a6f49c06a3100824692
4
- data.tar.gz: 6de1a37f3f917450a3214fd4ba98e70d5ce2eed0485933470cc2e072b1f89e0e
3
+ metadata.gz: 12be8423d59d7901c58655092ddd1a35408b853e4d025943a38c0d5f59c33048
4
+ data.tar.gz: f6a1e5432c5aaf95e50881049a1040ca4311429ec73cc322635a28c255a6f703
5
5
  SHA512:
6
- metadata.gz: 4d3810ce467896ea6d8165a8a313066c2d2d8947c07e39843bdc7886ad072e6eef29ea309d2505a67b902b2d3b0a14fdde8025a0c00c6d26092583b6fe505cd5
7
- data.tar.gz: 3b6c650d56e7624e673d4a840d24970e9428744478c7ac9399f398bdd6fc39ac92ad1470cb6209bae26e17c2eebfa0c200be30d8823990c79257348508b0c573
6
+ metadata.gz: 7fa3fa1e7bc2becdded7a85c0d64809fb4c19a8684c035418e745b6bccb0a25344d62960f9babf4ad4c54a581245d60d3748210f2bc3911f73951a645102f103
7
+ data.tar.gz: bc6fff79b9a1dfe781f81481fc84fb2ef41f1738dd80ea7e049b08050e2a832dfcb80b57f3004d094cafac531732d3c94dfcc5c5932d0cd2b571d988bf551350
data/CHANGELOG.md CHANGED
@@ -45,4 +45,8 @@
45
45
  - Requesting configuration for another object that can supply it's own config_files will use those files instead of locally determining them.
46
46
 
47
47
  ## [0.0.6.1] - 2022-04-25
48
- - Fixed issue when initializing env_prefixes in a namespaced module/class.
48
+ - Fixed issue when initializing env_prefixes in a namespaced module/class.
49
+
50
+ ## [0.0.6.2] - 2022-04-26
51
+ - When namespace_of, prefix_from, and yml_name_from encounter an anonymous class/module, the class hierarchy will be traversed until a name is found.
52
+
@@ -11,7 +11,7 @@ module AppConfigFor
11
11
  MAJOR = 0 # A field-grade officer
12
12
  MINOR = 0 # When the semitones show up as intervals between the 2nd and 3rd degrees
13
13
  TINY = 6 # The number of people who use antidisestablishmentarianism in everyday conversation
14
- PRE = 1 # Ante not auntie
14
+ PRE = 2 # Ante not auntie
15
15
 
16
16
  # String form of the version (duh). Are you seriously reading this? I guess it is slightly more interesting that Moby-Dick.
17
17
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -587,14 +587,7 @@ module AppConfigFor
587
587
  # namespace_of(Some::App.new) # => Some
588
588
  # namespace_of(Some) # => nil
589
589
  def namespace_of(object)
590
- case object
591
- when String
592
- object
593
- when Module
594
- object.name
595
- else
596
- object.class.name
597
- end.deconstantize.safe_constantize
590
+ (String === object ? object : nearest_named_class(object).name).deconstantize.safe_constantize
598
591
  end
599
592
 
600
593
  # Array of all hierarchical lexical namespaces of an object. Uses {.namespace_of}
@@ -613,7 +606,21 @@ module AppConfigFor
613
606
  def namespaces_of(object)
614
607
  (object = [namespace_of(object)]).each { |x| x && object << namespace_of(x) }[0..-2]
615
608
  end
616
-
609
+
610
+ # Locate the nearest class that is not anonymous.
611
+ # @param object [Object]
612
+ # @return [Class] The first non-anonymous class that is in the class hierarchy.
613
+ def nearest_named_class(object)
614
+ # Switch from an instance to a class
615
+ object = object.class unless object.is_a?(Module)
616
+ # Switch from anonymous module to a class unless it provides a name
617
+ object = object.class unless object.try(:name) || object.respond_to?(:superclass)
618
+ # Continue up the hierarchy while we are in an anonymous class
619
+ object = object.superclass while object.name.nil?
620
+ object
621
+ end
622
+
623
+ # Parent of an object.
617
624
  # Parent of an object.
618
625
  # While similar to inheritance it provides a meaningful value for strings and other objects.
619
626
  # Classes return super classes.
@@ -692,14 +699,12 @@ module AppConfigFor
692
699
  object
693
700
  else
694
701
  case object
695
- when Module
696
- object.name
697
702
  when String
698
703
  object
699
704
  when Pathname
700
705
  object.basename('.*').to_s
701
706
  else
702
- object.class.name
707
+ nearest_named_class(object).name
703
708
  end.underscore.gsub('/','_').to_sym
704
709
  end
705
710
  end
@@ -809,18 +814,16 @@ module AppConfigFor
809
814
  object
810
815
  else
811
816
  case object
812
- when Module
813
- object.name
814
817
  when String
815
818
  object
816
819
  when Symbol
817
820
  object.to_s
818
821
  else
819
- object.class.name
822
+ nearest_named_class(object).name
820
823
  end.underscore.gsub('/','_') + '.yml'
821
824
  end
822
825
  end
823
-
826
+
824
827
  private
825
828
 
826
829
  # Add the config directory from the gem installation if this is a gem.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_config_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6.1
4
+ version: 0.0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Hall
@@ -87,8 +87,8 @@ licenses:
87
87
  - MIT
88
88
  metadata:
89
89
  homepage_uri: https://github.com/ChapterHouse/app_config_for
90
- source_code_uri: https://github.com/ChapterHouse/app_config_for/tree/v0.0.6.1
91
- changelog_uri: https://github.com/ChapterHouse/app_config_for/blob/v0.0.6.1/CHANGELOG.md
90
+ source_code_uri: https://github.com/ChapterHouse/app_config_for/tree/v0.0.6.2
91
+ changelog_uri: https://github.com/ChapterHouse/app_config_for/blob/v0.0.6.2/CHANGELOG.md
92
92
  post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths: