From 459a2ff0020d967ef509ca8528bdd333da40d79f Mon Sep 17 00:00:00 2001 From: Nick Pezza Date: Thu, 17 Oct 2024 18:40:19 -0400 Subject: [PATCH 1/3] Support frozen strings --- .github/workflows/ci.yml | 2 ++ lib/net/scp.rb | 7 ++++++- net-scp.gemspec | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9330ac6..dd788bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,5 @@ jobs: bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Run Tests run: bundle exec rake test + env: + RUBYOPT: ${{ startsWith(matrix.ruby, 'ruby-head') && '--enable=frozen-string-literal' || '' }} diff --git a/lib/net/scp.rb b/lib/net/scp.rb index 1bb4333..64acd48 100644 --- a/lib/net/scp.rb +++ b/lib/net/scp.rb @@ -329,7 +329,12 @@ def download!(remote, local=nil, options={}, &progress) # (:verbose, :recursive, :preserve). Returns the command-line as a # string, ready to execute. def scp_command(mode, options) - command = "scp " + command = + if RUBY_VERSION < "2.3" + "scp " + else + +"scp " + end command << (mode == :upload ? "-t" : "-f") command << " -v" if options[:verbose] command << " -r" if options[:recursive] diff --git a/net-scp.gemspec b/net-scp.gemspec index 522d3a9..7fcdaa2 100644 --- a/net-scp.gemspec +++ b/net-scp.gemspec @@ -35,15 +35,15 @@ Gem::Specification.new do |spec| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then spec.add_runtime_dependency(%q, [">= 2.6.5", "< 8.0.0"]) spec.add_development_dependency(%q, [">= 0"]) - spec.add_development_dependency(%q, [">= 0"]) + spec.add_dependency(%q, [">= 0", "<2.1"]) else spec.add_dependency(%q, [">= 2.6.5", "< 8.0.0"]) spec.add_dependency(%q, [">= 0"]) - spec.add_dependency(%q, [">= 0"]) + spec.add_dependency(%q, [">= 0", "<2.1"]) end else spec.add_dependency(%q, [">= 2.6.5", "< 8.0.0"]) spec.add_dependency(%q, [">= 0"]) - spec.add_dependency(%q, [">= 0"]) + spec.add_dependency(%q, [">= 0", "<2.1"]) end end From 974fa7b68e267d79a645839ddb6660392a592a2d Mon Sep 17 00:00:00 2001 From: Nick Pezza Date: Tue, 24 Dec 2024 11:38:00 -0500 Subject: [PATCH 2/3] Revert gemspec changes --- net-scp.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net-scp.gemspec b/net-scp.gemspec index 7fcdaa2..522d3a9 100644 --- a/net-scp.gemspec +++ b/net-scp.gemspec @@ -35,15 +35,15 @@ Gem::Specification.new do |spec| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then spec.add_runtime_dependency(%q, [">= 2.6.5", "< 8.0.0"]) spec.add_development_dependency(%q, [">= 0"]) - spec.add_dependency(%q, [">= 0", "<2.1"]) + spec.add_development_dependency(%q, [">= 0"]) else spec.add_dependency(%q, [">= 2.6.5", "< 8.0.0"]) spec.add_dependency(%q, [">= 0"]) - spec.add_dependency(%q, [">= 0", "<2.1"]) + spec.add_dependency(%q, [">= 0"]) end else spec.add_dependency(%q, [">= 2.6.5", "< 8.0.0"]) spec.add_dependency(%q, [">= 0"]) - spec.add_dependency(%q, [">= 0", "<2.1"]) + spec.add_dependency(%q, [">= 0"]) end end From 9428143452b69da387402b87ad83ed6b6117e872 Mon Sep 17 00:00:00 2001 From: Nick Pezza Date: Tue, 14 Jan 2025 15:41:39 -0500 Subject: [PATCH 3/3] Cleanup --- .github/workflows/ci.yml | 4 ++-- lib/net/scp.rb | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd788bf..3ef7dbe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'ruby-head'] + ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', 'ruby-head'] continue-on-error: ${{ matrix.ruby-version == 'ruby-head' }} steps: - uses: actions/checkout@v3 @@ -22,4 +22,4 @@ jobs: - name: Run Tests run: bundle exec rake test env: - RUBYOPT: ${{ startsWith(matrix.ruby, 'ruby-head') && '--enable=frozen-string-literal' || '' }} + RUBYOPT: "--enable=frozen_string_literal" diff --git a/lib/net/scp.rb b/lib/net/scp.rb index 64acd48..c4eacf1 100644 --- a/lib/net/scp.rb +++ b/lib/net/scp.rb @@ -329,12 +329,7 @@ def download!(remote, local=nil, options={}, &progress) # (:verbose, :recursive, :preserve). Returns the command-line as a # string, ready to execute. def scp_command(mode, options) - command = - if RUBY_VERSION < "2.3" - "scp " - else - +"scp " - end + command = String.new("scp ") command << (mode == :upload ? "-t" : "-f") command << " -v" if options[:verbose] command << " -r" if options[:recursive]