include_with_respect 1.0.1 → 1.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.
@@ -2,4 +2,4 @@ module ActiveRecord
2
2
  class Base
3
3
  include IncludeWithRespect::ModuleWithRespect
4
4
  end
5
- end
5
+ end
@@ -4,4 +4,4 @@ module ActiveSupport
4
4
  base.send(:include, IncludeWithRespect::ModuleWithRespect)
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -1,3 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IncludeWithRespect
2
- VERSION = '1.0.1'.freeze
4
+ # Version namespace for this gem.
5
+ module Version
6
+ # Current gem version.
7
+ VERSION = "1.0.3"
8
+ end
9
+ # Current gem version exposed at the traditional constant location.
10
+ VERSION = Version::VERSION # Traditional Constant Location
3
11
  end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'include_with_respect/version'
4
- require 'include_with_respect/configuration'
3
+ require "include_with_respect/configuration"
5
4
 
6
5
  # How to automatically inject into ActiveSupport::Concern,
7
6
  # or other module dependency trees?
8
7
  # Refer to inline documentation in each file.
9
- require 'include_with_respect/module_with_respect'
10
- require 'include_with_respect/concern_with_respect' if defined?(ActiveSupport)
8
+ require "include_with_respect/module_with_respect"
9
+ require_relative "include_with_respect/version"
10
+
11
+ require "include_with_respect/concern_with_respect" if defined?(ActiveSupport)
11
12
 
12
13
  # [Sometimes] We should respect our ancestors.
13
14
  #
@@ -23,18 +24,16 @@ module IncludeWithRespect
23
24
  class Error < StandardError; end
24
25
 
25
26
  def include_with_respect(receiver, module1, *smth)
26
- @skip_include = false
27
- have_respect('included', receiver, module1, *smth) if receiver.include?(module1)
27
+ skip = receiver.include?(module1) && have_respect("included", receiver, module1, *smth)
28
28
 
29
- receiver.send(:include_without_respect, module1, *smth) unless @skip_include
29
+ receiver.send(:include_without_respect, module1, *smth) unless skip
30
30
  end
31
31
  module_function :include_with_respect
32
32
 
33
33
  def extend_with_respect(receiver, module1, *smth)
34
- @skip_include = false
35
- have_respect('extended', receiver, module1, skip, *smth) if receiver.singleton_class.include?(module1)
34
+ skip = receiver.singleton_class.include?(module1) && have_respect("extended", receiver, module1, *smth)
36
35
 
37
- receiver.send(:extend_without_respect, module1, *smth) unless @skip_include
36
+ receiver.send(:extend_without_respect, module1, *smth) unless skip
38
37
  end
39
38
  module_function :extend_with_respect
40
39
 
@@ -57,18 +56,19 @@ module IncludeWithRespect
57
56
  private
58
57
 
59
58
  def have_respect(action, receiver, module1, *smth)
60
- message = "#{module1}#{smth.any? ? " with #{smth}" : ''} already #{action} in #{receiver}"
59
+ message = "#{module1}#{" with #{smth}" if smth.any?} already #{action} in #{receiver}"
61
60
  puts "message: #{message}" if configuration.level == [:error]
62
- configuration.level.each do |level|
61
+ configuration.level.any? do |level|
63
62
  case level
64
63
  when :error
65
64
  raise ::IncludeWithRespect::Error, message
66
65
  when :warning
67
66
  puts message
68
67
  when :skip
69
- @skip_include = true
68
+ true
70
69
  else # :silent
71
70
  # NOOP
71
+ false
72
72
  end
73
73
  end
74
74
  end
@@ -0,0 +1,12 @@
1
+ module IncludeWithRespect
2
+ module Version
3
+ VERSION: String
4
+ end
5
+ VERSION: String
6
+ module Error
7
+ module Version
8
+ VERSION: String
9
+ end
10
+ VERSION: String
11
+ end
12
+ end
data.tar.gz.sig ADDED
Binary file