Skip to content

Commit

Permalink
ruby use two spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Jan 18, 2024
1 parent 1fd4dcc commit 076a77b
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 209 deletions.
7 changes: 6 additions & 1 deletion src/Generator/CodeGeneratorAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(?Config $config = null)
$this->generator = $this->newTypeGenerator($mapping);
$this->namespace = $config?->get(Config::NAMESPACE);
$this->mapping = $mapping;
$this->indent = str_repeat(' ', $config?->get(Config::INDENT) ?? 4);
$this->indent = str_repeat(' ', $this->getIndent());
}

public function generate(SchemaInterface $schema)
Expand Down Expand Up @@ -346,4 +346,9 @@ protected function writeFooter(TypeAbstract $origin): string
{
return '';
}

protected function getIndent(): int
{
return 4;
}
}
5 changes: 5 additions & 0 deletions src/Generator/Ruby.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ protected function writeFooter(TypeAbstract $origin): string

return $code;
}

protected function getIndent(): int
{
return 2;
}
}
94 changes: 47 additions & 47 deletions tests/Generator/resource/ruby/ruby.rb
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
# Location of the person
class Location
attr_accessor :lat, :long
attr_accessor :lat, :long

def initialize(lat, long)
@lat = lat
@long = long
end
def initialize(lat, long)
@lat = lat
@long = long
end
end

# An application
class Web
attr_accessor :name, :url
attr_accessor :name, :url

def initialize(name, url)
@name = name
@url = url
end
def initialize(name, url)
@name = name
@url = url
end
end

# An simple author element with some description
class Author
attr_accessor :title, :email, :categories, :locations, :origin
attr_accessor :title, :email, :categories, :locations, :origin

def initialize(title, email, categories, locations, origin)
@title = title
@email = email
@categories = categories
@locations = locations
@origin = origin
end
def initialize(title, email, categories, locations, origin)
@title = title
@email = email
@categories = categories
@locations = locations
@origin = origin
end
end

# An general news entry
class News
attr_accessor :config, :inline_config, :map_tags, :map_receiver, :map_resources, :tags, :receiver, :resources, :profile_image, :read, :source, :author, :meta, :send_date, :read_date, :expires, :range, :price, :rating, :content, :question, :version, :coffee_time, :profile_uri, :captcha, :payload
attr_accessor :config, :inline_config, :map_tags, :map_receiver, :map_resources, :tags, :receiver, :resources, :profile_image, :read, :source, :author, :meta, :send_date, :read_date, :expires, :range, :price, :rating, :content, :question, :version, :coffee_time, :profile_uri, :captcha, :payload

def initialize(config, inline_config, map_tags, map_receiver, map_resources, tags, receiver, resources, profile_image, read, source, author, meta, send_date, read_date, expires, range, price, rating, content, question, version, coffee_time, profile_uri, captcha, payload)
@config = config
@inline_config = inline_config
@map_tags = map_tags
@map_receiver = map_receiver
@map_resources = map_resources
@tags = tags
@receiver = receiver
@resources = resources
@profile_image = profile_image
@read = read
@source = source
@author = author
@meta = meta
@send_date = send_date
@read_date = read_date
@expires = expires
@range = range
@price = price
@rating = rating
@content = content
@question = question
@version = version
@coffee_time = coffee_time
@profile_uri = profile_uri
@captcha = captcha
@payload = payload
end
def initialize(config, inline_config, map_tags, map_receiver, map_resources, tags, receiver, resources, profile_image, read, source, author, meta, send_date, read_date, expires, range, price, rating, content, question, version, coffee_time, profile_uri, captcha, payload)
@config = config
@inline_config = inline_config
@map_tags = map_tags
@map_receiver = map_receiver
@map_resources = map_resources
@tags = tags
@receiver = receiver
@resources = resources
@profile_image = profile_image
@read = read
@source = source
@author = author
@meta = meta
@send_date = send_date
@read_date = read_date
@expires = expires
@range = range
@price = price
@rating = rating
@content = content
@question = question
@version = version
@coffee_time = coffee_time
@profile_uri = profile_uri
@captcha = captcha
@payload = payload
end
end
Loading

0 comments on commit 076a77b

Please sign in to comment.