Module: RubyNext::Core

Defined in:
lib/ruby-next/core.rb

Defined Under Namespace

Classes: Patch, Patches

Constant Summary collapse

STRATEGIES =
%i[refine core_ext backports].freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.strategyObject

Returns the value of attribute strategy.



107
108
109
# File 'lib/ruby-next/core.rb', line 107

def strategy
  @strategy
end

Class Method Details

.backports?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/ruby-next/core.rb', line 122

def backports?
  strategy == :backports
end

.core_ext?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/ruby-next/core.rb', line 118

def core_ext?
  strategy == :core_ext || strategy == :backports
end

.inject!(contents) ⇒ Object

Inject ‘using RubyNext` at the top of the source code



131
132
133
134
135
136
137
138
# File 'lib/ruby-next/core.rb', line 131

def inject!(contents)
  if contents.frozen?
    contents = contents.sub(/^(\s*[^#\s].*)/, 'using RubyNext;\1')
  else
    contents.sub!(/^(\s*[^#\s].*)/, 'using RubyNext;\1')
  end
  contents
end

.patchObject



126
127
128
# File 'lib/ruby-next/core.rb', line 126

def patch(...)
  patches << Patch.new(...)
end

.patchesObject



140
141
142
# File 'lib/ruby-next/core.rb', line 140

def patches
  @patches ||= Patches.new
end

.refine?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/ruby-next/core.rb', line 114

def refine?
  strategy == :refine
end