ernie-research/MEnvData-SWE huggingface dataset:
Repository: ruby/debug (Ruby)

Issue:
"Skip path" configuration makes VSCode stop at breakpoint, but not jump to definition
**To Reproduce**
- Set a breakpoint
- Configure `skip_path` to include the path of the breakpoint
- Debug in VSCode

**Expected behavior**
The breakpoint should be respected, and VSCode should jump to the definition of where the issue is

**Actual behavior**
The debugger stops, but VSCode can't jump to the definition, because the path is skipped (starting in [[debug/pr/749] 🐛 Respect skip_path when returning the backtrace in ServerDAP](https://github.com/ruby/debug/pull/749))



Discussion:
Wow...



Patch:
diff --git a/lib/debug/server_dap.rb b/lib/debug/server_dap.rb
index 97ff4b45b..c4813440c 100644
--- a/lib/debug/server_dap.rb
+++ b/lib/debug/server_dap.rb
@@ -711,7 +711,7 @@ def process_dap args
           next if i < start_frame
 
           path = frame.realpath || frame.path
-          next if skip_path?(path)
+          next if skip_path?(path) && !SESSION.stop_stepping?(path, frame.location.lineno, SESSION.subsession_id)
           break if (levels -= 1) < 0
           source_name = path ? File.basename(path) : frame.location.to_s
 


Test patch:
diff --git a/test/protocol/call_stack_with_skip_dap_test.rb b/test/protocol/call_stack_with_skip_dap_test.rb
index 52cec55a2..32b94be09 100644
--- a/test/protocol/call_stack_with_skip_dap_test.rb
+++ b/test/protocol/call_stack_with_skip_dap_test.rb
@@ -58,5 +58,21 @@ def test_it_skips_a_path
     ensure
       ENV['RUBY_DEBUG_SKIP_PATH'] = nil
     end
+
+    def test_it_does_not_skip_a_path_if_there_is_a_breakpoint
+      with_extra_tempfile do |extra_file|
+        ENV['RUBY_DEBUG_SKIP_PATH'] = extra_file.path
+        run_protocol_scenario(program(extra_file.path), cdp: false) do
+          req_add_breakpoint 2, path: extra_file.path
+          req_continue
+
+          assert_equal([File.basename(extra_file.path), File.basename(temp_file_path)], req_stacktrace_file_names)
+
+          req_terminate_debuggee
+        end
+      end
+    ensure
+      ENV['RUBY_DEBUG_SKIP_PATH'] = nil
+    end
   end
 end
Repository: Shopify/liquid (Ruby)

Issue:
Summing floats with the `sum` filter
When using the `sum` filter on an array containing floats, we get a `BigDecimal` result, which is rendered in scientific notation.

```ruby
require 'liquid'

template = Liquid::Template.parse("Result: {{ a | sum }}")
puts template.render!({"a" => [0.1, 0.2, 0.3]})
```

**Output**
```text
Result: 0.6e0
```

**Expected output**

```text
Result: 0.6
```

For consistency with existing math filters, would it be possible to convert a `BigDecimal` result to a float, just like the `round`  filter does?

https://github.com/Shopify/liquid/blob/77293d4524c55471dd4268ba3a536031c39ee20e/lib/liquid/standardfilters.rb#L791

Many thanks.


Discussion:

Patch:
diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb
index 661235a9d..0fcd55e58 100644
--- a/lib/liquid/standardfilters.rb
+++ b/lib/liquid/standardfilters.rb
@@ -892,9 +892,11 @@ def sum(input, property = nil)
         raise_property_error(property)
       end
 
-      InputIterator.new(values_for_sum, context).sum do |item|
+      result = InputIterator.new(values_for_sum, context).sum do |item|
         Utils.to_number(item)
       end
+
+      result.is_a?(BigDecimal) ? result.to_f : result
     end
 
     private


Test patch:
diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb
index b2405f7f8..e945ad253 100644
--- a/test/integration/standard_filter_test.rb
+++ b/test/integration/standard_filter_test.rb
@@ -994,6 +994,42 @@ def test_sum_with_property_calls_to_liquid_on_property_values
     assert(t.foo > 0)
   end
 
+  def test_sum_of_floats
+    input = [0.1, 0.2, 0.3]
+    assert_equal(0.6, @filters.sum(input))
+    assert_template_result("0.6", "{{ input | sum }}", { "input" => input })
+  end
+
+  def test_sum_of_negative_floats
+    input = [0.1, 0.2, -0.3]
+    assert_equal(0.0, @filters.sum(input))
+    assert_template_result("0.0", "{{ input | sum }}", { "input" => input })
+  end
+
+  def test_sum_with_float_strings
+    input = [0.1, "0.2", "0.3"]
+    assert_equal(0.6, @filters.sum(input))
+    assert_template_result("0.6", "{{ input | sum }}", { "input" => input })
+  end
+
+  def test_sum_resulting_in_negative_float
+    input = [0.1, -0.2, -0.3]
+    assert_equal(-0.4, @filters.sum(input))
+    assert_template_result("-0.4", "{{ input | sum }}", { "input" => input })
+  end
+
+  def test_sum_with_floats_and_indexable_map_values
+    input = [{ "quantity" => 1 }, { "quantity" => 0.2, "weight" => -0.3 }, { "weight" => 0.4 }]
+    assert_equal(0.0, @filters.sum(input))
+    assert_equal(1.2, @filters.sum(input, "quantity"))
+    assert_equal(0.1, @filters.sum(input, "weight"))
+    assert_equal(0.0, @filters.sum(input, "subtotal"))
+    assert_template_result("0", "{{ input | sum }}", { "input" => input })
+    assert_template_result("1.2", "{{ input | sum: 'quantity' }}", { "input" => input })
+    assert_template_result("0.1", "{{ input | sum: 'weight' }}", { "input" => input })
+    assert_template_result("0", "{{ input | sum: 'subtotal' }}", { "input" => input })
+  end
+
   private
 
   def with_timezone(tz)
Repository: yippee-fun/phlex (Ruby)

Issue:
Phlex::SGML.context broken by #846
#846 broke Phlex::SGML#context since it now refers to `@_state._state` which doesn't exist in the new state class.

I assume it should be referring to `@_state.user_context` instead to match the previous behaviour, but I'm not confident enough in my quick skim of the code to send a patch sorry. 


Discussion:
That sounds right. Sounds like an incorrect find and replace. I want to make sure this goes back with a new test too. Should have been caught.



Patch:
diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb
index 0c38ec33..79a6e036 100644
--- a/lib/phlex/sgml.rb
+++ b/lib/phlex/sgml.rb
@@ -95,7 +95,7 @@ def internal_call(parent: nil, state: nil, &block)
 	end
 
 	def context
