Comments (6)
I agree with you, that this is to avoid. Generally I use monkey patching in initial phases of development, because it nicely allows to get on the track (I like this on ruby). But apparently this project has reached next level, so it is time to refactor this out. I will look at refinements.
from rspreadsheet.
Closing this issue in release v0.2.14 - please have a look. I use refinements for newer versions of ruby (from 2.1, because the keyword "using" fails in ruby 2.0). I leave monkey patching for older ruby, for now, if you have better idea how to do it, let me know.
from rspreadsheet.
@gorn Thanks! I shall take a look at it on the weekend.
from rspreadsheet.
@gorn I saw usage of refinements, but do not understand where you fallback to monkey patching for Ruby versions which does not support them. So, I can not make reasonable opinion on it. But you can require different files based on ruby version or use forwarding to forward to the same methods from refinements and from monkey patching. That is as a workaround, but in general best approach would be to rewrite code to avoid need in monkey patching at all even with refinements it is still monkey patching...
from rspreadsheet.
I put all the "optional" code in https://github.com/gorn/rspreadsheet/blob/master/lib/helpers/class_extensions.rb ... I guess that it will fade away onece ruby 1.9 gois to oblivion.
I understand your point, but I think, that especially in case of LibXML::XML::Node it is more logical usage of ruby open classes than monkeypatching. The thing is, that on many places in code I work with LibXML::XML::Node objects returned by methods of LibXML::XML::Node class (like parent) and I can not imagine the decorator approach, which would enable to add my own methods, yet seemlesly get out of the way if someone else would like to reuse LibXML::XML::Node objects returned by my code. It would mean to dump decorator object and recreate everytime i pass such a thing like a parameter, which for is much uglier. However if you have any insigt at this I will be glad to hear it.
from rspreadsheet.
Nice article about decorators
https://robots.thoughtbot.com/evaluating-alternative-decorator-implementations-in
from rspreadsheet.
Related Issues (20)
- currency field HOT 2
- libxml-ruby dependency not identified by `gem install` on Alpine and Void Linux HOT 5
- FODS support HOT 7
- Setting background color get more cells colorized HOT 13
- Tests failing for ruby >= 2.4.6 HOT 1
- Cells table:covered-table-cell ignored.
- Repeated header rows (contained in table:table-header-rows) are ignored.
- method mispelled: Rspreadsheet::Row#lenght should be #length HOT 1
- Existing formulas do not calculate fields set by rspreadsheet HOT 9
- libxml gem not installed automatically on windows HOT 9
- Header rows are not respected HOT 1
- Rubyzip 1.3.0 and 2.0.0
- rewriting cell addresses in formulas when inserting rows / cells HOT 1
- Size does not ignore formatted cells without content HOT 9
- Randomly crash HOT 1
- Bundler doesn't detect libxml-ruby as a transitive dependency on macOS
- Can we open password protected file HOT 1
- Uncaught exception: cannot load such file -- libxml_ruby even if it's installed. HOT 2
- Problem writing cell with a drop-down list
- Unclear how to set cell number format for date etc.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspreadsheet.