From b597ecb15ef24aa18d1ce9ff1cb78574d0b2a3fc Mon Sep 17 00:00:00 2001 From: cn Date: Fri, 6 Mar 2020 21:33:29 +0100 Subject: [PATCH] gem: adopt frozen string literals --- .rubocop.yml | 3 --- CHANGELOG.md | 1 + Gemfile | 2 ++ Rakefile | 2 ++ dyndnsd.gemspec | 1 + exe/dyndnsd | 2 ++ lib/dyndnsd.rb | 2 +- lib/dyndnsd/database.rb | 1 + lib/dyndnsd/generator/bind.rb | 1 + lib/dyndnsd/helper.rb | 1 + lib/dyndnsd/responder/dyndns_style.rb | 1 + lib/dyndnsd/responder/rest_style.rb | 1 + lib/dyndnsd/textfile_reporter.rb | 1 + lib/dyndnsd/updater/command_with_bind_zone.rb | 1 + lib/dyndnsd/version.rb | 3 ++- spec/daemon_spec.rb | 4 +++- spec/spec_helper.rb | 6 ++++-- spec/support/dummy_database.rb | 1 + spec/support/dummy_updater.rb | 1 + 19 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9641030..45bc712 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -53,9 +53,6 @@ Style/Documentation: Style/FormatStringToken: Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false - Style/GuardClause: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 98025f6..d0258c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ IMPROVEMENTS: - Refactor gemspec based on [recommendations](https://piotrmurach.com/articles/writing-a-ruby-gem-specification/) so tests are now excluded from gem and binaries move to `./exe` directory +- Adopt Ruby 2.3 frozen string literals for source code potentially reducing memory consumption ## 2.1.1 (March 1, 2020) diff --git a/Gemfile b/Gemfile index fa75df1..7f4f5e9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/Rakefile b/Rakefile index ba57a1f..444ff67 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' diff --git a/dyndnsd.gemspec b/dyndnsd.gemspec index bd2b8f3..41de841 100644 --- a/dyndnsd.gemspec +++ b/dyndnsd.gemspec @@ -1,3 +1,4 @@ +# frozen_string_literal: true require_relative 'lib/dyndnsd/version' diff --git a/exe/dyndnsd b/exe/dyndnsd index fa15a52..5c2ebc1 100755 --- a/exe/dyndnsd +++ b/exe/dyndnsd @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true require 'dyndnsd' diff --git a/lib/dyndnsd.rb b/lib/dyndnsd.rb index 86898c8..7d9c1cf 100755 --- a/lib/dyndnsd.rb +++ b/lib/dyndnsd.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env ruby +# frozen_string_literal: true require 'etc' require 'logger' diff --git a/lib/dyndnsd/database.rb b/lib/dyndnsd/database.rb index 591e348..20c71d2 100644 --- a/lib/dyndnsd/database.rb +++ b/lib/dyndnsd/database.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'forwardable' diff --git a/lib/dyndnsd/generator/bind.rb b/lib/dyndnsd/generator/bind.rb index 17c704e..abfa178 100644 --- a/lib/dyndnsd/generator/bind.rb +++ b/lib/dyndnsd/generator/bind.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Dyndnsd module Generator diff --git a/lib/dyndnsd/helper.rb b/lib/dyndnsd/helper.rb index 6827663..5261e31 100644 --- a/lib/dyndnsd/helper.rb +++ b/lib/dyndnsd/helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'ipaddr' diff --git a/lib/dyndnsd/responder/dyndns_style.rb b/lib/dyndnsd/responder/dyndns_style.rb index a470823..284e1e2 100644 --- a/lib/dyndnsd/responder/dyndns_style.rb +++ b/lib/dyndnsd/responder/dyndns_style.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Dyndnsd module Responder diff --git a/lib/dyndnsd/responder/rest_style.rb b/lib/dyndnsd/responder/rest_style.rb index 8c89ccb..e60e95a 100644 --- a/lib/dyndnsd/responder/rest_style.rb +++ b/lib/dyndnsd/responder/rest_style.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Dyndnsd module Responder diff --git a/lib/dyndnsd/textfile_reporter.rb b/lib/dyndnsd/textfile_reporter.rb index 73aeae6..e9da30c 100644 --- a/lib/dyndnsd/textfile_reporter.rb +++ b/lib/dyndnsd/textfile_reporter.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Adapted from https://github.com/eric/metriks-graphite/blob/master/lib/metriks/reporter/graphite.rb diff --git a/lib/dyndnsd/updater/command_with_bind_zone.rb b/lib/dyndnsd/updater/command_with_bind_zone.rb index 14d5812..6c9c589 100644 --- a/lib/dyndnsd/updater/command_with_bind_zone.rb +++ b/lib/dyndnsd/updater/command_with_bind_zone.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Dyndnsd module Updater diff --git a/lib/dyndnsd/version.rb b/lib/dyndnsd/version.rb index 9a2b921..efee619 100644 --- a/lib/dyndnsd/version.rb +++ b/lib/dyndnsd/version.rb @@ -1,4 +1,5 @@ +# frozen_string_literal: true module Dyndnsd - VERSION = '2.1.1'.freeze + VERSION = '2.1.1' end diff --git a/spec/daemon_spec.rb b/spec/daemon_spec.rb index fb3ff5d..53fec02 100644 --- a/spec/daemon_spec.rb +++ b/spec/daemon_spec.rb @@ -1,4 +1,6 @@ -require 'spec_helper' +# frozen_string_literal: true + +require_relative 'spec_helper' describe Dyndnsd::Daemon do include Rack::Test::Methods diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e766e4f..26a824e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true require 'rubygems' require 'bundler/setup' require 'rack/test' require 'dyndnsd' -require 'support/dummy_database' -require 'support/dummy_updater' + +require_relative 'support/dummy_database' +require_relative 'support/dummy_updater' diff --git a/spec/support/dummy_database.rb b/spec/support/dummy_database.rb index b67a96d..8bf2961 100644 --- a/spec/support/dummy_database.rb +++ b/spec/support/dummy_database.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'forwardable' diff --git a/spec/support/dummy_updater.rb b/spec/support/dummy_updater.rb index ca33cc4..7f98de6 100644 --- a/spec/support/dummy_updater.rb +++ b/spec/support/dummy_updater.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Dyndnsd module Updater