-		@_state._state
+		@_state.user_context
 	end
 
 	# Output plain text.


Test patch:
diff --git a/quickdraw/context.test.rb b/quickdraw/context.test.rb
new file mode 100644
index 00000000..2fbae52b
--- /dev/null
+++ b/quickdraw/context.test.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+test "user context passed in from the outside" do
+	example = Class.new(Phlex::HTML) do
+		define_method :view_template do
+			h1 { context[:heading] }
+		end
+	end
+
+	context = { heading: "Hello, World!" }
+	assert_equal_html example.new.call(context:), %(<h1>Hello, World!</h1>)
+end
+
+test "user context passed down" do
+	a = Class.new(Phlex::HTML) do
+		define_method :view_template do
+			h1 { context[:heading] }
+		end
+	end
+
+	b = Class.new(Phlex::HTML) do
+		define_method :view_template do
+			context[:heading] = "Hello, World!"
+			render a.new
+		end
+	end
+
+	assert_equal_html b.new.call, %(<h1>Hello, World!</h1>)
+end
Repository: jhawthorn/vernier (Ruby)

Issue:
undefined method `frame_line_idx' for an instance of Vernier::Result>
Hey hey! I'm trying out Vernier for Sentry so that it could potentially replace StackProf, and my goal is to create an output that has the same structure as StackProf so that it could Just Work with the Sentry backend (at least for a good start).

I looked into the Result class and discovered `each_sample` so I thought I could just use that and then I hit this:

```ruby
result.each_sample { |stack, _| puts stack.frames.map(&:to_s).join("\n") }
#<NoMethodError: undefined method `frame_line_idx' for an instance of Vernier::Result>
```

Seems like a bug?


Discussion:
Thanks for the report! Fixing in https://github.com/jhawthorn/vernier/pull/88
Fix has been included in `1.1.2`.



Patch:
diff --git a/lib/vernier/result.rb b/lib/vernier/result.rb
index 4d433bcf..79ab1740 100644
--- a/lib/vernier/result.rb
+++ b/lib/vernier/result.rb
@@ -102,7 +102,7 @@ def func
       end
 
       def line
-        result.frame_line_idx(idx)
+        result._stack_table.frame_line_no(idx)
       end
 
       def to_s


Test patch:
diff --git a/test/test_retained_memory.rb b/test/test_retained_memory.rb
index c7ec8517..94fe5614 100644
--- a/test/test_retained_memory.rb
+++ b/test/test_retained_memory.rb
@@ -111,13 +111,21 @@ def test_alloc_order
 
     frames = result.each_sample.map {|stack, _| stack.frames[0] }
     labels = frames.map(&:label)
+    inspects = frames.map(&:to_s)
 
-    expected = %W[
+    expected_labels = %W[
       #{self.class.name}#alloc_a
       #{self.class.name}#alloc_b
       #{self.class.name}#alloc_c
     ]
-    assert_equal expected, labels.grep(/#alloc_[abc]\z/)
+    assert_equal expected_labels, labels.grep(/#alloc_[abc]\z/)
+
+    expected_inspects = [
+      "#{self.class.name}#alloc_a at #{method(:alloc_a).source_location.join(":")}",
+      "#{self.class.name}#alloc_b at #{method(:alloc_b).source_location.join(":")}",
+      "#{self.class.name}#alloc_c at #{method(:alloc_c).source_location.join(":")}"
+    ]
+    assert_equal expected_inspects, inspects.grep(/#alloc_[abc]/)
   end
 
   def test_nothing_retained_in_module_eval
@@ -166,15 +174,9 @@ def build_large_module
     nil
   end
 
-  def alloc_a
-    Object.new
-  end
+  def alloc_a = Object.new
 
-  def alloc_b
-    Object.new
-  end
+  def alloc_b = Object.new
 
-  def alloc_c
-    Object.new
-  end
+  def alloc_c = Object.new
 end
Repository: ruby/rdoc (Ruby)

Issue:
Invalid HTML being generated.
On this page:

https://docs.ruby-lang.org/en/2.7.0/Array.html

```
<p>Items can be added to the end of an array by using either <a href="Array.html#method-i-push"><code>push</code></a> or <a href="Array.html#method-i-3C-3C"><code><<</code></a></p>
```

Note `<code><<</code>` is invalid HTML.

I saw this on some other pages.

Not all output is being escaped.


Discussion:

Patch:
diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb
index 9314f04fae..4a3f028135 100644
--- a/lib/rdoc/markup/to_html_crossref.rb
+++ b/lib/rdoc/markup/to_html_crossref.rb
@@ -144,7 +144,7 @@ def link name, text, code = true
       path = ref.as_href @from_path
 
       if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
-        text = "<code>#{text}</code>"
+        text = "<code>#{CGI.escapeHTML text}</code>"
       end
 
       if path =~ /#/ then


Test patch:
diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
index bac2569f87..70306c683d 100644
--- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb
+++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb
@@ -89,6 +89,20 @@ def test_convert_RDOCLINK_rdoc_ref_method_percent
     assert_equal para("<a href=\"C1.html#method-c-25\"><code>C1::%</code></a>"), result
   end
 
+  def test_convert_RDOCLINK_rdoc_ref_method_escape_html
+    m = @c1.add_method RDoc::AnyMethod.new nil, '<<'
+    m.singleton = false
+
+    result = @to.convert 'rdoc-ref:C1#<<'
+
+    assert_equal para("<a href=\"C1.html#method-i-3C-3C\"><code>C1#&lt;&lt;</code></a>"), result
+    m.singleton = true
+
+    result = @to.convert 'rdoc-ref:C1::<<'
+
+    assert_equal para("<a href=\"C1.html#method-c-3C-3C\"><code>C1::&lt;&lt;</code></a>"), result
+  end
+
   def test_convert_RDOCLINK_rdoc_ref_method_percent_label
     m = @c1.add_method RDoc::AnyMethod.new nil, '%'
     m.singleton = false
Repository: bridgetownrb/bridgetown (Ruby)

Issue:
In 1.2 beta4, nested Roda routes are broken.
In a folder structure such as `src/_routes/items` which then has `index.erb` and `[slug].erb`, the following URLs should work:

* `/items` should go to `index.erb`
* `/items/123-abc` should go to `[slug].erb`

This works in beta3. But it's broken in beta 4. I suspect it has something to do with PR https://github.com/bridgetownrb/bridgetown/pull/654 but I'm not yet certain.


Discussion:

Patch:
diff --git a/bridgetown-routes/lib/bridgetown-routes/manifest.rb b/bridgetown-routes/lib/bridgetown-routes/manifest.rb
index c636c6d34..76a943f6a 100644
--- a/bridgetown-routes/lib/bridgetown-routes/manifest.rb
+++ b/bridgetown-routes/lib/bridgetown-routes/manifest.rb
@@ -40,6 +40,7 @@ def generate_manifest(site) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticCo
 
             new_manifest += sort_routes!(routes)
           end
+
           @route_manifest ||= {}
           @route_manifest[site.label] = new_manifest
         end
@@ -47,9 +48,9 @@ def generate_manifest(site) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticCo
         def sort_routes!(routes)
           routes.sort! do |route_a, route_b|
             # @type [String]
-            _, slug_a = route_a
+            slug_a = route_a[1][0]
             # @type [String]
-            _, slug_b = route_b
+            slug_b = route_b[1][0]
 
             # @type [Integer]
             weight1 = slug_a.count("/") <=> slug_b.count("/")


Test patch:
diff --git a/bridgetown-routes/test/ssr/src/_routes/nested/[slug].erb b/bridgetown-routes/test/ssr/src/_routes/nested/[slug].erb
new file mode 100644
index 000000000..36576739a
--- /dev/null
+++ b/bridgetown-routes/test/ssr/src/_routes/nested/[slug].erb
@@ -0,0 +1,8 @@
+---<%
+render_with data: {
+  title: "Nested Page with Slug",
+  slug_param: params[:slug]
+}
+%>---
+
+<h1><%= data.title %>: <%= data.slug_param %></h1>
diff --git a/bridgetown-routes/test/ssr/src/_routes/nested/index.erb b/bridgetown-routes/test/ssr/src/_routes/nested/index.erb
new file mode 100644
index 000000000..ba723e632
--- /dev/null
+++ b/bridgetown-routes/test/ssr/src/_routes/nested/index.erb
@@ -0,0 +1,7 @@
+---<%
+render_with data: {
+  title: "Nested Index"
+}
+%>---
+
+<h1><%= data.title %></h1>
diff --git a/bridgetown-routes/test/test_routes.rb b/bridgetown-routes/test/test_routes.rb
index 319632363..3e7d5170c 100644
--- a/bridgetown-routes/test/test_routes.rb
+++ b/bridgetown-routes/test/test_routes.rb
@@ -46,5 +46,15 @@ def site
       get "/it/localized"
       assert_equal "<h1>Localized for it - it</h1>\n", last_response.body
     end
+
+    should "return HTML for nested index RESTful route" do
+      get "/nested"
+      assert_equal "<h1>Nested Index</h1>\n", last_response.body
+    end
+
+    should "return HTML for nested item RESTful route" do
+      get "/nested/123-abc"
+      assert_equal "<h1>Nested Page with Slug: 123-abc</h1>\n", last_response.body
+    end
   end
 end
Repository: rubyzip/rubyzip (Ruby)

Issue:
`Zip::FileSystem::ZipFsDir#glob` triggers non-existing `Zip::FileSystem::ZipFileNameMapper#glob` method
Code:

