Skip to content

Commit

Permalink
Merge pull request #3 from reeganviljoen/rv-release-2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
reeganviljoen authored Sep 1, 2023
2 parents ba63f19 + 12c9f34 commit a3897a3
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 37 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on: [push, 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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.0.5
ruby 3.2.0
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
proc_evaluate (1.0.0)
proc_eval (2.0.0)

GEM
remote: https://rubygems.org/
Expand All @@ -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
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ProcEvaluate
# ProcEval

This ruby gem adds an `evaulate` method to Proc and Object instances through the use of [Refinements][1].

Expand Down Expand Up @@ -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 }
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'bundler/gem_tasks'
require 'rake/testtask'

Rake::TestTask.new do |t|
Expand Down
4 changes: 2 additions & 2 deletions lib/proc_evaluate.rb → lib/proc_eval.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ProcEvaluate
module ProcEval

refine Object do
def evaluate(*args, **options)
Expand Down Expand Up @@ -59,4 +59,4 @@ def evaluate(*args, **options)
end # refine Proc
end

require 'proc_evaluate/version'
require 'proc_eval/version'
3 changes: 3 additions & 0 deletions lib/proc_eval/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ProcEval
VERSION = '2.0.0'
end
3 changes: 0 additions & 3 deletions lib/proc_evaluate/version.rb

This file was deleted.

16 changes: 8 additions & 8 deletions proc_evaluate.gemspec → proc_eval.gemspec
Original file line number Diff line number Diff line change
@@ -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.authors = ['Brent Jacobs', 'br3nt']
spec.homepage = 'https://github.com/br3nt/proc_evaluate'
spec.required_ruby_version = '>= 2.0'
spec.name = 'proc_eval'
spec.version = ProcEval::VERSION
spec.authors = ['Brent Jacobs', 'br3nt', 'reeganviljoen']
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.
Expand All @@ -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
10 changes: 5 additions & 5 deletions test/test_proc_evaluate.rb → test/test_proc_eval.rb
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down Expand Up @@ -31,7 +31,7 @@ def test_example4
end

module TestModule
using ProcEvaluate
using ProcEval
extend self

def example1
Expand All @@ -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'
Expand Down

0 comments on commit a3897a3

Please sign in to comment.