mbj / anima Goto Github PK
View Code? Open in Web Editor NEWObject initializer from attributes hash
Object initializer from attributes hash
require 'anima'
Anima::VERSION # => "0.4.2"
class Dog
include Anima.new(:name, :age, :breed)
private :breed
end
spot = Dog.new(name: 'Spot', age: 5, breed: 'Dalmatian')
spot # => #<Dog name="Spot" age=5 breed="Dalmatian">
spot.with(age: 6) # => private method `breed' called for #<Dog name="Spot" age=5 breed="Dalmatian"> (NoMethodError)
spot.to_h # => private method `breed' called for #<Dog name="Spot" age=5 breed="Dalmatian"> (NoMethodError)
I'm updating some of codebase which uses anima to the latest release and I noticed the docs say Anima::InstanceMethods#with
is part of the private API. Is this correct?
Currently anima's initialization error reports are weak.
IMHO anima should report a "full" key-state report if ANY error condition is found. Generating the full report will result in more computation but efficiency on the error code path is not a primary objective.
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
I think it would be a good practice to allow default values to attributes. Something like:
require 'anima'
# Definition
class Person
include Anima.new(name: '', age: 0)
end
a = Person.new(age: 30)
# => #<Person name="" age=30>
I do not think this library is missing anything. I'm at all for releasing an 1.0
version. Feel free to add your comment here to discuss.
EDIT: I think #3 should be solved before releasing v1.0.
Recently, I've found myself doing private(*anima.attributes.map(&:name))
quite often. Usually from within anima infected builder objects.
you don't need much, just enough to make people understand what your code is about
hi there,
We are working on ataru, a documentation testing tool and have tested the anima documentation with it. Ataru found mistake in line 76:
1) Failure:
#<Class:0x00000002c64998>#test_README_0 [README.md:76]:
--- expected
+++ actual
@@ -1 +1 @@
-{:salutation=>"Mrs", :firstname=>"Sue"}
+{:salutation=>"Mrs", :firstname=>"Sue", :lastname=>"Doe"}
hope that's helpfull.
Hello there!
My name is Ana. I noted that you use the mutation testing tool mutant in the project.
I am a postdoctoral researcher at the University of Seville (Spain), and my colleagues and I are studying how mutation testing tools are used in practice. With this aim in mind, we have analysed over 3,500 public GitHub repositories using mutation testing tools, including yours! This work has recently been published in a journal paper available at https://link.springer.com/content/pdf/10.1007/s10664-022-10177-8.pdf.
To complete this study, we are asking for your help to understand better how mutation testing is used in practice, please! We would be extremely grateful if you could contribute to this study by answering a brief survey of 21 simple questions (no more than 6 minutes). This is the link to the questionnaire https://forms.gle/FvXNrimWAsJYC1zB9.
Drop me an e-mail if you have any questions or comments ([email protected]). Thank you very much in advance!!
Installed Anima 0.2.0 on Ruby 2.1.0 and the first time my project used executed Anima.new(:foo)
, Ruby explodes at the C level. I've posted the stack trace at https://gist.github.com/ravinggenius/9921559.
What do you think about support for optional (with defaults) attributes?
Something like:
class Person
include Anima.new(:salutation, :firstname, :lastname, age: 18)
end
person = Person.new(salutation: 'Mr', firstname: 'James')
person.lastname # nil
person.age # 18
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.