```ruby
require 'zip'
require 'zip/filesystem'

Zip::File.open('archive.zip') do |zip_file|
  zip_file.dir.glob('flags/**/*')
end
```

Output:

```
NoMethodError: undefined method `glob' for #<Zip::FileSystem::ZipFileNameMapper:0x00005654bd818c98>
from /home/alex/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rubyzip-1.2.1/lib/zip/filesystem.rb:475:in `glob'
```


Discussion:
Hi @AlexWayfer, I've had a go at fixing this. Does PR #363 do what you expect?
Hello. Sorry, I don't remember. But I think yes.



Patch:
diff --git a/lib/zip/filesystem.rb b/lib/zip/filesystem.rb
index fb64325b..81ad1a18 100644
--- a/lib/zip/filesystem.rb
+++ b/lib/zip/filesystem.rb
@@ -573,6 +573,10 @@ def get_output_stream(fileName, permissionInt = nil, &aProc)
         @zipFile.get_output_stream(expand_to_entry(fileName), permissionInt, &aProc)
       end
 
+      def glob(pattern, *flags, &block)
+        @zipFile.glob(expand_to_entry(pattern), *flags, &block)
+      end
+
       def read(fileName)
         @zipFile.read(expand_to_entry(fileName))
       end


Test patch:
diff --git a/test/filesystem/directory_test.rb b/test/filesystem/directory_test.rb
index ec0a7371..f36ede53 100644
--- a/test/filesystem/directory_test.rb
+++ b/test/filesystem/directory_test.rb
@@ -3,6 +3,7 @@
 
 class ZipFsDirectoryTest < MiniTest::Test
   TEST_ZIP = 'test/data/generated/zipWithDirs_copy.zip'
+  GLOB_TEST_ZIP = 'test/data/globTest.zip'
 
   def setup
     FileUtils.cp('test/data/zipWithDirs.zip', TEST_ZIP)
@@ -93,11 +94,28 @@ def test_chroot
     end
   end
 
-  # Globbing not supported yet
-  # def test_glob
-  #  # test alias []-operator too
-  #  fail "implement test"
-  # end
+  def test_glob
+    globbed_files = [
+      'globTest/foo/bar/baz/foo.txt',
+      'globTest/foo.txt',
+      'globTest/food.txt'
+    ]
+
+    ::Zip::File.open(GLOB_TEST_ZIP) do |zf|
+      zf.dir.glob('**/*.txt') do |f|
+        assert globbed_files.include?(f.name)
+      end
+
+      zf.dir.glob('globTest/foo/**/*.txt') do |f|
+        assert_equal globbed_files[0], f.name
+      end
+
+      zf.dir.chdir('globTest/foo')
+      zf.dir.glob('**/*.txt') do |f|
+        assert_equal globbed_files[0], f.name
+      end
+    end
+  end
 
   def test_open_new
     ::Zip::File.open(TEST_ZIP) do |zf|
Repository: rack/rack (Ruby)

Issue:
Rack::Deflater error when writing empty string
Hi.  I think I found a problem with Rack::Deflater.

This rackup config will throw a Zlib::DataError exception here (and I was getting Zlib::BufError in a more complex application before):

```
require 'zlib'
require 'rack'
use Rack::Deflater
run lambda { |env| [200, { }, ['test', '']] }
```

It seems to be a Zlib problem:

```
require 'zlib'
z = Zlib::GzipWriter.new open('/dev/null', 'w')
z.write 'test'
z.flush
z.write ''
z.flush
z.close
```

So flushing an empty string seems to be a no-no.  (But an empty flush doesn't error out if it's the first one for the stream somehow.)

