Skip to content

Commit

Permalink
Adjusts the indentation of several project classes
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-wellington-santos committed Oct 10, 2017
1 parent 93bbb31 commit d7e5ce9
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 89 deletions.
8 changes: 1 addition & 7 deletions lib/yard/code_objects/cucumber/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module YARD::CodeObjects::Cucumber

module LocationHelper
Expand All @@ -14,19 +13,14 @@ def file
def location
"#{file}:#{line_number}"
end

end

class Base < YARD::CodeObjects::Base
include LocationHelper

def path
@value || super
end

end



end

10 changes: 3 additions & 7 deletions lib/yard/code_objects/cucumber/feature.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@


module YARD::CodeObjects::Cucumber

class Feature < NamespaceObject

attr_accessor :background, :comments, :description, :keyword, :scenarios, :tags, :value

def initialize(namespace,name)
def initialize(namespace, name)
@comments = ""
@scenarios = []
@tags = []
super(namespace,name.to_s.strip)
super(namespace, name.to_s.strip)
end

end

end
43 changes: 25 additions & 18 deletions lib/yard/code_objects/cucumber/namespace_object.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@

module YARD::CodeObjects::Cucumber

class NamespaceObject < YARD::CodeObjects::NamespaceObject
include LocationHelper
def value ; nil ; end

def value;
nil;
end
end

class Requirements < NamespaceObject ; end
class FeatureTags < NamespaceObject ; end
class StepTransformersObject < NamespaceObject ; end
class Requirements < NamespaceObject;
end
class FeatureTags < NamespaceObject;
end
class StepTransformersObject < NamespaceObject;
end

class FeatureDirectory < YARD::CodeObjects::NamespaceObject

attr_accessor :description

def initialize(namespace,name)
super(namespace,name)
def initialize(namespace, name)
super(namespace, name)
@description = ""
end

Expand All @@ -27,23 +32,25 @@ def expanded_path
to_s.split('::')[1..-1].join('/')
end

def value ; name ; end

def value;
name;
end

def features
children.find_all {|d| d.is_a?(Feature) }
children.find_all { |d| d.is_a?(Feature) }
end

def subdirectories
subdirectories = children.find_all {|d| d.is_a?(FeatureDirectory) }
subdirectories + subdirectories.collect {|s| s.subdirectories }.flatten
subdirectories = children.find_all { |d| d.is_a?(FeatureDirectory) }
subdirectories + subdirectories.collect { |s| s.subdirectories }.flatten
end

end

CUCUMBER_NAMESPACE = Requirements.new(:root, "requirements") unless defined?(CUCUMBER_NAMESPACE)

CUCUMBER_TAG_NAMESPACE = FeatureTags.new(CUCUMBER_NAMESPACE, "tags") unless defined?(CUCUMBER_TAG_NAMESPACE)

CUCUMBER_STEPTRANSFORM_NAMESPACE = StepTransformersObject.new(CUCUMBER_NAMESPACE, "step_transformers") unless defined?(CUCUMBER_STEPTRANSFORM_NAMESPACE)

end
16 changes: 6 additions & 10 deletions lib/yard/code_objects/cucumber/scenario.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@


module YARD::CodeObjects::Cucumber

class Scenario < NamespaceObject

attr_accessor :value, :comments, :keyword, :description, :steps, :tags, :feature
def initialize(namespace,name)
super(namespace,name.to_s.strip)

def initialize(namespace, name)
super(namespace, name.to_s.strip)
@comments = @description = @keyword = @value = @feature = nil
@steps = []
@tags = []
end

def background?
@keyword == "Background"
end

def outline?
false
end

end

end
37 changes: 16 additions & 21 deletions lib/yard/code_objects/cucumber/scenario_outline.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@


module YARD::CodeObjects::Cucumber

class ScenarioOutline < NamespaceObject

attr_accessor :value, :comments, :keyword, :description, :steps, :tags, :feature
attr_accessor :scenarios, :examples

def initialize(namespace,name)
super(namespace,name.to_s.strip)
def initialize(namespace, name)
super(namespace, name.to_s.strip)
@comments = @description = @value = @feature = nil
@steps = []
@tags = []
Expand All @@ -23,53 +21,50 @@ def background?
def outline?
true
end

def examples?
@examples.find {|example| example.rows }
@examples.find { |example| example.rows }
end


class Examples

attr_accessor :name, :line, :keyword, :comments, :rows

# The first row of the rows contains the headers for the table
def headers
rows.first
end

# The data of the table starts at the second row. When there is no data then
# return a empty string.
def data
rows ? rows[1..-1] : ""
end

def values_for_row(row)
hash = {}

headers.each_with_index do |header,index|
headers.each_with_index do |header, index|
hash[header] = data[row][index]
end

hash
end

def to_hash
hash = {}

rows.each_with_index do |header,index|
hash[header] = rows.collect {|row| row[index] }
rows.each_with_index do |header, index|
hash[header] = rows.collect { |row| row[index] }
end

hash
end

def initialize(parameters = {})
parameters.each {|key,value| send("#{key.to_sym}=",value) if respond_to? "#{key.to_sym}=" }
parameters.each { |key, value| send("#{key.to_sym}=", value) if respond_to? "#{key.to_sym}=" }
end

end

end

end
20 changes: 12 additions & 8 deletions lib/yard/code_objects/cucumber/step.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@


module YARD::CodeObjects::Cucumber

class Step < Base

attr_accessor :comments, :definition, :examples, :keyword, :scenario, :table, :text, :transforms, :value

def initialize(namespace,name)
super(namespace,name.to_s.strip)
attr_accessor :comments,
:definition,
:examples,
:keyword,
:scenario,
:table,
:text,
:transforms,
:value

def initialize(namespace, name)
super(namespace, name.to_s.strip)
@comments = @definition = @description = @keyword = @table = @text = @value = nil
@examples = {}
@transforms = []
Expand All @@ -32,7 +38,5 @@ def definition=(stepdef)
def transformed?
!@transforms.empty?
end

end

end
18 changes: 7 additions & 11 deletions lib/yard/code_objects/cucumber/tag.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@


module YARD::CodeObjects::Cucumber

class Tag < NamespaceObject

attr_accessor :value, :owners

def features
@owners.find_all{|owner| owner.is_a?(Feature) }
@owners.find_all { |owner| owner.is_a?(Feature) }
end

def scenarios
@owners.find_all{|owner| owner.is_a?(Scenario) || owner.is_a?(ScenarioOutline) }
@owners.find_all { |owner| owner.is_a?(Scenario) || owner.is_a?(ScenarioOutline) }
end

def indirect_scenarios
@owners.find_all{|owner| owner.is_a?(Feature) }.collect {|feature| feature.scenarios }.flatten
@owners.find_all { |owner| owner.is_a?(Feature) }.collect { |feature| feature.scenarios }.flatten
end

def all_scenarios
scenarios + indirect_scenarios
end

end

end
5 changes: 2 additions & 3 deletions lib/yard/code_objects/step_definition.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@


module YARD::CodeObjects

class StepDefinitionObject < StepTransformerObject ; end
class StepDefinitionObject < StepTransformerObject;
end

end
7 changes: 3 additions & 4 deletions lib/yard/code_objects/step_transform.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@


module YARD::CodeObjects

class StepTransformObject < StepTransformerObject ; end

class StepTransformObject < StepTransformerObject;
end

end

0 comments on commit d7e5ce9

Please sign in to comment.