Commit graph

111 commits

Author SHA1 Message Date
Marc-Andre Lafortune
f0818982e9 [ruby/ostruct] v0.4.0
8534f69e4e
2021-06-15 12:04:05 +09:00
Marc-Andre Lafortune
52369fc545 [lib/ostruct] Allow overriding of block_given? 2021-06-14 12:28:53 -04:00
Nobuyoshi Nakada
5dde13e5ce [ruby/ostruct] bump up
bb253be3e9
2021-06-14 23:31:49 +09:00
jfrazx
931ea7cfbe
Add fallback block to OpenStruct#delete_field (#1409) 2021-06-14 09:53:20 -04:00
Marc-Andre Lafortune
7f1323c3bd
[ruby/ostruct] Add compatibility for to_h with block in Ruby 2.5
da45de5068
2021-04-28 17:48:05 +09:00
Marc-Andre Lafortune
37b445eaeb [ruby/ostruct] Compatibility with Ruby 2.5
ecd9fafdf8
2021-04-28 17:33:59 +09:00
Marc-Andre Lafortune
30a35420e6 [ruby/ostruct] Bump version 2021-01-13 01:09:29 -05:00
Marc-Andre Lafortune
f48edc28dd Fix method protection for modules in the ancestry chain.
[Fixes ruby/ostruct#23]
2021-01-12 23:29:39 -05:00
Marc-Andre Lafortune
a0a6293e78 [ruby/ostruct] Bump version 2021-01-05 18:35:56 -05:00
Adam Hess
e13f41e02d
[ruby/ostruct] Allow ostruct to return a value on super (#4028)
This fixes cases where you can super in something that inherits from OpenStruct

Co-authored-by: John Hawthorn <john@hawthorn.email>
2021-01-05 18:34:45 -05:00
Marc-Andre Lafortune
2aa9a50dcc [ruby/ostruct] Update version 2020-11-04 17:52:03 -05:00
Marc-Andre Lafortune
015b023820 [ruby/ostruct] Restore ostruct doc 2020-11-04 17:52:03 -05:00
Marc-Andre Lafortune
6f24be8565 Revert "Make marshal_load public"
This reverts commit ee7cc6ac35.

I'm not sure I agree with the spec, but I just tweaked it.
2020-11-04 17:52:03 -05:00
Nobuyoshi Nakada
3198e7abd7
Separate send into public_send and __send__ 2020-10-27 16:12:45 +09:00
Aaron Patterson
ee7cc6ac35
Make marshal_load public
Ruby specs expected this method to be public
2020-10-06 15:13:49 -07:00
Marc-Andre Lafortune
1486785a57 [lib/ostruct] Fix Marshal loading 2020-10-06 17:11:08 -04:00
Marc-Andre Lafortune
bb2ba72c3b [ruby/ostruct] Tweak doc 2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
152ba86b6b [ruby/ostruct] Remove unused condition 2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
b36a45c05c [ruby/ostruct] Improved YAML serialization.
Patch adapted from Pietro Monteiro [Fixes bug#8382]
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
0977040133 [ruby/ostruct] Add test that frozen OpenStructs are Ractor-shareable 2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
083fa6e5d2 [ruby/ostruct] Protect subclass' methods and our bang methods.
Internally, use only bang methods
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
df4d08c44a [ruby/ostruct] Avoid calling initialize 2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
60f5d38482 [ruby/ostruct] Fix dup/clone 2020-09-14 16:10:37 -04:00
Marc-Andre Lafortune
125605abd9 [ruby/ostruct] method_missing is private 2020-09-14 16:10:37 -04:00
Marc-Andre Lafortune
606c009ce2 [ruby/ostruct] Avoid self calling our public methods.
Found because `json` has a bad example in its test suite.
This implementation still offers better encapsulation.
2020-09-14 16:10:37 -04:00
Marc-Andre Lafortune
67e5f7a9e5 [ruby/ostruct] Reinstate recent changes
This reverts commit 28e60b0045.
2020-09-14 16:10:37 -04:00
Marc-Andre Lafortune
28e60b0045 [ruby/ostruct] Revert recent changes
This reverts commit e026e186f4..12a2e32d43.
2020-09-14 13:29:54 -04:00
Marc-Andre Lafortune
12a2e32d43 [ruby/ostruct] Add access to public instance methods in case they are overriden 2020-09-14 12:46:51 -04:00
Marc-Andre Lafortune
12a13eef49 [ruby/ostruct] Tweak doc 2020-09-14 12:46:49 -04:00
Marc-Andre Lafortune
8eefa8f373 [ruby/ostruct] Allow overriding public methods
[Fixes https://bugs.ruby-lang.org/issues/15409]
2020-09-14 12:46:47 -04:00
Marc-Andre Lafortune
ebb8de7302 [ruby/ostruct] Refactor handling of frozen OpenStruct. Simplify new_ostruct_member! 2020-09-14 12:46:45 -04:00
Marc-Andre Lafortune
e026e186f4 [ruby/ostruct] Revert "ostruct.rb: deferred accessors"
This reverts commits:
dc38e99813
22c082fcfd
b499e0f9ff
58e5876646

Add test for overriden private methods

[Fixes https://bugs.ruby-lang.org/issues/12136]
2020-09-14 12:46:27 -04:00
Marc-Andre Lafortune
fbaab562d9 lib/ostruct.rb: Revert "To use RuntimeError instead of FrozenError for old ruby versions."
This reverts commit 4cd1fc8b3559353069860eee90b1b5bade013917.
2020-09-04 01:23:14 -04:00
Burdette Lamar
c84ccf1a07
Fix links to Dig Methods document (#3421)
* Fix links to Dig Methods document

* Fix links to Dig Methods document
2020-08-14 18:55:04 -05:00
Burdette Lamar
22fd617aa5
Adding doc/dig_methods.rdoc and links to it (#3416)
Adds a full discussion of #dig, along with links from Array, Hash, Struct, and OpenStruct.

CSV::Table and CSV::Row are over in ruby/csv. I'll get to them soon.

The art to the thing is to figure out how much (or how little) to say at each #dig.
2020-08-13 13:16:27 -05:00
Nobuyoshi Nakada
b2d96abb42 Extract version number from the source
"requiring version.rb" strategy has some issues.

- cannot work when cross-compiling
- often introduces wrong namespace
- must know the superclasses
- costs at each runtime than at build-time

etc.
2020-07-30 19:03:18 +09:00
zverok
54fd50c951 Fix OpenStructDocumentation
In 9be3295d53,
OpenStruct's documentation stopped to be rendered by RDoc
(there should be no additional code between documentation
comment and documented class). Fixing this.
2020-01-05 14:35:14 +09:00
Marc-Andre Lafortune
9be3295d53 [ruby/ostruct] Create OpenStruct::VERSION 2019-12-22 21:48:54 -05:00
Nobuyoshi Nakada
dbcc224f38
Removed old names of internal methods 2019-05-10 14:13:17 +09:00
Nobuyoshi Nakada
a7b68e63c5
Suppress a warning in Psych&YAML with verbose mode 2019-05-10 14:12:51 +09:00
marcandre
816c5323fe OpenStruct: improve error message when passing wrong number of arguments.
Patch by Lisa Ugray (issue #15515)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-14 13:47:24 +00:00
marcandre
1e30df6f77 ostruct.rb: Accept block for to_h [#15451].
Patch by Shuji Kobayashi.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 17:05:03 +00:00
hsbt
1380aa04a6 Support old versions of Ruby with FrozenError.
They should work separatedly from Ruby core repository.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07 12:47:11 +00:00
marcandre
5219adf4f1 lib/ostruct: Remove unnecessary __send__
Patch by yuuji.yaginuma [Fix GH-1890]

Since `remove_method` is public.
Ref: https://bugs.ruby-lang.org/issues/14133

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-26 18:46:10 +00:00
marcandre
b16eaf8632 lib/ostruct.rb: Use FrozenError instead of RuntimeError.
Patch by Yuuji Yaginuma. [Fixes GH-1808]

In other classes, `FrozenError` will be raised if change the frozen
object.
In order to match the behavior, I think that `FrozenError` should
use in `OpenStruct`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 23:52:30 +00:00
shyouhei
f2a91397fd Add uplevel keyword to Kernel#warn and use it
If uplevel keyword is given, the warning message is prepended
with caller file and line information and the string "warning: ".
The use of the uplevel keyword makes Kernel#warn format output
similar to how rb_warn formats output.

This patch modifies net/ftp and net/imap to use Kernel#warn
instead of $stderr.puts or $stderr.printf, since they are used
for printing warnings.

This makes lib/cgi/core and tempfile use $stderr.puts instead of
warn for debug logging, since they are used for debug printing
and not for warning.

This does not modify bundler, rubygems, or rdoc, as those are
maintained outside of ruby and probably wish to remain backwards
compatible with older ruby versions.

rb_warn_m code is originally from nobu, but I've changed it
so that it only includes the path and lineno from uplevel
(not the method), and also prepends the string "warning: ",
to make it more similar to rb_warn.

From: Jeremy Evans code@jeremyevans.net
Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:56:25 +00:00
marcandre
e565c838ce lib/ostruct.rb: Use frozen literals.
Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 18:08:15 +00:00
eregon
a6456054ae ostruct.rb: improve fix for OpenStruct.allocate + #respond_to?
* lib/ostruct.rb (OpenStruct#respond_to_missing?): this makes
  OpenStruct#respond_to? works on any OpenStruct instance,
  just like Kernel#respond_to? does, without workarounds.
  [ruby-core:80292] [Bug #13358]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-01 10:30:48 +00:00
nobu
a20715c8ed ostruct.rb: refine visibility failure message
* lib/ostruct.rb (method_missing): raise an exception with proper
  visibility message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-28 09:21:58 +00:00
nobu
cd911b9367 ostruct.rb: fix OpenStruct.allocate
* lib/ostruct.rb (OpenStruct.allocate): initialize an instance
  variable directly, without calling `intialize` method which may
  be overridden in a subclass.  [ruby-core:80292] [Bug #13358]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-24 12:16:54 +00:00