Maybe there should be a guard in Rack::Deflater::GzipStream#each like this?

```
    ...
    @body.each { |part|
      unless part.empty?
        gzip.write(part)
        gzip.flush
      end
    }
    ...
```

Even if this is a Zlib bug, it could be nice to protect older ruby versions from it.



Discussion:

Patch:
diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb
index ce248c665..939832ce6 100644
--- a/lib/rack/deflater.rb
+++ b/lib/rack/deflater.rb
@@ -88,8 +88,9 @@ def each(&block)
         gzip = ::Zlib::GzipWriter.new(self)
         gzip.mtime = @mtime if @mtime
         @body.each { |part|
-          gzip.write(part)
-          gzip.flush if @sync
+          len = gzip.write(part)
+          # Flushing empty parts would raise Zlib::BufError.
+          gzip.flush if @sync && len > 0
         }
       ensure
         gzip.close


Test patch:
diff --git a/test/spec_deflater.rb b/test/spec_deflater.rb
index a00b5ec39..18fe831b4 100644
--- a/test/spec_deflater.rb
+++ b/test/spec_deflater.rb
@@ -114,6 +114,19 @@ class << app_body; def each; yield('foo'); yield('bar'); end; end
     end
   end
 
+  it 'be able to deflate bodies that respond to each and contain empty chunks' do
+    app_body = Object.new
+    class << app_body; def each; yield('foo'); yield(''); yield('bar'); end; end
+
+    verify(200, 'foobar', deflate_or_gzip, { 'app_body' => app_body }) do |status, headers, body|
+      headers.must_equal({
+        'Content-Encoding' => 'gzip',
+        'Vary' => 'Accept-Encoding',
+        'Content-Type' => 'text/plain'
+      })
+    end
+  end
+
   it 'flush deflated chunks to the client as they become ready' do
     app_body = Object.new
     class << app_body; def each; yield('foo'); yield('bar'); end; end
Repository: Shopify/liquid (Ruby)

Issue:
Liquid::Template.register_filter(...) doesn't work if the filter has already been used
I've been using liquid and discovered that if a filter is used before the register_filter call is made then not only does the filter not work - as you would expect - but also adding that filter using register_filters does not work at any point after that.  As if liquid is remembering the filter does not exist and making it unavailable for registering ever again.  Here is an example - note that url_arg_prefix puts a question mark on the end of the string.

$irb
>require 'liquid'
>Liquid::Template.parse("{{'example' | url_arg_prefix }}").render
 => "example" 
> require './lib/taxi_liquid_filters.rb'
> Liquid::Template.register_filter(TaxiLiquidFilters)
=> #<Set: {"size",.....  "url_param_escape"}> 
> Liquid::Template.parse("{{'example' | url_arg_prefix }}").render
 => "example" 

Take 2 - this time register the filters first:

 > require 'liquid'
> require './lib/taxi_liquid_filters.rb'
 > Liquid::Template.register_filter(TaxiLiquidFilters)
 => #<Set: {"size" ..... "url_param_escape"}> 
> Liquid::Template.parse("{{'example' | url_arg_prefix }}").render
 => "example?" 




Discussion:
Here is a full script that reproduces the problem

```ruby
require 'liquid'

module MyFilters
  def myfilter(arg)
    'filtered'
  end
end

source = "{{ 'input' | myfilter }}"
template = Liquid::Template.parse(source)
puts template.render!
Liquid::Template.register_filter(MyFilters)
template = Liquid::Template.parse(source)
puts template.render!
```

which outputs

```
input
input
```

instead of

```
input
filtered
```



Patch:
diff --git a/lib/liquid/strainer.rb b/lib/liquid/strainer.rb
index 441e335cf..99a9c29d5 100644
--- a/lib/liquid/strainer.rb
+++ b/lib/liquid/strainer.rb
@@ -39,6 +39,7 @@ def self.add_filter(filter)
     end
 
     def self.global_filter(filter)
+      @@strainer_class_cache.clear
       @@global_strainer.add_filter(filter)
     end
 


Test patch:
diff --git a/test/unit/strainer_unit_test.rb b/test/unit/strainer_unit_test.rb
index 5cdf2e8f4..6ccdc278a 100644
--- a/test/unit/strainer_unit_test.rb
+++ b/test/unit/strainer_unit_test.rb
@@ -133,4 +133,16 @@ def test_add_filter_does_not_raise_when_module_overrides_previously_registered_m
     strainer.class.add_filter(PublicMethodOverrideFilter)
     assert strainer.class.filter_methods.include?('public_filter')
   end
+
+  module LateAddedFilter
+    def late_added_filter(input)
+      "filtered"
+    end
+  end
+
+  def test_global_filter_clears_cache
+    assert_equal 'input', Strainer.create(nil).invoke('late_added_filter', 'input')
+    Strainer.global_filter(LateAddedFilter)
+    assert_equal 'filtered', Strainer.create(nil).invoke('late_added_filter', 'input')
+  end
 end # StrainerTest
Repository: Shopify/shopify-cli (Ruby)

Issue:
[Enhancement]: theme package - include release-notes.md
### What type of project(s) will this request affect?

theme

### Overview

A new requirement for official Shopify theme update (free and premium) is to include a `release-notes.md` file in the root of the theme directory.  When using shopify-cli to run `shopify theme package` the markdown files are excluded.

### Motivation

Currently teams using Shopify CLI for themes in the marketplace can not rely on `shopify theme package` since it excludes the required release-notes.md file.


Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eaaaa84228..b9871c6845 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
 From version 2.6.0, the sections in this file adhere to the [keep a changelog](https://keepachangelog.com/en/1.0.0/) specification.
 
 ## [Unreleased]
+### Added
+* [#2103](https://github.com/Shopify/shopify-cli/pull/2103): Improve `shopify theme package` to include the `release-notes.md` file
 
 ## Version 2.13.0
 
diff --git a/lib/project_types/theme/commands/package.rb b/lib/project_types/theme/commands/package.rb
index df0c6db9c6..7209f04383 100644
--- a/lib/project_types/theme/commands/package.rb
+++ b/lib/project_types/theme/commands/package.rb
@@ -15,6 +15,7 @@ class Package < ShopifyCLI::Command::SubCommand
         sections
         snippets
         templates
+        release-notes.md
       ]
 
       def call(args, _name)


Test patch:
diff --git a/test/project_types/theme/commands/package_test.rb b/test/project_types/theme/commands/package_test.rb
index 334801a648..591e550186 100644
--- a/test/project_types/theme/commands/package_test.rb
+++ b/test/project_types/theme/commands/package_test.rb
@@ -17,7 +17,16 @@ def test_package_theme
           "zip",
           "-r",
           "Example-1.0.0.zip",
-          *Theme::Command::Package::THEME_DIRECTORIES,
+          *%w[
+            assets
+            config
+            layout
+            locales
+            sections
+            snippets
+            templates
+            release-notes.md
+          ],
           chdir: theme_root
         )
