Skip to content

Commit

Permalink
Merge pull request #8 from SINTEF-9012/ci
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
fungiboletus authored Jan 24, 2024
2 parents f267afd + c81c8fd commit 6747c2a
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 15 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish Gem

on:
release:
types: [created]

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true

- name: Run tests
run: bundle exec rake

- name: Build gem
run: gem build -V rodash.gemspec

- name: Push gem to RubyGems
run: gem push rodash-*.gem
env:
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
25 changes: 25 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Ruby tests

on:
push: {}
pull_request: {}

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "head"]
steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1

with:
ruby-version: ${{ matrix.ruby }}
bundler: latest
bundler-cache: true

- name: Run tests
run: bundle exec rake
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*

# Apple's crap
.DS_Store
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

group :development, :test do
gem 'shoulda', '~> 4.0'
gem 'rake', '~> 13.1'
end
44 changes: 44 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
base64 (0.2.0)
bigdecimal (3.1.6)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
drb (2.2.0)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
minitest (5.21.2)
mutex_m (0.2.0)
rake (13.1.0)
ruby2_keywords (0.0.5)
shoulda (4.0.0)
shoulda-context (~> 2.0)
shoulda-matchers (~> 4.0)
shoulda-context (2.0.0)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

PLATFORMS
aarch64-linux
ruby

DEPENDENCIES
rake (~> 13.1)
shoulda (~> 4.0)

BUNDLED WITH
2.5.3
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/test_*.rb']
t.verbose = true
end

task default: :test
4 changes: 2 additions & 2 deletions rodash.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'rodash'
s.version = '3.0.0'
s.date = '2017-03-10'
s.version = '4.0.0'
s.date = '2024-01-24'
s.summary = "Rodash"
s.description = "_.set, _.get, and _.unset for Ruby"
s.authors = ["Antoine Pultier"]
Expand Down
25 changes: 12 additions & 13 deletions test/test_rodash.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'test/unit'
require 'minitest/autorun'
require 'shoulda'

require_relative '../lib/rodash'

class SetTest < Test::Unit::TestCase
class SetTest < Minitest::Test

should "set property values" do
object = {'a' => 1}
Expand Down Expand Up @@ -104,8 +104,8 @@ class SetTest < Test::Unit::TestCase
end

should "not error when object is nullish" do
assert_equal Rodash.set(nil, 'a.b', 1), nil
assert_equal Rodash.set(nil, ['a','b'], 1), nil
assert_nil Rodash.set(nil, 'a.b', 1)
assert_nil Rodash.set(nil, ['a','b'], 1)
end

should "not create an array for missing non-index property names that start with numbers" do
Expand All @@ -116,7 +116,7 @@ class SetTest < Test::Unit::TestCase

end

class GetTest < Test::Unit::TestCase
class GetTest < Minitest::Test

should "get property values" do
object = {'a' => 1}
Expand Down Expand Up @@ -159,9 +159,8 @@ class GetTest < Test::Unit::TestCase
end

should "handle empty paths" do
[['', ''], [[], ['']]].each_with_index do |pair,index|
object = {}
assert_equal Rodash.get({}, pair[0]), nil
[['', ''], [[], ['']]].each do |pair|
assert_nil Rodash.get({}, pair[0])
assert_equal Rodash.get({'' => 3}, pair[1]), 3
end
end
Expand All @@ -185,26 +184,26 @@ class GetTest < Test::Unit::TestCase
object = { 'a' => [nil, nil] }

['a[1].b.c', ['a', '1', 'b', 'c']].each do |path|
assert_equal Rodash.get(object, path), nil
assert_nil Rodash.get(object, path)
end
end

should "be able to return nil values" do
object = { 'a' => { 'b' => nil }}
assert_equal Rodash.get(object, 'a.b'), nil
assert_equal Rodash.get(object, ['a', 'b']), nil
assert_nil Rodash.get(object, 'a.b')
assert_nil Rodash.get(object, ['a', 'b'])
end

should "return the default value for nil values" do
object = { 'a' => { 'b' => nil }}
assert_equal Rodash.get(object, 'a.b', true), true
assert_equal Rodash.get(object, ['a', 'b'], 898), 898
assert_equal Rodash.get(object, ['a', 'b'], nil), nil
assert_nil Rodash.get(object, ['a', 'b'], nil)
end

end

class UnsetTest < Test::Unit::TestCase
class UnsetTest < Minitest::Test

should "unset property values" do
['a', ['a']].each do |path|
Expand Down

0 comments on commit 6747c2a

Please sign in to comment.