lib/ronin/license.rb in ronin-0.3.0 vs lib/ronin/license.rb in ronin-1.0.0.pre1
- old
+ new
@@ -1,9 +1,9 @@
#
# Ronin - A Ruby platform for exploit development and security research.
#
-# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
+# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@@ -17,43 +17,40 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
require 'ronin/model'
+require 'ronin/model/has_unique_name'
-require 'dm-predefined'
+require 'dm-is-predefined'
module Ronin
+ #
+ # Represents a software license and pre-defines many other common ones
+ # ({bsd}, {cc_by}, {cc_by_sa}, {cc_by_nd}, {cc_by_nc}, {cc_by_nc_sa},
+ # {cc_by_nc_nd}, {cc0}, {gpl2}, {gpl3}, {lgpl3} and {mit}).
+ #
class License
include Model
- include DataMapper::Predefined
+ include Model::HasUniqueName
+ is :predefined
+
# Primary key
property :id, Serial
- # License name
- property :name, String
-
# Description of license
- property :description, Text
+ property :description, Text, :required => true
# URL of the License document
property :url, String
- # Validations
- validates_present :name, :description
- validates_is_unique :name
-
- #
- # Converts the license to a String.
- #
- # @return [String]
- # The name of the license.
- #
- def to_s
- self.name.to_s
- end
+ # Berkeley Software Distribution License
+ predefine :bsd,
+ :name => 'BSD',
+ :description => 'Berkeley Software Distribution License',
+ :url => 'http://www.opensource.org/licenses/bsd-license.php'
# Creative Commons By-Attribution License
predefine :cc_by,
:name => 'CC by',
:description => 'Creative Commons Attribution v3.0 License',