Repository: ruby/rdoc (Ruby)

Issue:
RDoc::Parser::Ruby failure on class paths with line breaks
The easiest reproducing case for this is:

```
print String::
  new('test')
```

This is valid Ruby. However, not for `rdoc`.

```
$ ruby test.rb
test
```

```
$ rdoc
Parsing sources...
100% [ 1/ 1]  test.rb
RDoc::Parser::Ruby failure around line 2 of
test.rb

  new('test')

Before reporting this, could you check that the file you're documenting
has proper syntax:

  /Users/Jason/.rvm/rubies/ruby-2.5.1/bin/ruby -c test.rb

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

	(RDoc::Error) Invalid class or module definition: String

uh-oh! RDoc had a problem:
Invalid class or module definition: String

run with --debug for full backtrace
```

Versions:

```
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
$ rdoc --version
6.2.0
```


Discussion:

Patch:
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index dffe30482b..8d021f3c6d 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -378,7 +378,7 @@ def get_class_or_module container, ignore_constants = false
       record_location container
 
       get_tk
-      skip_tkspace_without_nl
+      skip_tkspace
       if :on_lparen == peek_tk[:kind] # ProcObjectInConstant::()
         parse_method_or_yield_parameters
         break


Test patch:
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 8673225cad..0c81906090 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -100,7 +100,7 @@ def test_get_class_or_module
     assert_equal 'E', name_t[:text]
     assert_equal 'D::E', given_name
 
-    assert_raise RDoc::Error do
+    assert_nothing_raised do
       util_parser("A::\nB").get_class_or_module ctxt
     end
   end
Repository: ffaker/ffaker (Ruby)

Issue:
Birthday
I'm exploring if there's interest in Birthday. When creating users, it allows us to have realistic looking dates for employees. 

I've looked at leveraging `FFaker::Date.between`, but it's pretty clunky for the caller to setup the `from` date and `to` date. The caller could do something like `FFaker::Date.between(Time.zone.today - 365*65, Time.zone.today - 365*18)` assuming the caller had access to active support. This is my Plan B.

Faker defines birthday as:
```
# Random birthday date (maximum age between 18 and 65)
# Keyword arguments: min_age, max_age
Faker::Date.birthday(min_age: 18, max_age: 65) #=> "Fri, 28 Mar 1986"
```

What do you think? Should I add this to FFaker::Date ?


Discussion:
Using time zones will not work in projects that do not use Rails. I recommend just doing it as a date.

> `Faker::Date.birthday(min_age: 18, max_age: 65)`

I'm OK with this syntax.



Patch:
diff --git a/Changelog.md b/Changelog.md
index 3e4eeea3..8f031926 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,6 +1,7 @@
 ## development
 
   - Add your change HERE
+  - Adds FFaker::Date.birthday [@professor]
   - Adds FFaker::Crypto.sha256 [@professor]
   - Update README [@professor]
   - Adds FFaker::Number.between [@professor]
diff --git a/REFERENCE.md b/REFERENCE.md
index 98951b88..4ed67e6e 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -1077,6 +1077,7 @@
 | ------ | ------- |
 | `backward` | 2023-07-09, 2023-05-11, 2022-09-09 |
 | `between`(..., ...) |  |
+| `birthday(min_age:, max_age:)` | |
 | `forward` | 2024-07-09, 2024-06-16, 2024-06-20 |
 
 ## FFaker::DizzleIpsum
diff --git a/lib/ffaker/date.rb b/lib/ffaker/date.rb
index 8bea2177..b73a98da 100644
--- a/lib/ffaker/date.rb
+++ b/lib/ffaker/date.rb
@@ -27,5 +27,14 @@ def forward(days = 365)
 
       between(from, to)
     end
+
+    # Random birthday date (maximum age between 18 and 65)
+    # Keyword arguments: min_age, max_age
+    def birthday(min_age: 18, max_age: 65)
+      from = ::Date.today.prev_year(max_age + 1).next_day
+      to = ::Date.today.prev_year(min_age)
+
+      between(from, to)
+    end
   end
 end


Test patch:
diff --git a/test/test_date.rb b/test/test_date.rb
index 095ff406..4c1c1d47 100644
--- a/test/test_date.rb
+++ b/test/test_date.rb
@@ -9,7 +9,7 @@ def setup
     @tester = FFaker::Date
   end
 
-  assert_methods_are_deterministic(FFaker::Date, :backward, :forward)
+  assert_methods_are_deterministic(FFaker::Date, :backward, :forward, :birthday)
 
   def test_between
     from = Date.new(2015, 1, 1)
@@ -34,4 +34,12 @@ def test_forward
     assert_random_between(today + 1..today + 30) { @tester.forward(30) }
     assert_instance_of Date, @tester.forward
   end
+
+  def test_birthday
+    today = Date.today
+
+    assert_random_between(today.prev_year(65).next_day..today.prev_year(18)) { @tester.birthday }
+    assert_random_between(today.prev_year(43).next_day..today.prev_year(42)) { @tester.birthday(min_age: 42, max_age: 42) }
+    assert_instance_of Date, @tester.birthday
+  end
 end
Repository: roo-rb/roo (Ruby)

Issue:
Incorrect formatted value for `0%`-formatted percentages due to floating point inaccuracy
PR coming momentarily!

### Steps to reproduce

See Gist at https://gist.github.com/leboshi/e0e6302b50eaef325744087048f16924; download and run self-contained (plus XLSX) test script.

### Issue

In some very specific cases, floating-point storage inaccuracy causes `:formatted_value` to return an unexpected value; specifically, when `57%` is stored as a `0%`-formatted percentage, `:formatted_value` returns `56%`.  Ultimately, this is because the formatter implementation truncates instead of rounding:
```ruby
Kernel.format('%d%%', number.to_f * 100)
```

In this specific case, 57% is stored as 0.56999999999999995.  Multiplied by 100, that's 56.999999999999995.  The `%d` token truncates that to 56%, whereas `%.0f` would correctly round to 57%.

