> def tt (x=123)
> puts x
> end
=> :tt
> tt
123
=> nil
> tt(456)
456
=> nil
The code above is the default argument I know.
But this one,
> def tt2 (x:123)
> puts x
1> end
=> :tt2
> tt2
123
=> nil
> tt2(456)
Traceback (most recent call last):
5: from /usr/bin/irb:23:in `<main>'
4: from /usr/bin/irb:23:in `load'
3: from /Library/Ruby/Gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
2: from (irb):10
1: from (irb):6:in `tt2'
ArgumentError (wrong number of arguments (given 1, expected 0))
As you see it fails.
But the following calling could work.
> tt2(x:456)
456
=> nil
> tt2(:x=>456)
456
=> nil
what's the trick behind it?
Thanks & regards,
Henry
for instance,
10.times do |s| puts s end
0
1
2
3
4
5
6
7
8
9
=> 10
is the arguments block run in async mode?
I have this question b/c my program quit earily. i don't know if it's due to somewhat async operations.
the code is like (connection to rabbitmq),
conn = Bunny.new
conn.start
ch = conn.create_channel
exchange = ch.fanout("myfanout",:durable => true)
100.times do |s|
exchange.publish(s.to_s)
end
It can't publish the entire 100 items to the broker, just some items.
Thanks.
minitest-server version 1.0.7 has been released!
* home: <https://github.com/seattlerb/minitest-server>
* rdoc: <http://docs.seattlerb.org/minitest-server>
minitest-server provides a client/server setup with your minitest
process, allowing your test run to send its results directly to a
handler.
Changes:
### 1.0.7 / 2022-12-17
* 1 minor enhancement:
* Bumped to minitest ~> 5.16 to get improved marshal handling.
rodauth-oauth 1.0.0 has been released.
rodauth-oauth is a rack-compatible toolkit for building OAuth 2.0
authorization servers, as well as OpenID Authentication Providers.
rodauth-oauth
is certified <https://openid.net/certification/> for the following profiles
of the OpenID Connect™ protocol:
Basic OP, Implicit OP, Hybrid OP, Config OP, Dynamic OP, Form Post OP.
# as simple as
rodauth do
enable :oauth_authorization_code_grant
# or
enable :oidc
end
Among its features, it supports:
* Authorization Code Grant
* Refresh Token Grant
* Implicit Grant
* Client Credentials Grant
* Device Code Grant
* Token Revocation
* Token Introspection
* Auth Server Metadata
* PKCE
* Resource Indicators
* JWT Access Tokens
* Assertion Framework
* SAML 2.0 Bearer Assertion Grant
* JWT Bearer Assertion Grant
* JWT Secured authorization requests
* Dynamic Client Registration
* OpenID
* OpenID Discovery
* OpenID Multiple Response types
* OpenID Connect Dynamic Client Registration
* OpenID Relying Party Initiated Logout
It can also be used with Rails (via the "rodauth-rails" gem).
Website: https://honeyryderchuck.gitlab.io/rodauth-oauth/
Documentation: https://honeyryderchuck.gitlab.io/rodauth-oauth/rdoc/
Wiki: https://gitlab.com/honeyryderchuck/rodauth-oauth/wikis/home
CI: https://gitlab.com/honeyryderchuck/rodauth-oauth/pipeline
These are the release notes since the last update:
## 1.0.0 (15/12/2022)
## Highlights
rodauth-oauth is now [OpenID
certified](https://openid.net/certification/) for the following
certification profiles:
* Basic OP
* Implicit OP
* Hybrid OP
* Config OP
* Dynamic OP
* Form Post OP
and passes the conformance tests for RP-Initiated Logout OP.
The OIDC server used to run the test can be found
[here](https://gitlab.com/os85/rodauth-oauth/-/blob/master/examples/oidc/aut…
and deployed [here](https://rodauth-oauth-oidc.onrender.com).
### Breaking changes
The full description of breaking changes, and suggestions on how to
make the migration smoother, can be found in the [migration
guide](https://gitlab.com/os85/rodauth-oauth/-/blob/6465b8522a78cf0037a55d3….
A short list of the main highlights:
* Ruby 2.5 or higher is required.
* `oauth_http_mac` feature removed.
* `oauth_tokens` table (and resource) were removed (only
`oauth_applications` and `oauth_grants`, access and refresh tokens are
now properties of the latter).
* access and refresh tokens hashed by default when stored in the database.
* default oauth response mode is `"form_post"`.
* oauth specific features require explicit enablement of respective
features (no more `enable :oauth`)
* refresh token policy is "rotation" by default
* homepage url is no longer a client application required property.
* OIDC RP-initiated logout extracted into `oidc_rp_initiated_logout` feature.
### Features
The following helpers are exposed in the `rodauth` object:
* `current_oauth_account` - returns the dataset row for the `rodauth`
account associated to an oauth access token in the "authorization"
header.
* `current_oauth_application` - returns the dataset row for the oauth
application associated to an oauth access token in the "authorization"
header.
When used in `rails` via `rodauth-rails`, both are exposed directly as
controller helpers.
#### `oauth_resource_server` plugin
This plugin can be used as a convenience when configuring resource servers.
#### JAR support for request_uri query param
The `oauth_jwt_secured_authorization_request` plugin now supports a
`request_uri` query param as well.
#### OIDC features
* The `oidc` plugin supports [essential
claims](https://openid.net/specs/openid-connect-core-1_0.html#ClaimsParamet…,
via the `claims` authorization request query parameter.
* id token built with `"c_hash"` and `"at_hash"` claims when they should.
### Improvements
* `:oauth_introspect` plugin: OAuth introspection endpoint exposes the
token's `"username"` claim.
* endpoint client authentication supports "client credentials grant"
access tokens.
* `acr_values_supported` exposed in the openid configuration.
* `oauth_request_object_signing_alg_allow_none` enables `"none"` as an
accepted request object signing alg when `true` (`false` by default).
* OIDC `offline_access` supported.
### Bugfixes
* fixed `oidc` calculation of `"auth_time"` claim.
* JWT: "sub" is now always a string.
* `response_type` is now an authorization request required parameter
(as per the RFC).
* `state` is now passed along when redirecting from authorization
requests with `error`;
* access token can now be read from POST body or GET query params (as
per the RFC).
* id token no longer shipping with claims with `null` value;
* id token no longer encoding claims by default (only when
`response_type=id_token`, as per the RFC).
* support "JWT without kid" when doing jwt decoding for JWT tokens not
generated in the provider (such as request objects).
* Set `iss` and `aud` claims in the Userinfo JWT response.
* Make sure errors are also delivered via form POST, when
`response_mode=form_post`.
* Authorization request now shows an error page when `response_type`
or `client_id` are missing, or `redirect_uri` is missing or invalid; a
new `"authorize_error"` template is invoked in such cases.
* oidc: nonce present in id token when using the "id_token token" response type.
* error parameter delivered in URL fragment when failing an implicit
grant autorization request.
Hi everyone! I'm writing a talk on how dispatch chains cause more cache
hits in the RubyVM using this great article by Matthew Alp:
https://mattalp.com/blog/dispatch-chains/.
However, I'm unable to find any benchmarks on how much speedup is gained.
Can someone please help me find any data on this my talk is tomorrow and
I'm kinda panicking now haha
Regards,
Faraaz
Hi
I have installed "bunny" (rabbitmq client) via gem.
but this package can't be loaded. please see follows.
$ sudo gem install bunny
Successfully installed bunny-2.19.0
Parsing documentation for bunny-2.19.0
Done installing documentation for bunny after 1 seconds
1 gem installed
$ irb
irb(main):001:0> require "bunny"
<internal:/snap/ruby/290/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- bunny (LoadError)
from <internal:/snap/ruby/290/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from (irb):1:in `<main>'
from /snap/ruby/290/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from /snap/ruby/290/bin/irb:25:in `load'
from /snap/ruby/290/bin/irb:25:in `<main>'
My ruby version is ruby 3.1.3p185.
Can you help? Thanks
Here's the task: I need to take an Excel spreadsheet from Sharepoint,
slice & dice it, and write the output into a database
Tools I have: Windows 10 laptop with WSL2 installed and I have admin
rights, so I can install whatever.
If I can't read from Sharepoint, then I can manually save a copy
locally. Automation would be nice
If I can't read the Excel spreadsheet, then I can manually open it and
write a csv
I can use what ever database I want that I can install, sqlite, mysql,
mariadb, postgresql or even MongoDB, so not a problem
I've done lots of slicing & dicing text files in a multitude of
languages, I just plan to use Ruby because it's my favorite
It's the first couple of steps that I would like to automate. Any
suggestions?
-- Matt