Долното е извадка от GNU GPL лиценза за отворен код:
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Долното е извадка от GNU GPL лиценза за отворен код:
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Ние, програмистите, не вярваме на собствения си код, та какво остава за чуждия такъв?
Така и трябва. Колкото по-малко зависимости от чужд (third-party) код – толкова по-добре.
Изобщо, колкото по-малко код, откъдето и да е дошъл – толкова по-добре. Но това е друга тема.
От друга страна, не може да си напишем всичко. Трябва да стъпим на нещо. И трябва да знаем как да изберем на какво.
Като изключим "помощни" gem-ове, най-популярният е Rails (с над 42 милиона изтегляния)
rubygems.org/gems/именабиблиотеката
→ линк "Source code" или "Homepage"
gem install gemname —platform=ruby
https://github.com/rails/rails/tree/master/activesupport
https://github.com/rails/rails/tree/master/activerecord
mysql2
, pg
, sqlite3
и т.н.
https://github.com/ruby/curses
https://github.com/capistrano/capistrano
Deploy WordPress with Capistrano!
https://github.com/bundler/bundler или http://bundler.io
Практически задължително за всеки проект, който има нужда от други gem-ове.
%
на String
е много удобен за интерполация и форматиране на определени низове
Kernel.sprintf
%
може да се ползва и без точка, като други методи, наподобяващи операториКогато имаме повече от една стойност за интерполация, трябва да подадем списък:
'%02d' % 7 # "07"
'%02d:%02d:%02d' % [19, 5, 2] # "19:05:02"
name = 'Пешо'
'Здравей, <strong>%s</strong>!' % name # "Здравей, <strong>Пешо</strong>!"
template = '
<html>
<head>
<title>%{title}</title>
</head>
<body>
%{content}
</body>
</html>
'
variables = {
title: 'String Interpolation',
content: 'Made easy by Kernel.sprintf.',
foobar: 'Extra keys are not an issue.'
}
template % variables # "\n <html>\n <head>\n <title>String Interpolation</title>\n </head>\n <body>\n Made easy by Kernel.sprintf.\n </body>\n </html>\n"