(Possibly related to issue #384?)

### System configuration

**Roo version**: 2.8.3

**Ruby version**: 2.7.2


Discussion:

Patch:
diff --git a/lib/roo/excelx/cell/number.rb b/lib/roo/excelx/cell/number.rb
index 7ea48b58..58cd1592 100644
--- a/lib/roo/excelx/cell/number.rb
+++ b/lib/roo/excelx/cell/number.rb
@@ -51,7 +51,7 @@ def generate_formatter(format)
           when /^#,##0.(0+)$/ then number_format("%.#{$1.size}f")
           when '0%'
             proc do |number|
-              Kernel.format('%d%%', number.to_f * 100)
+              Kernel.format('%.0f%%', number.to_f * 100)
             end
           when '0.00%'
             proc do |number|


Test patch:
diff --git a/test/excelx/cell/test_number.rb b/test/excelx/cell/test_number.rb
index ddcffeb4..58c9ff7f 100644
--- a/test/excelx/cell/test_number.rb
+++ b/test/excelx/cell/test_number.rb
@@ -35,6 +35,11 @@ def test_percent
     assert_kind_of(Float, cell.value)
   end
 
+  def test_rounded_percent_formatted_value
+    cell = Roo::Excelx::Cell::Number.new '0.569999999995', nil, ['0%'], nil, nil, nil
+    assert_equal('57%', cell.formatted_value)
+  end
+
   def test_formats_with_negative_numbers
     [
       ['#,##0 ;(#,##0)', '(1,042)'],
Repository: ruby-syntax-tree/syntax_tree (Ruby)

Issue:
`plugin/single_quotes` changes strings that have single-quotes inside
Using `@prettier/plugin-ruby` 3.1.2 and `syntax_tree` 2.6.0. A string like `x = "asd'qwe"` is changed to `x = 'asd\'qwe'` which I believe is worse. Is it possible to somehow configure `plugin/single_quotes`? Or change the default so it doesn't do that? :smile: 


Discussion:
Hmm I see what you mean. Feel like a contribution? You would need to change this line: https://github.com/ruby-syntax-tree/syntax_tree/blob/main/lib/syntax_tree/node.rb#L8406.
For the record, I'm seeing the same behavior when double quotes are enclosed in single quotes, so something like `x = 'a "string"'` would become `x = "a \"string\""`
I think I've also fixed this case with the PR.



Patch:
diff --git a/lib/syntax_tree/node.rb b/lib/syntax_tree/node.rb
index 0a1fc394..5e1a353a 100644
--- a/lib/syntax_tree/node.rb
+++ b/lib/syntax_tree/node.rb
@@ -3864,9 +3864,9 @@ module Quotes
     # whichever quote the user chose. (If they chose single quotes, then double
     # quoting would activate the escape sequence, and if they chose double
     # quotes, then single quotes would deactivate it.)
-    def self.locked?(node)
+    def self.locked?(node, quote)
       node.parts.any? do |part|
-        !part.is_a?(TStringContent) || part.value.match?(/\\|#[@${]/)
+        !part.is_a?(TStringContent) || part.value.match?(/\\|#[@${]|#{quote}/)
       end
     end
 
@@ -3981,12 +3981,12 @@ def quotes(q)
 
         if matched
           [quote, matching]
-        elsif Quotes.locked?(self)
+        elsif Quotes.locked?(self, q.quote)
           ["#{":" unless hash_key}'", "'"]
         else
           ["#{":" unless hash_key}#{q.quote}", q.quote]
         end
-      elsif Quotes.locked?(self)
+      elsif Quotes.locked?(self, q.quote)
         if quote.start_with?(":")
           [hash_key ? quote[1..] : quote, quote[1..]]
         else
@@ -8404,7 +8404,7 @@ def format(q)
       end
 
       opening_quote, closing_quote =
-        if !Quotes.locked?(self)
+        if !Quotes.locked?(self, q.quote)
           [q.quote, q.quote]
         elsif quote.start_with?("%")
           [quote, Quotes.matching(quote[/%[qQ]?(.)/, 1])]


Test patch:
diff --git a/test/fixtures/string_literal.rb b/test/fixtures/string_literal.rb
index ebe56a40..d8ee0cdb 100644
--- a/test/fixtures/string_literal.rb
+++ b/test/fixtures/string_literal.rb
@@ -41,4 +41,8 @@
 %
 '"foo"'
 -
-"\"foo\""
+'"foo"'
+%
+"'foo'"
+-
+"'foo'"
diff --git a/test/formatter/single_quotes_test.rb b/test/formatter/single_quotes_test.rb
index ac5103a1..78f9ae3d 100644
--- a/test/formatter/single_quotes_test.rb
+++ b/test/formatter/single_quotes_test.rb
@@ -26,6 +26,10 @@ def test_dyna_symbol
         assert_format(":'symbol'\n", ":\"symbol\"")
       end
 
+      def test_single_quote_in_string
+        assert_format("\"str'ing\"\n")
+      end
+
       def test_label
         assert_format(
           "{ foo => foo, :'bar' => bar }\n",
Repository: rack/rack (Ruby)

Issue:
Rack::Deflate and Rack::Sendfile do not cooperate
It seems that Rack::Deflate does not detect when Rack::Sendfile is used.

Rack::Sendfile sets X-Sendfile or X-Accel-Redirect and it even sets content-length to 0, but Rack::Deflate only looks for cache-control no-transform or encoding identity.

Additionally a check for content length 0 would be sufficient. 
As a workaround you could use a lambda. 




Discussion:

Patch:
diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb
index 4da07d556..9a30c0175 100644
--- a/lib/rack/deflater.rb
+++ b/lib/rack/deflater.rb
@@ -124,6 +124,10 @@ def should_deflate?(env, status, headers, body)
       # Skip if @condition lambda is given and evaluates to false
       return false if @condition && !@condition.call(env, status, headers, body)
 
+      # No point in compressing empty body, also handles usage with
+      # Rack::Sendfile.
+      return false if headers[CONTENT_LENGTH] == '0'
+
       true
     end
   end


Test patch:
diff --git a/test/spec_deflater.rb b/test/spec_deflater.rb
index 75244dccc..378e2cf30 100644
--- a/test/spec_deflater.rb
+++ b/test/spec_deflater.rb
@@ -362,6 +362,15 @@ class << app_body; def each; yield('foo'); yield('bar'); end; end
     verify(200, 'Hello World!', { 'gzip' => nil }, options)
   end
 
+  it "not deflate if content-length is 0" do
+    options = {
+      'response_headers' => {
+        'Content-Length' => '0'
+      },
+    }
+    verify(200, '', { 'gzip' => nil }, options)
+  end
+
   it "deflate response if :if lambda evaluates to true" do
     options = {
       'deflater_options' => {
Repository: soveran/cuba (Ruby)

Issue:
Support passing keyword arguments to middlewares
It seems Cuba is [not forwarding kargs ](https://github.com/soveran/cuba/blob/master/lib/cuba.rb#L94) to the app, so this is not working for me:

 ```ruby
API.use MyMiddleware, foo, bar: 'baz'
```

I can create a PR to forward kargs if that makes sense. Something like this:

```ruby
def self.use(middleware, *args, **karsg, &block)
  app.use(middleware, *args, **karsg, &block)
end
```




Discussion:
@soveran , just to know if you had a chance to take a look at this. Thanks!
@Juanmcuello Hey! Yes, please create a PR. Use `kwargs` as the name of that argument.

Thanks!
Done!



Patch:
diff --git a/lib/cuba.rb b/lib/cuba.rb
index 81557fd5..e8518f64 100644
--- a/lib/cuba.rb
+++ b/lib/cuba.rb
@@ -91,8 +91,8 @@ def self.app
     @app ||= Rack::Builder.new
   end
 
-  def self.use(middleware, *args, &block)
-    app.use(middleware, *args, &block)
+  def self.use(middleware, *args, **kwargs, &block)
+    app.use(middleware, *args, **kwargs, &block)
   end
 
   def self.define(&block)


Test patch:
diff --git a/test/middleware.rb b/test/middleware.rb
index 804915ec..59534183 100644
--- a/test/middleware.rb
+++ b/test/middleware.rb
@@ -1,8 +1,9 @@
 require File.expand_path("helper", File.dirname(__FILE__))
 
 class Shrimp
-  def initialize(app)
+  def initialize(app, foo:)
     @app = app
+    @foo = foo
   end
 
   def call(env)
@@ -17,7 +18,7 @@ def call(env)
 
 test do
   class API < Cuba
-    use Shrimp
+    use Shrimp, foo: 'bar'
 
     define do
       on "v1/test" do
Repository: soutaro/steep (Ruby)

Issue:
`steep:ignore` family sometimes doesn’t work in CRLF files
```console
$ echo -e '\r\nfoo # steep:ignore' > ruby.rb
$ hexdump *
0000000 0a0d 6f66 206f 2023 7473 6565 3a70 6769
0000010 6f6e 6572 000a
0000015
$ steep check
2024-12-02 16:35:47.772: ERROR: [Steep 1.8.3] Cannot find a configuration at Steepfile: `steep init` to scaffold. Using current directory...
# Type checking files:

...........................................................F........................

ruby.rb:2:0: [error] Type `::Object` does not have method `foo`
│ Diagnostic ID: Ruby::NoMethod
│
└ foo # steep:ignore
  ~~~

Detected 1 problem from 1 file
```


Discussion:

Patch:
diff --git a/lib/steep/ast/ignore.rb b/lib/steep/ast/ignore.rb
index b908b8217..37e1cac40 100644
--- a/lib/steep/ast/ignore.rb
+++ b/lib/steep/ast/ignore.rb
@@ -93,15 +93,14 @@ def ignored_diagnostics
       def self.parse(comment, buffer)
         return unless comment.inline?
 
-        comment_location = RBS::Location.new(buffer, comment.loc.expression.begin_pos, comment.loc.expression.end_pos)
+        begin_pos = buffer.loc_to_pos([comment.loc.line, comment.loc.column])
+        end_pos = buffer.loc_to_pos([comment.loc.last_line, comment.loc.last_column])
+        comment_location = RBS::Location.new(buffer, begin_pos, end_pos)
         scanner = BufferScanner.new(comment_location)
 
         scanner.scan(/#/)
         scanner.skip(/\s*/)
 
-        begin_pos = comment.location.expression.begin_pos
-        end_pos = comment.location.expression.end_pos
-
         case
         when loc = scanner.scan(/steep:ignore:start\b/)
           scanner.skip(/\s*/)


Test patch:
diff --git a/test/ast/ignore_test.rb b/test/ast/ignore_test.rb
index 362ee41a9..f4f4ce167 100644
--- a/test/ast/ignore_test.rb
+++ b/test/ast/ignore_test.rb
@@ -108,4 +108,19 @@ def test_parse_ignore__diagnostics
       assert_equal "steep:ignore Foo, Bar,", ignore.location.source
     end
   end
+
+  def test_parse_ignore__crlf
+    _, comments, buf = parse(<<~RUBY)
+      \r
+      # steep:ignore Foo
+      # steep:ignore Foo, Bar,
+    RUBY
+    Steep::AST::Ignore.parse(comments[0], buf).tap do |ignore|
+      assert_instance_of Ignore::IgnoreLine, ignore
+    end
+
+    Steep::AST::Ignore.parse(comments[1], buf).tap do |ignore|
+      assert_instance_of Ignore::IgnoreLine, ignore
+    end
+  end
 end
Repository: ruby/rdoc (Ruby)

Issue:
Rdoc::Parser::Ruby failure on the namespace resolution operator with a block
https://github.com/wowinter13/terrasms_api/blob/master/lib/terrasms_api/request.rb

I have a Gem, which contains a method called `with_handled_errors`.

If I rewrote the method body from:
```ruby
TerrasmsApi::Error.call { yield }
```
to:
```ruby
TerrasmsApi::Error::() { yield } # functional way, etc-etc.
```
It still would be a correct ruby code, but:
```bash
gem install terrasms_api
Successfully installed terrasms_api-0.1.0
Parsing documentation for terrasms_api-0.1.0

RDoc::Parser::Ruby failure around line 51 of
lib/terrasms_api/request.rb

      TerrasmsApi::Error::() { yield }

Before reporting this, could you check that the file you're documenting
has proper syntax:

  .../.rbenv/versions/2.6.5/bin/ruby -c lib/terrasms_api/request.rb

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

	(RDoc::Error) Invalid class or module definition: TerrasmsApi::Error

ERROR:  While executing gem ... (RDoc::Error)
    Invalid class or module definition: TerrasmsApi::Error

________
.../.rbenv/versions/2.6.5/bin/ruby -c lib/terrasms_api/request.rb
Syntax OK
```


Discussion:

Patch:
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb
index c87765b75a..dffe30482b 100644
--- a/lib/rdoc/parser/ruby.rb
+++ b/lib/rdoc/parser/ruby.rb
@@ -379,6 +379,10 @@ def get_class_or_module container, ignore_constants = false
 
       get_tk
       skip_tkspace_without_nl
+      if :on_lparen == peek_tk[:kind] # ProcObjectInConstant::()
+        parse_method_or_yield_parameters
+        break
+      end
       name_t = get_tk
       unless :on_const == name_t[:kind] || :on_ident == name_t[:kind]
         raise RDoc::Error, "Invalid class or module definition: #{given_name}"


Test patch:
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 99f4de2fcb..8673225cad 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -830,6 +830,17 @@ class Foo
     assert_equal @top_level, blah.file
   end
 
+  def test_parse_call_syntax_sugar_for_constant
+    util_parser <<-CODE
+Foo = proc{}
+Foo::()
+    CODE
+
+    assert_nothing_raised do
+      @parser.scan
+    end
+  end
+
   def test_parse_class_multi_ghost_methods
     util_parser <<-'CLASS'
 class Foo
Repository: JEG2/highline (Ruby)

Issue:
Have to set convert type in order for `.in` to work with array
If you do this, no validation happens:

```Ruby
ask('Letter a, b, or c? ') { |q| q.in = %w[ a b c ] }
```

You can enter in `d`, and it accepts the input.

In order for it to work, you have to pass in `String`:

```Ruby
ask('Letter a, b, or c? ',String) { |q| q.in = %w[ a b c ] }
```

Is there another way I should do this (I don't want a full-blown menu like with `choose`)? Else, I think it'd be useful to change it.


Discussion:

Patch:
diff --git a/lib/highline/question/answer_converter.rb b/lib/highline/question/answer_converter.rb
index 76558aeb..6a4585c2 100644
--- a/lib/highline/question/answer_converter.rb
+++ b/lib/highline/question/answer_converter.rb
@@ -9,7 +9,7 @@ class AnswerConverter
       extend Forwardable
 
       def_delegators :@question,
-                     :answer, :answer=, :check_range,
+                     :answer, :answer=,
                      :directory, :answer_type, :choices_complete
 
       # It should be initialized with a Question object.
@@ -26,10 +26,7 @@ def initialize(question)
       # it makes the conversion and returns the answer.
       # @return [Object] the converted answer.
       def convert
-        return unless answer_type
-
-        self.answer = convert_by_answer_type
-        check_range
+        self.answer = convert_by_answer_type if answer_type
         answer
       end
 
diff --git a/lib/highline/question_asker.rb b/lib/highline/question_asker.rb
index 03b3ff77..d28d36ca 100644
--- a/lib/highline/question_asker.rb
+++ b/lib/highline/question_asker.rb
@@ -31,6 +31,7 @@ def ask_once
         raise NotValidQuestionError unless question.valid_answer?
 
         question.convert
+        question.check_range
 
         if question.confirm
           confirmation = @highline.send(:confirm, question)


Test patch:
diff --git a/test/test_highline.rb b/test/test_highline.rb
index 67d8fade..e6233059 100755
--- a/test/test_highline.rb
+++ b/test/test_highline.rb
@@ -1358,6 +1358,25 @@ def test_range_requirements
                   "?  ", @output.string)
   end
 
+  def test_range_requirements_with_array_of_strings
+    @input.truncate(@input.rewind)
+    @input << "z\nx\nb\n"
+    @input.rewind
+    @output.truncate(@output.rewind)
+
+    answer = @terminal.ask("Letter a, b, or c? ") do |q|
+      q.in = %w[ a b c ]
+    end
+    assert_equal("b", answer)
+    assert_equal("Letter a, b, or c? " \
+                  "Your answer isn't within the expected range " \
+                  "(included in [\"a\", \"b\", \"c\"]).\n" \
+                  "?  " \
+                  "Your answer isn't within the expected range " \
+                  "(included in [\"a\", \"b\", \"c\"]).\n" \
+                  "?  ", @output.string)
+  end
+
   def test_reask
     number = 61_676
     @input << "Junk!\n" << number << "\n"
Repository: puma/puma (Ruby)

Issue:
Rackup overrides CLI preference for app
**Describe the bug**

Puma should always prefer the rackup file specified by the CLI, but if the `rackup` DSL command is used, it does not.

Related: #1401

**Puma config:**

Using the test fixtures in the repo: 

```
rackup "test/rackup/hello-env.ru"
```

**To Reproduce**

```
bin/puma -C my_rackup_config.rb test/rackup/hello.ru
```

...should return a Hello World! response, but runs the hello-env app instead.




Discussion:
@nateberkopec, can you help me to solve this? I want to do my first contribution to this amazing project that I have been using for the last 3 years! And I want to solidify my knowledge on puma web server.

Thanks for your time!
Hi @acmh. Look at CONTRIBUTING.md if you haven't already. Glad to have you on board!

1. Write a test first. Take a look at the tests in the `integration` files, they're probably the closest. There are probably a few existing tests for config that may help too. Once you have a failing test, you can look at solutions.
2. Solution: Will probably involve setting the underlying options correctly in either `dsl.rb` or `configuration.rb`.



Patch:
diff --git a/History.md b/History.md
index ce96413323..94e72bc609 100644
--- a/History.md
+++ b/History.md
@@ -39,6 +39,7 @@
   * Fix `out_of_band` hook never executed if the number of worker threads is > 1 (#2177)
   * Fix ThreadPool#shutdown timeout accuracy (#2221)
   * Fix `UserFileDefaultOptions#fetch` to properly use `default` (#2233)
+  * Prefer the rackup file specified by the CLI (#2225)
 
 * Refactor
   * Remove unused loader argument from Plugin initializer (#2095)
diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb
index 9bc51f77aa..41e03a1a7e 100644
--- a/lib/puma/dsl.rb
+++ b/lib/puma/dsl.rb
@@ -308,7 +308,7 @@ def debug
     # @example
     #   rackup '/u/apps/lolcat/config.ru'
     def rackup(path)
-      @options[:rackup] = path.to_s
+      @options[:rackup] ||= path.to_s
     end
 
     def early_hints(answer=true)


Test patch:
diff --git a/test/config/with_rackup_from_dsl.rb b/test/config/with_rackup_from_dsl.rb
new file mode 100644
index 0000000000..3c310d8772
--- /dev/null
+++ b/test/config/with_rackup_from_dsl.rb
@@ -0,0 +1,1 @@
+rackup "test/rackup/hello-env.ru"
diff --git a/test/test_integration_single.rb b/test/test_integration_single.rb
index e1afa97f4d..864c3385ae 100644
--- a/test/test_integration_single.rb
+++ b/test/test_integration_single.rb
@@ -43,6 +43,17 @@ def test_term_suppress
     assert_equal 0, status
   end
 
+  def test_prefer_rackup_file_specified_by_cli
+    skip_unless_signal_exist? :TERM
+
+    cli_server "-C test/config/with_rackup_from_dsl.rb test/rackup/hello.ru"
+    connection = connect
+    reply = read_body(connection)
+    _, status = stop_server
+
+    assert_match("Hello World", reply)
+  end
+
   def test_term_not_accepts_new_connections
     skip_unless_signal_exist? :TERM
     skip_on :jruby