Skip to content

Commit

Permalink
Merge pull request #111 from razum2um/fix_array_example_generation
Browse files Browse the repository at this point in the history
Fix array example generation
  • Loading branch information
razum2um committed Dec 2, 2015
2 parents 80e5fdb + a90ad9a commit af3840b
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ matrix:
- rvm: 2.2.0
gemfile: gemfiles/rails_32.gemfile
install: bundle install -j4 --path vendor/bundle

notifications:
slack: evilmartians:3TVEqLTmDrMKUZZqUIy9apFT
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,35 @@ appraise 'rails-32' do
gem 'rails', '~> 3.2.21'
gem 'sprockets', '~> 2.2.2.backport2', github: 'razum2um/sprockets-2.2.2.backport', branch: 'master'
gem 'sass-rails', github: 'razum2um/sass-rails', branch: 'backport'
gem 'autoprefixer-rails', '~> 5.2'
gem 'rspec', '~> 2.14'
eval ::File.read('Gemfile')
end

appraise 'rails-40' do
gem 'rails', '~> 4.0.13'
gem 'sprockets'
gem 'sass-rails'
gem 'autoprefixer-rails', '~> 5.2'
gem 'rspec', '~> 2.14'
eval ::File.read('Gemfile')
end

appraise 'rails-41' do
gem 'rails', '~> 4.1.9'
gem 'sprockets'
gem 'sass-rails'
gem 'autoprefixer-rails', '~> 5.2'
gem 'rspec', '~> 2.14'
eval ::File.read('Gemfile')
end

appraise 'rails-42' do
gem 'rails', '~> 4.2.0'
gem 'sprockets'
gem 'sass-rails'
gem 'autoprefixer-rails', '~> 5.2'
gem 'rspec', '~> 2.14'
eval ::File.read('Gemfile')
end

4 changes: 3 additions & 1 deletion gemfiles/rails_32.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source "https://rubygems.org"
gem "rails", "~> 3.2.21"
gem "sprockets", "~> 2.2.2.backport2", :github => "razum2um/sprockets-2.2.2.backport", :branch => "master"
gem "sass-rails", :github => "razum2um/sass-rails", :branch => "backport"
gem "autoprefixer-rails", "~> 5.2"
gem "rspec", "~> 2.14"

group :development do
gem "fuubar"
Expand All @@ -14,7 +16,7 @@ group :development do
gem "appraisal"
gem "uglifier"
gem "coffee-rails"
gem "bootstrap-sass"
gem "bootstrap-sass", "~> 3.3.3"
gem "jquery-rails"
gem "remotipart"
gem "launchy"
Expand Down
4 changes: 3 additions & 1 deletion gemfiles/rails_40.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source "https://rubygems.org"
gem "rails", "~> 4.0.13"
gem "sprockets"
gem "sass-rails"
gem "autoprefixer-rails", "~> 5.2"
gem "rspec", "~> 2.14"

group :development do
gem "fuubar"
Expand All @@ -14,7 +16,7 @@ group :development do
gem "appraisal"
gem "uglifier"
gem "coffee-rails"
gem "bootstrap-sass"
gem "bootstrap-sass", "~> 3.3.3"
gem "jquery-rails"
gem "remotipart"
gem "launchy"
Expand Down
4 changes: 3 additions & 1 deletion gemfiles/rails_41.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source "https://rubygems.org"
gem "rails", "~> 4.1.9"
gem "sprockets"
gem "sass-rails"
gem "autoprefixer-rails", "~> 5.2"
gem "rspec", "~> 2.14"

group :development do
gem "fuubar"
Expand All @@ -14,7 +16,7 @@ group :development do
gem "appraisal"
gem "uglifier"
gem "coffee-rails"
gem "bootstrap-sass"
gem "bootstrap-sass", "~> 3.3.3"
gem "jquery-rails"
gem "remotipart"
gem "launchy"
Expand Down
4 changes: 3 additions & 1 deletion gemfiles/rails_42.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source "https://rubygems.org"
gem "rails", "~> 4.2.0"
gem "sprockets"
gem "sass-rails"
gem "autoprefixer-rails", "~> 5.2"
gem "rspec", "~> 2.14"

group :development do
gem "fuubar"
Expand All @@ -14,7 +16,7 @@ group :development do
gem "appraisal"
gem "uglifier"
gem "coffee-rails"
gem "bootstrap-sass"
gem "bootstrap-sass", "~> 3.3.3"
gem "jquery-rails"
gem "remotipart"
gem "launchy"
Expand Down
10 changes: 7 additions & 3 deletions lib/lurker/json/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ def to_yaml(options = {})
YAML.dump(to_hash(options))
end

def respond_to_missing?(method, include_private=false)
@schema.respond_to?(method, include_private)
end

def method_missing(method, *args, &block)
if @schema.is_a?(Lurker::Json::Schema) || @schema.respond_to?(method)
return @schema.send(method, *args, &block)
@schema.send(method, *args, &block)
else
super
end

super
end

private
Expand Down
1 change: 1 addition & 0 deletions lib/lurker/presenters/base_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def tag_with_anchor(tag, content, anchor_slug = nil)
end

def markup(content)
return unless content
Lurker.safe_require 'kramdown'
defined?(Kramdown) ? Kramdown::Document.new(content).to_html : content
end
Expand Down
6 changes: 3 additions & 3 deletions lib/lurker/presenters/endpoint_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ def example_from_object(object, parent=nil)
end

def example_from_array(array, parent=nil)
if array["items"].is_a? Array
if array["items"].respond_to?(:each) && !array["items"].respond_to?(:each_pair)
example = []
array["items"].each do |item|
example << example_from_schema(item, parent)
end
example
elsif (array["items"] || {})["type"].is_a? Array
elsif (types = (array["items"] || {})["type"]).respond_to?(:each)
example = []
array["items"]["type"].each do |item|
types.each do |item|
example << example_from_schema(item, parent)
end
example
Expand Down
11 changes: 6 additions & 5 deletions lib/lurker/presenters/schema_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,19 @@ def enum_html

def items_html
return unless items = @schema["items"]
return if items.size == 0

html = ""
html << '<li>Items'

sub_options = options.merge(:nested => options[:nested] + 1, :parent => self)

if items.is_a? Array
item.compact.each do |item|
html << self.class.new(item, sub_options).to_html
end
else
if items.respond_to?(:each_pair)
html << self.class.new(items, sub_options).to_html
else
items.each do |item|
html << self.class.new(item, sub_options).to_html if item
end
end

html << '</li>'
Expand Down
2 changes: 1 addition & 1 deletion lib/lurker/presenters/service_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ def endpoints_by_prefix
private

def service_domains
service.domains.to_hash
service.domains.try(:to_hash) || {}
end
end
2 changes: 1 addition & 1 deletion lib/lurker/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def base_path
if base_path && !base_path.end_with?('/')
base_path + '/'
else
base_path
base_path || '/'
end
end

Expand Down

0 comments on commit af3840b

Please sign in to comment.