From 1fa28061e425f899822ca3a4a797718a57cfb64b Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 2 Dec 2025 19:00:11 -0300 Subject: [PATCH 1/6] ruby version upgrade --- .ruby-version | 2 +- lib/has_safe_dates/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 4a36342..f989260 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.0 +3.4.4 diff --git a/lib/has_safe_dates/version.rb b/lib/has_safe_dates/version.rb index 9c5a43a..dd8c609 100644 --- a/lib/has_safe_dates/version.rb +++ b/lib/has_safe_dates/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HasSafeDates - VERSION = "2.0.3" + VERSION = "5.0.0-beta.1" end From 9e1d0733db790e47bfc953e57c14b962b87f9464 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Mon, 5 Jan 2026 13:42:55 -0300 Subject: [PATCH 2/6] fixes for new Ruby --- .circleci/config.yml | 8 +-- .rubocop.yml | 5 ++ Gemfile | 16 ++++- has_safe_dates.gemspec | 43 ++++++------- lib/has_safe_dates/core_ext.rb | 6 +- lib/has_safe_dates/version.rb | 2 +- spec/db/schema.rb | 10 +-- spec/has_safe_dates_spec.rb | 113 ++++++++++++++++----------------- spec/spec_helper.rb | 9 +-- 9 files changed, 112 insertions(+), 100 deletions(-) create mode 100644 .rubocop.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index d09efa2..5bec898 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,8 +25,8 @@ jobs: - restore_cache: keys: - - has_safe_dates-dependencies-v1-{{ checksum "has_safe_dates.gemspec" }} - - has_safe_dates-dependencies-v1- + - has_safe_dates-dependencies-v1-{{ checksum "has_safe_dates.gemspec" }} + - has_safe_dates-dependencies-v1- - run: name: Install dependencies @@ -65,8 +65,8 @@ jobs: - restore_cache: keys: - - has_safe_dates-dependencies-v1-{{ checksum "has_safe_dates.gemspec" }} - - has_safe_dates-dependencies-v1- + - has_safe_dates-dependencies-v1-{{ checksum "has_safe_dates.gemspec" }} + - has_safe_dates-dependencies-v1- - run: name: Install dependencies diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..8d3cbe8 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,5 @@ +inherit_from: + - https://onehq.com/rubocop3_4.yml + +AllCops: + SuggestExtensions: false \ No newline at end of file diff --git a/Gemfile b/Gemfile index 5a96427..37c9292 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,17 @@ # frozen_string_literal: true -source "http://rubygems.org" - -gemspec +source "https://rubygems.org" +gem "base64" +gem "benchmark" +gem "bigdecimal" gem "byebug" +gem "logger" +gem "mutex_m" +gem "ostruct" +gem "rubocop", "~> 1.81" +gem "rubocop-performance", "~> 1.26" +gem "rubocop-rails", "~> 2.34" +gem "sqlite3", "~> 1.4" + +gemspec diff --git a/has_safe_dates.gemspec b/has_safe_dates.gemspec index dce531a..0388b91 100644 --- a/has_safe_dates.gemspec +++ b/has_safe_dates.gemspec @@ -7,48 +7,45 @@ require "has_safe_dates/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "has_safe_dates" - s.version = HasSafeDates::VERSION - s.authors = ["kylejginavan"] - s.date = "2012-02-24" - s.description = "Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings" - s.email = "kylejginavan@gmail.com" + s.name = "has_safe_dates" + s.version = HasSafeDates::VERSION + s.authors = ["kylejginavan"] + s.date = "2012-02-24" + s.description = "Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings" + s.email = "kylejginavan@gmail.com" + s.required_ruby_version = ">= 3.4" - s.extra_rdoc_files = [ - "MIT-LICENSE.txt", - "README.md" - ] - s.files = `git ls-files`.split("\n") - s.homepage = "http://github.com/kylejginavan/has_safe_dates" - s.require_paths = ["lib"] - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } - s.summary = "Chronic based date setting for ActiveRecord models" + s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md"] + s.files = `git ls-files`.split("\n") + s.homepage = "http://github.com/kylejginavan/has_safe_dates" + s.require_paths = ["lib"] + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } + s.summary = "Chronic based date setting for ActiveRecord models" - if s.respond_to? :specification_version then + if s.respond_to? :specification_version s.specification_version = 3 - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.2.0") then + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.2.0") s.add_development_dependency("activerecord", ["~> 6.0"]) s.add_development_dependency("bundler", ["~> 2.0"]) s.add_dependency("chronic") s.add_development_dependency("database_cleaner") - s.add_development_dependency("rdoc", ["~> 3.12"]) - s.add_development_dependency("rspec", [">= 0", "< 3"]) + s.add_development_dependency("rdoc", ">= 6.0") + s.add_development_dependency("rspec", "~> 3.13") s.add_development_dependency("rspec_junit_formatter", ["~> 0.3", ">= 0.3.0"]) - s.add_development_dependency("sqlite3") else s.add_dependency("activerecord", [">= 3.1.0"]) s.add_dependency("bundler", ["~> 2.0"]) s.add_dependency("chronic") - s.add_dependency("rdoc", ["~> 3.12"]) + s.add_dependency("rdoc", ">= 6.0") s.add_dependency("rspec", [">= 0"]) end else s.add_dependency("activerecord", [">= 3.1.0"]) s.add_dependency("bundler", ["~> 2.0"]) s.add_dependency("chronic") - s.add_dependency("rdoc", ["~> 3.12"]) + s.add_dependency("rdoc", ["~> 6.17"]) s.add_dependency("rspec", [">= 0"]) end end diff --git a/lib/has_safe_dates/core_ext.rb b/lib/has_safe_dates/core_ext.rb index 3feb84b..1d4b174 100644 --- a/lib/has_safe_dates/core_ext.rb +++ b/lib/has_safe_dates/core_ext.rb @@ -72,11 +72,11 @@ def execute_callstack_for_multiparameter_attributes(callstack) end end else - super(callstack) # has_safe_dates is not enabled for the current field, so invoke the super method + super(callstack) # has_safe_dates is not enabled for the current field, so invoke the super method end end end end -::ActiveRecord::Base.send :include, ::HasSafeDates::CoreExt -::ActiveRecord::Base.send :prepend, ::HasSafeDates::DateTimeExt +::ActiveRecord::Base.include ::HasSafeDates::CoreExt +::ActiveRecord::Base.prepend ::HasSafeDates::DateTimeExt diff --git a/lib/has_safe_dates/version.rb b/lib/has_safe_dates/version.rb index dd8c609..f67b2ca 100644 --- a/lib/has_safe_dates/version.rb +++ b/lib/has_safe_dates/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HasSafeDates - VERSION = "5.0.0-beta.1" + VERSION = "5.0.0-beta.2" end diff --git a/spec/db/schema.rb b/spec/db/schema.rb index 2491183..778e5a6 100644 --- a/spec/db/schema.rb +++ b/spec/db/schema.rb @@ -1,8 +1,9 @@ -# require File.join(File.dirname(__FILE__), 'fixtures/document') +# frozen_string_literal: true -ActiveRecord::Schema.define(:version => 0) do +# require File.join(File.dirname(__FILE__), 'fixtures/document') - create_table "comments", :force => true do |t| +ActiveRecord::Schema.define(version: 0) do + create_table "comments", force: true do |t| t.text "body" t.date "approved_at" t.date "created_at" @@ -10,7 +11,7 @@ t.datetime "published_at" end - create_table "posts", :force => true do |t| + create_table "posts", force: true do |t| t.string "title" t.date "published_date" t.date "safe_date" @@ -18,5 +19,4 @@ t.date "created_at" t.date "updated_at" end - end diff --git a/spec/has_safe_dates_spec.rb b/spec/has_safe_dates_spec.rb index 9ec6d1b..cbcb88d 100644 --- a/spec/has_safe_dates_spec.rb +++ b/spec/has_safe_dates_spec.rb @@ -1,132 +1,131 @@ -require 'spec_helper' +# frozen_string_literal: true + +require "spec_helper" class TestUser < ActiveRecord::Base; end class Post < ActiveRecord::Base - has_safe_dates :published_date, :safe_date, :error_message => 'is not a real date' + has_safe_dates :published_date, :safe_date, error_message: "is not a real date" end class Comment < ActiveRecord::Base - has_safe_dates :approved_at, :published_at, :error_message => 'is not a real date' + has_safe_dates :approved_at, :published_at, error_message: "is not a real date" end -describe "HasSafeDates" do - - before(:each) do +RSpec.describe "HasSafeDates" do + before do @post = Post.new @comment = Comment.new end describe "class method" do - it "should work" do - expect { - TestUser.send(:has_safe_dates, :published_date) - }.to_not raise_error + expect { TestUser.send(:has_safe_dates, :published_date) }.not_to raise_error end it "should raise an error if no fields are passed in" do - expect { - TestUser.send(:has_safe_dates) - }.to raise_error(ArgumentError, 'Must define the fields you want to be converted to safe dates with "has_safe_dates :my_field_name_date, :my_other_field_name_date"') + expect { TestUser.send(:has_safe_dates) }. + to raise_error(ArgumentError, + 'Must define the fields you want to be converted to safe dates with "has_safe_dates :my_field_name_date, :my_other_field_name_date"') end - it "does not touch an field that it has not been told to make safe" do - @post.update_attribute(:unsafe_date, '1st of December 2012') + it "does not touch a field that it has not been told to make safe" do + @post.update_attribute(:unsafe_date, "1st of December 2012") @post.reload - @post.unsafe_date.should be_nil + + expect(@post.unsafe_date).to be_nil end end describe "safe date parsing" do - - ['2012-12-1', '1st of December 2012', 'first of dec 2012', '1 Dec 2012'].each do |date| + ["2012-12-1", "1st of December 2012", "first of dec 2012", "1 Dec 2012"].each do |date| it "allows you to set the date as '#{date}'" do @post.update_attribute(:safe_date, date) @comment.update_attribute(:approved_at, date) @post.reload @comment.reload - @post.safe_date.should == Date.new(2012, 12, 1) - @comment.approved_at.should == Date.new(2012, 12, 1) + + expect(@post.safe_date).to eq(Date.new(2012, 12, 1)) + expect(@comment.approved_at).to eq(Date.new(2012, 12, 1)) end end - [' ', '', nil].each do |date| + [" ", "", nil].each do |date| it "sets the field to nil if given the blank value #{date.inspect}" do @post.safe_date = date @post.valid? - @post.safe_date.should == nil - @post.errors.should be_blank + + expect(@post.safe_date).to be_nil + expect(@post.errors).to be_empty end end - ['random', 'does not compute'].each do |date| + ["random", "does not compute"].each do |date| it "sets the field to nil and sets a validation error if given the value #{date.inspect}" do @post.safe_date = date @post.valid? - @post.safe_date.should == nil - @post.errors.should_not be_blank - @post.errors[:safe_date].should == ['is not a real date'] + + expect(@post.safe_date).to be_nil + expect(@post.errors[:safe_date]).to eq(["is not a real date"]) end end - end describe "multiparameter parsing" do + it "doesn't blow up when given incorrect values" do + invalid_post_attributes = { "published_date(1i)" => "2001", "published_date(2i)" => "12", "published_date(3i)" => "abc" } + invalid_comment_attributes = { "approved_at(1i)" => "2001", "approved_at(2i)" => "15", "approved_at(3i)" => "17" } - it "doesn't blow up when given an incorrect values" do - invalid_post_attributes = {'published_date(1i)' => "2001", 'published_date(2i)' => "12", 'published_date(3i)' => "abc"} - invalid_comment_attributes = {'approved_at(1i)' => "2001", 'approved_at(2i)' => "15", 'approved_at(3i)' => "17"} - expect { + expect do @post.update(invalid_post_attributes) @comment.update(invalid_comment_attributes) - }.to_not raise_error + end.not_to raise_error end it "does not interfere with a date column that it has not been told to make safe" do - invalid_attributes = {'unsafe_date(1i)' => "2001", 'unsafe_date(2i)' => "12", 'unsafe_date(3i)' => "abc"} - expect { - @post.update(invalid_attributes) - }.to raise_error(ActiveRecord::MultiparameterAssignmentErrors) + invalid_attributes = { "unsafe_date(1i)" => "2001", "unsafe_date(2i)" => "12", "unsafe_date(3i)" => "abc" } + + expect { @post.update(invalid_attributes) }.to raise_error(ActiveRecord::MultiparameterAssignmentErrors) end it "adds an error when Chronic returns nil" do - invalid_post_attributes = {'published_date(1i)' => "2014", 'published_date(2i)' => "12", 'published_date(3i)' => "abc"} + invalid_post_attributes = { "published_date(1i)" => "2014", "published_date(2i)" => "12", "published_date(3i)" => "abc" } @post.update(invalid_post_attributes) - @post.errors[:published_date].should == ['is not a real date'] + + expect(@post.errors[:published_date]).to eq(["is not a real date"]) end context "with time" do it "works" do - invalid_comment_attributes = {'published_at(1i)' => "2014", 'published_at(2i)' => "12", 'published_at(3i)' => "22", 'published_at(4i)' => "12", 'published_at(5i)' => "34"} - expect { - @comment.update(invalid_comment_attributes) - }.to_not raise_error - expect(@comment.published_at.utc.strftime("%FT%T%:z")).to eq(Time.new(2014, 12, 22, 12, 34).utc.strftime("%FT%T%:z")) + attrs = { "published_at(1i)" => "2014", "published_at(2i)" => "12", "published_at(3i)" => "22", "published_at(4i)" => "12", "published_at(5i)" => "34" } + + expect { @comment.update(attrs) }.not_to raise_error + expect(@comment.published_at.utc.strftime("%FT%T%:z")). + to eq(Time.new(2014, 12, 22, 12, 34).utc.strftime("%FT%T%:z")) end - it "doesn't blow up when given an incorrect values" do - invalid_post_attributes = {'published_date(1i)' => "2001", 'published_date(2i)' => "12", 'published_date(3i)' => "17", 'published_date(4i)' => "12", 'published_date(5i)' => "34"} - invalid_comment_attributes = {'published_at(1i)' => "2001", 'published_at(2i)' => "15", 'published_at(3i)' => "17", 'published_at(4i)' => "12", 'published_at(5i)' => "34"} - expect { + it "doesn't blow up when given incorrect values" do + invalid_post_attributes = { "published_date(1i)" => "2001", "published_date(2i)" => "12", "published_date(3i)" => "17", "published_date(4i)" => "12", "published_date(5i)" => "34" } + invalid_comment_attributes = { "published_at(1i)" => "2001", "published_at(2i)" => "15", "published_at(3i)" => "17", "published_at(4i)" => "12", "published_at(5i)" => "34" } + + expect do @post.update(invalid_post_attributes) @comment.update(invalid_comment_attributes) - }.to_not raise_error + end.not_to raise_error end it "does not interfere with a date column that it has not been told to make safe" do - invalid_attributes = {'unsafe_date(1i)' => "2011", 'unsafe_date(2i)' => "9", 'unsafe_date(3i)' => "83", 'unsafe_date(4i)' => "12", 'unsafe_date(5i)' => "34"} - expect { - @post.update(invalid_attributes) - }.to raise_error(ActiveRecord::MultiparameterAssignmentErrors) + invalid_attributes = { "unsafe_date(1i)" => "2011", "unsafe_date(2i)" => "9", "unsafe_date(3i)" => "83", "unsafe_date(4i)" => "12", "unsafe_date(5i)" => "34" } + + expect { @post.update(invalid_attributes) }.to raise_error(ActiveRecord::MultiparameterAssignmentErrors) end it "adds an error when Chronic returns nil" do - invalid_comment_attributes = {'published_at(1i)' => "2009", 'published_at(2i)' => "12", 'published_at(3i)' => "90", 'published_at(4i)' => "12", 'published_at(5i)' => "34"} - @comment.update(invalid_comment_attributes) - @comment.errors[:published_at].should == ['is not a real date'] + attrs = { "published_at(1i)" => "2009", "published_at(2i)" => "12", "published_at(3i)" => "90", "published_at(4i)" => "12", "published_at(5i)" => "34" } + @comment.update(attrs) + + expect(@comment.errors[:published_at]).to eq(["is not a real date"]) end end end - end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c312067..02832e5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +require "logger" require "active_support" require "active_record" require "database_cleaner" @@ -6,8 +9,8 @@ ENV["debug"] = "test" unless ENV["debug"] # Establish DB Connection -config = YAML::load(IO.read(File.join(File.dirname(__FILE__), "db", "database.yml"))) -ActiveRecord::Base.configurations = {"test" => config[ENV["DB"] || "sqlite3"]} +config = YAML.load(IO.read(File.join(File.dirname(__FILE__), "db", "database.yml"))) +ActiveRecord::Base.configurations = { "test" => config[ENV["DB"] || "sqlite3"] } ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations["test"]) # Load Test Schema into the Database @@ -19,7 +22,6 @@ require "has_safe_dates" RSpec.configure do |config| - config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) @@ -32,5 +34,4 @@ config.after(:each) do DatabaseCleaner.clean end - end From bd45047fac8b34394d54f774f859b63d21347ef6 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Mon, 5 Jan 2026 13:46:58 -0300 Subject: [PATCH 3/6] indentation --- Gemfile | 8 ++++---- has_safe_dates.gemspec | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 37c9292..7425f42 100644 --- a/Gemfile +++ b/Gemfile @@ -9,9 +9,9 @@ gem "byebug" gem "logger" gem "mutex_m" gem "ostruct" -gem "rubocop", "~> 1.81" -gem "rubocop-performance", "~> 1.26" -gem "rubocop-rails", "~> 2.34" -gem "sqlite3", "~> 1.4" +gem "rubocop", "~> 1.81" +gem "rubocop-performance", "~> 1.26" +gem "rubocop-rails", "~> 2.34" +gem "sqlite3", "~> 1.4" gemspec diff --git a/has_safe_dates.gemspec b/has_safe_dates.gemspec index 0388b91..ab2625b 100644 --- a/has_safe_dates.gemspec +++ b/has_safe_dates.gemspec @@ -7,21 +7,21 @@ require "has_safe_dates/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "has_safe_dates" - s.version = HasSafeDates::VERSION - s.authors = ["kylejginavan"] - s.date = "2012-02-24" - s.description = "Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings" - s.email = "kylejginavan@gmail.com" + s.name = "has_safe_dates" + s.version = HasSafeDates::VERSION + s.authors = ["kylejginavan"] + s.date = "2012-02-24" + s.description = "Uses Chronic to parse incoming dates and does not raise errors on invalid multi parameter settings" + s.email = "kylejginavan@gmail.com" s.required_ruby_version = ">= 3.4" - s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md"] - s.files = `git ls-files`.split("\n") - s.homepage = "http://github.com/kylejginavan/has_safe_dates" - s.require_paths = ["lib"] - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } - s.summary = "Chronic based date setting for ActiveRecord models" + s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md"] + s.files = `git ls-files`.split("\n") + s.homepage = "http://github.com/kylejginavan/has_safe_dates" + s.require_paths = ["lib"] + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } + s.summary = "Chronic based date setting for ActiveRecord models" if s.respond_to? :specification_version s.specification_version = 3 From 8f65a79ae84f9c087b6113f5a9c7bb600c648aba Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 6 Jan 2026 11:44:39 -0300 Subject: [PATCH 4/6] gemfile update --- has_safe_dates.gemspec | 31 +++++++------------------------ lib/has_safe_dates/version.rb | 2 +- spec/spec_helper.rb | 25 ++++++++++--------------- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/has_safe_dates.gemspec b/has_safe_dates.gemspec index ab2625b..d571d9d 100644 --- a/has_safe_dates.gemspec +++ b/has_safe_dates.gemspec @@ -22,30 +22,13 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } s.summary = "Chronic based date setting for ActiveRecord models" + s.licenses = ["HQ"] - if s.respond_to? :specification_version - s.specification_version = 3 + s.add_dependency "chronic", "~> 0.10" - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.2.0") - s.add_development_dependency("activerecord", ["~> 6.0"]) - s.add_development_dependency("bundler", ["~> 2.0"]) - s.add_dependency("chronic") - s.add_development_dependency("database_cleaner") - s.add_development_dependency("rdoc", ">= 6.0") - s.add_development_dependency("rspec", "~> 3.13") - s.add_development_dependency("rspec_junit_formatter", ["~> 0.3", ">= 0.3.0"]) - else - s.add_dependency("activerecord", [">= 3.1.0"]) - s.add_dependency("bundler", ["~> 2.0"]) - s.add_dependency("chronic") - s.add_dependency("rdoc", ">= 6.0") - s.add_dependency("rspec", [">= 0"]) - end - else - s.add_dependency("activerecord", [">= 3.1.0"]) - s.add_dependency("bundler", ["~> 2.0"]) - s.add_dependency("chronic") - s.add_dependency("rdoc", ["~> 6.17"]) - s.add_dependency("rspec", [">= 0"]) - end + s.add_development_dependency "activerecord", "~> 7.2" + s.add_development_dependency "database_cleaner", "~> 2.1" + s.add_development_dependency "rdoc", "~> 7.0" + s.add_development_dependency "rspec", "~> 3.13" + s.add_development_dependency "rspec_junit_formatter", "~> 0.6", ">= 0.3.0" end diff --git a/lib/has_safe_dates/version.rb b/lib/has_safe_dates/version.rb index f67b2ca..634deb8 100644 --- a/lib/has_safe_dates/version.rb +++ b/lib/has_safe_dates/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HasSafeDates - VERSION = "5.0.0-beta.2" + VERSION = "5.0.0-beta.3" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 02832e5..c541961 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,17 +8,17 @@ ENV["debug"] = "test" unless ENV["debug"] -# Establish DB Connection -config = YAML.load(IO.read(File.join(File.dirname(__FILE__), "db", "database.yml"))) -ActiveRecord::Base.configurations = { "test" => config[ENV["DB"] || "sqlite3"] } -ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations["test"]) +config_path = File.join(__dir__, "db", "database.yml") +config = YAML.load_file(config_path) -# Load Test Schema into the Database -load(File.dirname(__FILE__) + "/db/schema.rb") +db_key = ENV["DB"] || "sqlite3" +db_config = config.fetch(db_key) -# Load in our code -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" +ActiveRecord::Base.establish_connection(db_config) +load File.join(__dir__, "db", "schema.rb") + +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "has_safe_dates" RSpec.configure do |config| @@ -27,11 +27,6 @@ DatabaseCleaner.clean_with(:truncation) end - config.before(:each) do - DatabaseCleaner.start - end - - config.after(:each) do - DatabaseCleaner.clean - end + config.before(:each) { DatabaseCleaner.start } + config.after(:each) { DatabaseCleaner.clean } end From 8234d5b025110b03f8b24b17b5d19991220b552c Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 7 Apr 2026 10:45:17 -0300 Subject: [PATCH 5/6] 5.0 cut --- .tekton/Chart.yaml | 8 ++-- .tekton/values-main.yaml | 72 +++++++++++++++++------------------ .tekton/values-pr.yaml | 54 +++++++++++++------------- .tekton/values.yaml | 4 +- lib/has_safe_dates/version.rb | 2 +- 5 files changed, 70 insertions(+), 70 deletions(-) diff --git a/.tekton/Chart.yaml b/.tekton/Chart.yaml index 0e56d75..25ca85f 100644 --- a/.tekton/Chart.yaml +++ b/.tekton/Chart.yaml @@ -10,7 +10,7 @@ type: application version: 0.1.0 dependencies: -- name: ruby-pipelines - alias: delivery - version: "0.2.0-dev.4" - repository: "oci://public.ecr.aws/c6o8b8d1" + - name: ruby-pipelines + alias: delivery + version: "0.2.0-dev.4" + repository: "oci://public.ecr.aws/c6o8b8d1" diff --git a/.tekton/values-main.yaml b/.tekton/values-main.yaml index 5753986..2545ed5 100644 --- a/.tekton/values-main.yaml +++ b/.tekton/values-main.yaml @@ -6,48 +6,48 @@ delivery: - role: cr_admin_pipes name: adminpipe subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_release_adminpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygemsadminallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_adminallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_release_adminpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygemsadminallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_adminallpipe - role: cr_operator_pipes name: operatorpipe subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_release_operatorpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_operatorallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_operatorallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_release_operatorpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_operatorallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_operatorallpipe - role: cr_read_PLR name: readPLR subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_release_readpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_readallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_readallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_release_readpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_readallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_readallpipe - role: cr_read_rerun_PLR name: readrerunPLR subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_release_readrerunpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_readrerunallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_readrerunallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_release_readrerunpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_readrerunallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_readrerunallpipe diff --git a/.tekton/values-pr.yaml b/.tekton/values-pr.yaml index 5470528..d99012d 100644 --- a/.tekton/values-pr.yaml +++ b/.tekton/values-pr.yaml @@ -5,36 +5,36 @@ delivery: - role: cr_admin_pipes name: adminpipe subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_pr_adminpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_adminallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_adminallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_pr_adminpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_adminallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_adminallpipe - role: cr_operator_pipes name: operatorpipe subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_pr_operatorpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_operatorallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_operatorallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_pr_operatorpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_operatorallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_operatorallpipe - role: cr_read_rerun_PLR name: readrerunPLR subjects: - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_pr_readrerunpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_rubygems_readrerunallpipe - - kind: Group - apiGroup: rbac.authorization.k8s.io - name: g_hq_readrerunallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_pr_readrerunpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_rubygems_readrerunallpipe + - kind: Group + apiGroup: rbac.authorization.k8s.io + name: g_hq_readrerunallpipe diff --git a/.tekton/values.yaml b/.tekton/values.yaml index 59aa956..f2ad0c8 100644 --- a/.tekton/values.yaml +++ b/.tekton/values.yaml @@ -8,11 +8,11 @@ git: global: - taskAnnotations: + taskAnnotations: vault.security.banzaicloud.io/vault-addr: "https://vault-onehq.apps.hub.internal.onehq.com" vault.security.banzaicloud.io/vault-path: "jwt-hub" vault.security.banzaicloud.io/vault-auth-method: "jwt" - vault.security.banzaicloud.io/vault-tls-secret: "custom-trusted-ca" + vault.security.banzaicloud.io/vault-tls-secret: "custom-trusted-ca" gem: *gem rubyVersion: 3.0.2 mountGemDockerfile: true diff --git a/lib/has_safe_dates/version.rb b/lib/has_safe_dates/version.rb index 634deb8..3677e9e 100644 --- a/lib/has_safe_dates/version.rb +++ b/lib/has_safe_dates/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HasSafeDates - VERSION = "5.0.0-beta.3" + VERSION = "5.0.0" end From 6cf2149c8e7abf445bb2d1c4fc48f6a3ffd01ef8 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Thu, 16 Apr 2026 16:32:17 -0300 Subject: [PATCH 6/6] beta.4 (with review feedbacks applied) --- .tekton/templates/pipeline-gem-delivery.yaml | 211 +++++++++---------- .tekton/templates/pipelinerun.yaml | 45 ++-- .tekton/values.yaml | 5 +- README.md | 20 +- has_safe_dates.gemspec | 2 +- lib/has_safe_dates/version.rb | 2 +- 6 files changed, 136 insertions(+), 149 deletions(-) diff --git a/.tekton/templates/pipeline-gem-delivery.yaml b/.tekton/templates/pipeline-gem-delivery.yaml index ab65e82..48283b2 100644 --- a/.tekton/templates/pipeline-gem-delivery.yaml +++ b/.tekton/templates/pipeline-gem-delivery.yaml @@ -4,117 +4,108 @@ metadata: name: gem-delivery-has-reports spec: params: - - name: ci-image-name - description: CI image name - - name: gem-name - description: Gem name - - name: publish - default: 'false' - - name: git-url - description: URL of git repository - - name: git-sha - - name: git-ref - - name: spec-path - description: Path for ruby specs (e.g. "spec/{abilities,apis,commands}") - default: "spec" + - name: ci-image-name + description: CI image name + - name: gem-name + description: Gem name + - name: publish + default: 'false' + - name: git-url + description: URL of git repository + - name: git-sha + - name: git-ref + - name: spec-path + description: Path for ruby specs (e.g. "spec/{abilities,apis,commands}") + default: "spec" workspaces: - - name: git-source + - name: git-source tasks: - - - name: set-initial-status - taskRef: - kind: Task - name: github-set-status - params: - - name: gitRepoName - value: $(params.gem-name) - - name: gitOrganization - value: OneHQ - -# This job gets the source from git - - name: fetch-from-git - taskRef: - name: git-clone - kind: ClusterTask - params: - - name: url - value: $(params.git-url) - - name: refspec - value: "$(params.git-ref):refs/heads/workingcopy" - - name: revision - value: workingcopy - workspaces: - - name: output - workspace: git-source - -# This job gets the source from git - - name: build-ci-image - taskRef: - name: buildkit - workspaces: - - name: source - workspace: git-source - params: - - name: TAG - value: $(params.git-sha) - - name: IMAGE - value: $(params.ci-image-name) - runAfter: - - fetch-from-git -# This job gets the source from git - - name: run-specs - taskRef: - name: ruby-run-specs - params: - - name: image - value: $(params.ci-image-name):$(params.git-sha) - - name: prepare-database - value: "false" - - name: spec-path - value: $(params.spec-path) - - name: app - value: $(params.gem-name) - - runAfter: - - build-ci-image - - - - name: run-rubocop - params: - - name: app - value: $(params.gem-name) - - name: image - value: $(params.ci-image-name):$(params.git-sha) - taskRef: - name: ruby-run-rubocop - - runAfter: - - build-ci-image - - - name: publish-gem - params: - - name: gem-name - value: $(params.gem-name) - - name: image - value: $(params.ci-image-name):$(params.git-sha) - when: - - input: "$(params.publish)" - operator: in - values: ["true"] - taskRef: - name: publish-to-gemfury - runAfter: - - run-rubocop - - run-specs - + - name: set-initial-status + taskRef: + kind: Task + name: github-set-status + params: + - name: gitRepoName + value: $(params.gem-name) + - name: gitOrganization + value: OneHQ + # This job gets the source from git + - name: fetch-from-git + taskRef: + name: git-clone + kind: ClusterTask + params: + - name: url + value: $(params.git-url) + - name: refspec + value: "$(params.git-ref):refs/heads/workingcopy" + - name: revision + value: workingcopy + workspaces: + - name: output + workspace: git-source + # This job gets the source from git + - name: build-ci-image + taskRef: + name: buildkit + workspaces: + - name: source + workspace: git-source + params: + - name: TAG + value: $(params.git-sha) + - name: IMAGE + value: $(params.ci-image-name) + runAfter: + - fetch-from-git + # This job gets the source from git + - name: run-specs + taskRef: + name: ruby-run-specs + params: + - name: image + value: $(params.ci-image-name):$(params.git-sha) + - name: prepare-database + value: "false" + - name: spec-path + value: $(params.spec-path) + - name: app + value: $(params.gem-name) + runAfter: + - build-ci-image + - name: run-rubocop + params: + - name: app + value: $(params.gem-name) + - name: image + value: $(params.ci-image-name):$(params.git-sha) + taskRef: + name: ruby-run-rubocop + runAfter: + - build-ci-image + - name: publish-gem + params: + - name: gem-name + value: $(params.gem-name) + - name: image + value: $(params.ci-image-name):$(params.git-sha) + when: + - input: "$(params.publish)" + operator: in + values: [ "true" ] + taskRef: + name: publish-to-gemfury + runAfter: + - run-rubocop + - run-specs finally: - - name: set-final-status - taskRef: - kind: Task - name: github-set-status - params: - - name: gitRepoName - value: $(params.gem-name) - - name: gitOrganization - value: OneHQ + - name: set-final-status + taskRef: + kind: Task + name: github-set-status + params: + - name: gitRepoName + value: $(params.gem-name) + - name: gitOrganization + value: OneHQ diff --git a/.tekton/templates/pipelinerun.yaml b/.tekton/templates/pipelinerun.yaml index 4af4a80..e7c3c45 100644 --- a/.tekton/templates/pipelinerun.yaml +++ b/.tekton/templates/pipelinerun.yaml @@ -1,40 +1,38 @@ apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata: - name: {{ .Release.Name }}-{{ .Release.Revision }} + name: { { .Release.Name } }-{{ .Release.Revision }} annotations: "helm.sh/hook": post-upgrade,post-install spec: serviceAccountName: build-bot params: - - name: ci-image-name - value: onehq.azurecr.io/{{ .Values.gem }}-ci - - name: gem-name - value: "{{ .Values.gem }}" - - name: publish - value: '{{ .Values.publish }}' - - name: git-url - value: "https://{{ .Values.git.provider }}/{{ .Values.git.organization }}/{{ .Values.git.repository }}.git" - - name: git-sha - value: "{{ .Values.git.sha }}" - - name: git-ref - value: "{{ required "Required .Values.git.ref" .Values.git.ref }}" - - name: rubyVersion - value: "{{ .Values.rubyVersion }}" - workspaces: - + - name: ci-image-name + value: onehq.azurecr.io/{{ .Values.gem }}-ci + - name: gem-name + value: "{{ .Values.gem }}" + - name: publish + value: '{{ .Values.publish }}' + - name: git-url + value: "https://{{ .Values.git.provider }}/{{ .Values.git.organization }}/{{ .Values.git.repository }}.git" + - name: git-sha + value: "{{ .Values.git.sha }}" + - name: git-ref + value: "{{ required "Required .Values.git.ref" .Values.git.ref }}" + - name: rubyVersion + value: "{{ .Values.rubyVersion }}" pipelineRef: name: gem-delivery-has-reports timeout: 1h30m0s podTemplate: volumes: - - name: oidc-token - projected: - sources: - - serviceAccountToken: - path: oidc-token - expirationSeconds: 1800 + - name: oidc-token + projected: + sources: + - serviceAccountToken: + path: oidc-token + expirationSeconds: 1800 workspaces: - name: git-source @@ -46,4 +44,3 @@ spec: resources: requests: storage: 1Gi - diff --git a/.tekton/values.yaml b/.tekton/values.yaml index f2ad0c8..d48c67f 100644 --- a/.tekton/values.yaml +++ b/.tekton/values.yaml @@ -6,7 +6,6 @@ git: organization: OneHQ repository: *gem - global: taskAnnotations: vault.security.banzaicloud.io/vault-addr: "https://vault-onehq.apps.hub.internal.onehq.com" @@ -14,5 +13,5 @@ global: vault.security.banzaicloud.io/vault-auth-method: "jwt" vault.security.banzaicloud.io/vault-tls-secret: "custom-trusted-ca" gem: *gem - rubyVersion: 3.0.2 - mountGemDockerfile: true + rubyVersion: 3.4.4 + mountGemDockerfile: true diff --git a/README.md b/README.md index 782a00e..3fa259d 100644 --- a/README.md +++ b/README.md @@ -40,29 +40,29 @@ Do the following to publish and push a new gem: 1) Make sure the local working copy is clean with no pending commits: - $ git status - # On branch master - nothing to commit (working directory clean) + $ git status + # On branch master + nothing to commit (working directory clean) 2) Edit the version number and increment per SEMVER versioning: - $ vi lib/has_safe_dates/version.rb + $ vi lib/has_safe_dates/version.rb 3) Run gem build to create the gem: - $ gem build has_safe_dates.gemspec + $ gem build has_safe_dates.gemspec 4) Test install the gem locally: - $ gem install has_safe_dates-0.0.1.gem + $ gem install has_safe_dates-0.0.1.gem 5) Commit any changes and tag the commit at the current version: - $ git commit lib/has_safe_dates/version.rb -m "Releasing v0.0.1" - $ git tag v0.0.1 - $ git push + $ git commit lib/has_safe_dates/version.rb -m "Releasing v0.0.1" + $ git tag v0.0.1 + $ git push 6) Push the gem to rubygems: - $ gem push has_safe_dates-0.0.1.gem + $ gem push has_safe_dates-0.0.1.gem diff --git a/has_safe_dates.gemspec b/has_safe_dates.gemspec index d571d9d..3b901a4 100644 --- a/has_safe_dates.gemspec +++ b/has_safe_dates.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.email = "kylejginavan@gmail.com" s.required_ruby_version = ">= 3.4" - s.extra_rdoc_files = ["MIT-LICENSE.txt", "README.md"] + s.extra_rdoc_files = %w[MIT-LICENSE.txt README.md] s.files = `git ls-files`.split("\n") s.homepage = "http://github.com/kylejginavan/has_safe_dates" s.require_paths = ["lib"] diff --git a/lib/has_safe_dates/version.rb b/lib/has_safe_dates/version.rb index 3677e9e..677ceaa 100644 --- a/lib/has_safe_dates/version.rb +++ b/lib/has_safe_dates/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HasSafeDates - VERSION = "5.0.0" + VERSION = "5.0.0-beta.4" end