Sha256: b3469bb0177010d93951db005c66e7d2d35f3a61d0193b9b53f60e71514e4e00

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

#
# SCMs
#
# This example may look stupid (I am sure it is),
# but it is way better than foobars and easier to read/add cases
# compared to gardening examples because every software engineer has idea
# about SCMs and not every software engineer does gardening often.
#

class ScmOperation
  include DataMapper::Resource

  #
  # Property
  #

  property :id,                 Serial

  # operation name
  property :name,               String,  :auto_validation => false

  property :committer_name,     String,  :auto_validation => false, :default => "Just another Ruby hacker"
  property :author_name,        String,  :auto_validation => false, :default => "Just another Ruby hacker"
  property :network_connection, Boolean, :auto_validation => false
  property :message,            Text,    :auto_validation => false
  property :clean_working_copy, Boolean, :auto_validation => false

  #
  # Validations
  #

  validates_presence_of :name
end

class SubversionOperation < ScmOperation
  #
  # Validations
  #

  validates_presence_of :network_connection, :when => [:committing, :log_viewing]
end

class GitOperation < ScmOperation
  #
  # Validations
  #

  validates_presence_of :author_name, :committer_name, :when => :committing

  validates_presence_of :message,            :when => :committing
  validates_presence_of :network_connection, :when => [:pushing, :pulling], :message => {
    :pushing => "though git is advanced, it cannot push without network connectivity",
    :pulling => "you must have network connectivity to pull from others"
  }
  validates_presence_of :clean_working_copy, :when => :pulling
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
sbf-dm-validations-1.4.0 spec/fixtures/scm_operation.rb
sbf-dm-validations-1.3.0 spec/fixtures/scm_operation.rb
sbf-dm-validations-1.3.0.beta spec/fixtures/scm_operation.rb
ardm-validations-1.2.0 spec/fixtures/scm_operation.rb
aequitas-0.0.1 spec_legacy/fixtures/scm_operation.rb
dm-validations-1.2.0 spec/fixtures/scm_operation.rb
dm-validations-1.2.0.rc2 spec/fixtures/scm_operation.rb
dm-validations-1.2.0.rc1 spec/fixtures/scm_operation.rb
dm-validations-1.1.0 spec/fixtures/scm_operation.rb
dm-validations-1.1.0.rc3 spec/fixtures/scm_operation.rb
dm-validations-1.1.0.rc2 spec/fixtures/scm_operation.rb
dm-validations-1.1.0.rc1 spec/fixtures/scm_operation.rb
dm-validations-1.0.2 spec/fixtures/scm_operation.rb
dm-validations-1.0.1 spec/fixtures/scm_operation.rb
dm-validations-1.0.0 spec/fixtures/scm_operation.rb
dm-validations-1.0.0.rc3 spec/fixtures/scm_operation.rb
dm-validations-1.0.0.rc2 spec/fixtures/scm_operation.rb
dm-validations-1.0.0.rc1 spec/fixtures/scm_operation.rb