From 87dad295dd4507e5e5b8bfe9190b722b3a202e04 Mon Sep 17 00:00:00 2001 From: Reegan Viljoen Date: Fri, 1 Sep 2023 08:06:45 +0200 Subject: [PATCH 1/4] add: version 2 --- .github/workflowas/ci.yml | 30 +++++++++++++++++++ Gemfile.lock | 7 +++-- README.md | 30 +++++++++---------- lib/{proc_evaluate.rb => proc_eval.rb} | 4 +-- lib/proc_eval/version.rb | 3 ++ lib/proc_evaluate/version.rb | 3 -- proc_evaluate.gemspec => proc_eval.gemspec | 14 ++++----- ...est_proc_evaluate.rb => test_proc_eval.rb} | 10 +++---- 8 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 .github/workflowas/ci.yml rename lib/{proc_evaluate.rb => proc_eval.rb} (96%) create mode 100644 lib/proc_eval/version.rb delete mode 100644 lib/proc_evaluate/version.rb rename proc_evaluate.gemspec => proc_eval.gemspec (82%) rename test/{test_proc_evaluate.rb => test_proc_eval.rb} (90%) diff --git a/.github/workflowas/ci.yml b/.github/workflowas/ci.yml new file mode 100644 index 0000000..3b450ff --- /dev/null +++ b/.github/workflowas/ci.yml @@ -0,0 +1,30 @@ +name: Ruby + +on: + push: + branches: + - main + + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} + strategy: + matrix: + include: + - ruby_version: "2.7" + - ruby_version: "3.0" + - ruby-version: "3.1" + - ruby-version: "3.2" + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - name: Run the default task + run: bundle exec rake diff --git a/Gemfile.lock b/Gemfile.lock index aa755c2..e3e374f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - proc_evaluate (1.0.0) + proc_eval (2.0.0) GEM remote: https://rubygems.org/ @@ -10,12 +10,13 @@ GEM rake (13.0.6) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES minitest (~> 5.0) - proc_evaluate! + proc_eval! rake (~> 13.0) BUNDLED WITH - 2.3.14 + 2.4.8 diff --git a/README.md b/README.md index e839d70..7d2ed3c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ProcEvaluate +# ProcEval This ruby gem adds an `evaulate` method to Proc and Object instances through the use of [Refinements][1]. @@ -44,19 +44,19 @@ Because this gem makes use of keyword parameters and refinements, it is only com ## Usage -In your `Gemfile` add `gem 'proc_evaluate'`. +In your `Gemfile` add `gem 'proc_eval'`. -In your codebase add `require 'proc_evaluate'`. +In your codebase add `require 'proc_eval'`. -The refinement methods in the gem can be used by including `using ProcEvaluate` in the file, **class** definition, or **module** definition in which you wish to use the [refinement][1]. +The refinement methods in the gem can be used by including `using ProcEval` in the file, **class** definition, or **module** definition in which you wish to use the [refinement][1]. ### Class and Module usage The refinement methods can be activated for use within a specific Class or Module. ```ruby -class ProcEvaluateClassExamples - using ProcEvaluate +class ProcEvalClassExamples + using ProcEval def example1 a = ->(a) { a } @@ -79,14 +79,14 @@ class ProcEvaluateClassExamples end end -e = ProcEvaluateClassExamples.new +e = ProcEvalClassExamples.new e.example1 # "hello" e.example2 # [1, 2, 3, 4, nil, nil, nil] e.example3 # "Im a proc!!!" e.example4 # "im a value!!!" -module ProcEvaluateModuleExamples - using ProcEvaluate +module ProcEvalModuleExamples + using ProcEval extend self def example1 @@ -110,17 +110,17 @@ module ProcEvaluateModuleExamples end end -ProcEvaluateModuleExamples.example1 # "hello" -ProcEvaluateModuleExamples.example2 # [1, 2, 3, 4, nil, nil, nil] -ProcEvaluateModuleExamples.example3 # "Im a proc!!!" -ProcEvaluateModuleExamples.example4 # "im a value!!!" +ProcEvalModuleExamples.example1 # "hello" +ProcEvalModuleExamples.example2 # [1, 2, 3, 4, nil, nil, nil] +ProcEvalModuleExamples.example3 # "Im a proc!!!" +ProcEvalModuleExamples.example4 # "im a value!!!" ``` Another example showing a different pattern of usage: ```ruby class Example - using ProcEvaluate + using ProcEval def initialize(value) @value = value @@ -165,7 +165,7 @@ To test the example, place the code into a file and run with the command `ruby e ```ruby # example.rb -using ProcEvaluate # activate the refinements for the current file +using ProcEval # activate the refinements for the current file proc = proc {|a, b, c| [a, b, c] } proc.evaluate() # [nil, nil, nil] diff --git a/lib/proc_evaluate.rb b/lib/proc_eval.rb similarity index 96% rename from lib/proc_evaluate.rb rename to lib/proc_eval.rb index 8d7a174..f0c461d 100644 --- a/lib/proc_evaluate.rb +++ b/lib/proc_eval.rb @@ -1,4 +1,4 @@ -module ProcEvaluate +module ProcEval refine Object do def evaluate(*args, **options) @@ -59,4 +59,4 @@ def evaluate(*args, **options) end # refine Proc end -require 'proc_evaluate/version' +require 'proc_eval/version' diff --git a/lib/proc_eval/version.rb b/lib/proc_eval/version.rb new file mode 100644 index 0000000..81bbf8f --- /dev/null +++ b/lib/proc_eval/version.rb @@ -0,0 +1,3 @@ +module ProcEval + VERSION = '2.0.0' +end diff --git a/lib/proc_evaluate/version.rb b/lib/proc_evaluate/version.rb deleted file mode 100644 index 9b5f2eb..0000000 --- a/lib/proc_evaluate/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module ProcEvaluate - VERSION = '1.0.0' -end diff --git a/proc_evaluate.gemspec b/proc_eval.gemspec similarity index 82% rename from proc_evaluate.gemspec rename to proc_eval.gemspec index ff28af7..9758d9d 100644 --- a/proc_evaluate.gemspec +++ b/proc_eval.gemspec @@ -1,11 +1,11 @@ -require_relative 'lib/proc_evaluate/version.rb' +require_relative 'lib/proc_eval/version.rb' Gem::Specification.new do |spec| - spec.name = 'proc_evaluate' - spec.version = ProcEvaluate::VERSION + spec.name = 'proc_eval' + spec.version = ProcEval::VERSION spec.authors = ['Brent Jacobs', 'br3nt'] - spec.homepage = 'https://github.com/br3nt/proc_evaluate' - spec.required_ruby_version = '>= 2.0' + spec.homepage = 'https://github.com/reeganviljoen/proc_eval' + spec.required_ruby_version = '>= 2.7' spec.summary = 'Allow evaluation of variables, procs, and lambdas with the same level of flexibility.' spec.description = <<-DESC Adds an `evaulate` refinement method to Proc and Object instances. @@ -28,7 +28,7 @@ Gem::Specification.new do |spec| spec.licenses = ['MIT'] spec.files = [ - 'lib/proc_evaluate.rb', - 'lib/proc_evaluate/version.rb' + 'lib/proc_eval.rb', + 'lib/proc_eval/version.rb' ] end diff --git a/test/test_proc_evaluate.rb b/test/test_proc_eval.rb similarity index 90% rename from test/test_proc_evaluate.rb rename to test/test_proc_eval.rb index 490d948..6b27016 100644 --- a/test/test_proc_evaluate.rb +++ b/test/test_proc_eval.rb @@ -1,8 +1,8 @@ require 'minitest/autorun' -require 'proc_evaluate' +require 'proc_eval' -class ProcEvaluateClassTest < Minitest::Test - using ProcEvaluate +class ProcEvalClassTest < Minitest::Test + using ProcEval def test_example1 lambda = ->(a) { a } @@ -31,7 +31,7 @@ def test_example4 end module TestModule - using ProcEvaluate + using ProcEval extend self def example1 @@ -55,7 +55,7 @@ def example4 end end -class ProcEvaluateModuleTest < Minitest::Test +class ProcEvalModuleTest < Minitest::Test def test_example1 value = TestModule.example1 assert_equal value, 'hello' From e427ffae3187cd556cc01df69df9f9a62688b748 Mon Sep 17 00:00:00 2001 From: Reegan Viljoen Date: Fri, 1 Sep 2023 08:10:10 +0200 Subject: [PATCH 2/4] edit: add ci to pr's --- .github/workflowas/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflowas/ci.yml b/.github/workflowas/ci.yml index 3b450ff..0ea5c18 100644 --- a/.github/workflowas/ci.yml +++ b/.github/workflowas/ci.yml @@ -1,9 +1,6 @@ -name: Ruby +name: CI -on: - push: - branches: - - main +on: [push, pull_request] pull_request: From d41e74fd39561767e72ae304c53b1fe4946bab04 Mon Sep 17 00:00:00 2001 From: Reegan Viljoen Date: Fri, 1 Sep 2023 08:11:11 +0200 Subject: [PATCH 3/4] fix: ci folder spelling mistake --- .github/{workflowas => workflows}/ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflowas => workflows}/ci.yml (100%) diff --git a/.github/workflowas/ci.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflowas/ci.yml rename to .github/workflows/ci.yml From c12d1c6dcf9eb49ce26443fb8937c972f56e26c6 Mon Sep 17 00:00:00 2001 From: Reegan Viljoen Date: Fri, 1 Sep 2023 08:12:25 +0200 Subject: [PATCH 4/4] fix: syntax error in ci --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ea5c18..a8ef1ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,6 @@ name: CI on: [push, pull_request] - pull_request: - jobs: build: runs-on: ubuntu-latest