Skip to content

Commit

Permalink
acu128253 remove YARD groups; simplecov takes care of this
Browse files Browse the repository at this point in the history
Also deleted some commented-out code.
  • Loading branch information
Magne Land committed Sep 30, 2013
1 parent 9060bb0 commit b1bfe0c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 131 deletions.
33 changes: 11 additions & 22 deletions lib/attributor/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ class Attribute

attr_reader :type

# @!group Tested
# @options: metadata about the attribute
# @block: code definition for struct attributes (nil for predefined types or leaf/simple types)
def initialize(type, options={}, &block)
@type = Attributor.resolve_type(type, options, block)

@options = options
@saved_block = block
# @inherit_from = @options.delete(:inherit_from) # AttributeType object to inherit options/subdefinitions from

check_options!
end


def parse(value)
Expand Down Expand Up @@ -184,11 +194,6 @@ def validate_dependency(context)
end


# @endgroup


# @!group Half-Tested

def check_options!
self.options.each do |option_name, option_value|
if self.check_option!(option_name, option_value) == :unknown
Expand Down Expand Up @@ -227,21 +232,5 @@ def check_option!(name, definition)
:ok # passes
end


# @endgroup

# @options: metadata about the attribute
# @block: code definition for struct attributes (nil for predefined types or leaf/simple types)
def initialize(type, options={}, &block)
@type = Attributor.resolve_type(type, options, block)

@options = options
@saved_block = block
# @inherit_from = @options.delete(:inherit_from) # AttributeType object to inherit options/subdefinitions from

check_options!
end


end
end
106 changes: 0 additions & 106 deletions lib/attributor/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def self.included( klass )

module ClassMethods

# @!group Tested

# Generic decoding and coercion of the attribute.
def load(value)
unless value.is_a?(self.native_type)
Expand All @@ -54,18 +52,6 @@ def validate(value,context,attribute)
end


# @endgroup

# ===================================
# Untested Stuff
# ===================================


########
# @!group Public interface to an Attributor "Type" class



# Default, overridable example function
def example(options=nil, context=nil)
raise "#{self} must implement #example"
Expand All @@ -78,98 +64,6 @@ def example(options=nil, context=nil)
# return nil
end

# @!endgroup

# attr_reader :inherit_from


# def supported_options_for_type
# return []
# raise "Type subclasses need to override this and return an array of option names that they support (that fall within the common ones). Otherwise they can fully override validate_options for custom option validation"
# end

# Native type for the attribute (based on the derived class' native type)
# def native_type
# self.class.native_type
# end

# def compile_dsl( block, options )
# end

# By default, there's no substructure (unless overriden) ... so no decoding needed, and no errors checking dependencies
# def decode_substructure( decoded_value , context )
# return [ decoded_value, [] ]
# end
# def check_dependencies_substructure(myself,root,attribute)
# []
# end

# def check_dependencies(myself, root, attribute)
# errors = []
# # Checks any conditional dependencies of this attribute (against the root object) and returns an array of errors
# # Checks the dependencies for this attribute itself
# if attribute.options.include? :required_if
# errors = errors + check_dependency( attribute.options[:required_if], myself, root )
# end

# # Checks any dependencies for the sub attributes
# errors = errors + check_dependencies_substructure(myself,root,attribute) unless attribute.type < Attributor::Struct #TODO: Change this to check if it has a "sub-structure" type module ...
# return errors
# end

# # checks a single dependency condition based on a loaded attribute
# def check_dependency( condition_spec, value, root )
# return [] if value
# errors = []
# case condition_spec
# when ::String
# dependent_value = fetch_related_value(condition_spec,root)
# errors << "value for #{name} required when #{condition_spec} is defined" unless dependent_value.nil?
# when ::Hash
# raise "not more than 1 condition supported right now (got: #{condition_spec.inspect})" if condition_spec.keys.size > 1
# dependent_attribute = condition_spec.keys.first
# target_value = condition_spec[dependent_attribute]
# case target_value
# when ::String
# # 'some.name' => 'some_value'
# dependent_value = fetch_related_value(dependent_attribute,root)
# errors << "value for #{name} required since #{dependent_attribute}=#{target_value}" if !dependent_value.nil? && dependent_value == target_value

# when ::Regexp
# # 'some.name' => /regexp/
# dependent_value = fetch_related_value(dependent_attribute,root)
# errors << "value for #{name} required since #{dependent_attribute} matches #{target_value.inspect}" if !dependent_value.nil? && dependent_value =~ target_value
# when ::Proc
# # 'some.name' => Proc.new{|value| return true or false}
# dependent_value = fetch_related_value(dependent_attribute,root)
# errors << "value for #{name} required since the defined Proc condition returns true when passing the dependent value: #{dependent_value}" if !dependent_value.nil? && target_value.call(dependent_value) == true
# else
# raise "this type of target condition for a Hash dependency is not supported"
# end
# errors
# else
# raise "This type of condition definition is not currenty supported"
# end
# return errors
# end


# def fetch_related_value( dotted_name, root )
# segments = dotted_name.split(SEPARATOR)
# segments.inject(root){|base,segment| (base == nil ? nil : base[segment] ) }
# end



# By default the object value coming in, is already loaded correctly.
# i.e., for simple types in JSON payload, or for simple strings in the URL params.
# Attribute types that are more complex, might want to get the incoming value and decode it into the proper object before processing
# TODO: Need to build error handling/reporting with this function...should return error msg
#def load( value, context , attribute)
# [ value, [] ]
#end



# HELPER FUNCTIONS

Expand Down
3 changes: 0 additions & 3 deletions lib/attributor/types/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def method_missing(name, *args)

module ClassMethods

# @!group Tested

def example(options={}, context=nil)
result = self.new
Expand Down Expand Up @@ -78,8 +77,6 @@ def check_option!(name, value)
end


# @endgroup

# Model-specific decoding and coercion of the attribute.
def load(value)
return value if value.nil?
Expand Down

1 comment on commit b1bfe0c

@flexera-ci
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RS-COMPLIANCE: COMPLIANCE-COMMITMESSAGE-PASS Build: #45754(2013-09-30_20-05-31), repo: attributor, branch/tag: salmon_13_14_acu128253_add_code_coverage, sha: b1bfe0c, status: PASS, reason: Looks like this commit is associated with a valid AcunoteId. (https://rightscale.acunote.com/projects/2091/tasks/128253)

Please sign in to comment.