betterdocs 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +2 -8
  4. data/Gemfile +1 -2
  5. data/Rakefile +4 -2
  6. data/VERSION +1 -1
  7. data/betterdocs.gemspec +14 -8
  8. data/lib/betterdocs.rb +2 -0
  9. data/lib/betterdocs/dsl.rb +0 -1
  10. data/lib/betterdocs/dsl/controller/action/param.rb +2 -1
  11. data/lib/betterdocs/dsl/controller/action/response.rb +9 -12
  12. data/lib/betterdocs/dsl/json_params/param.rb +2 -0
  13. data/lib/betterdocs/dsl/json_type_mapper.rb +1 -1
  14. data/lib/betterdocs/dsl/result/link.rb +1 -0
  15. data/lib/betterdocs/dsl/result/property.rb +9 -2
  16. data/lib/betterdocs/generator/markdown.rb +32 -25
  17. data/lib/betterdocs/generator/markdown/templates/README.md.erb +3 -3
  18. data/lib/betterdocs/global.rb +8 -7
  19. data/lib/betterdocs/result_representer.rb +1 -4
  20. data/lib/betterdocs/sanitizer.rb +23 -0
  21. data/lib/betterdocs/version.rb +1 -1
  22. data/spec/assets/app/assets/images/logos/logo.png +0 -0
  23. data/spec/assets/app/views/api_v4/documentation/assets/CHANGELOG.md +1 -0
  24. data/spec/assets/config/betterdocs.yml +18 -15
  25. data/spec/betterdocs/dsl/controller/action/param_spec.rb +34 -0
  26. data/spec/betterdocs/dsl/controller/action/response_spec.rb +59 -0
  27. data/spec/{json_type_mapper_spec.rb → betterdocs/dsl/json_type_mapper_spec.rb} +3 -3
  28. data/spec/betterdocs/dsl/result/collection_property_spec.rb +38 -0
  29. data/spec/betterdocs/dsl/result/link_spec.rb +43 -0
  30. data/spec/betterdocs/dsl/result/property_spec.rb +83 -0
  31. data/spec/betterdocs/generator/markdown_spec.rb +45 -0
  32. data/spec/{global_spec.rb → betterdocs/global_spec.rb} +2 -2
  33. data/spec/{json_params_representer_spec.rb → betterdocs/json_params_representer_spec.rb} +1 -1
  34. data/spec/{result_representer_spec.rb → betterdocs/result_representer_spec.rb} +1 -1
  35. data/spec/betterdocs/sanitizer_spec.rb +25 -0
  36. data/spec/controller_dsl_spec.rb +1 -1
  37. data/spec/result_representer_dsl_spec.rb +1 -2
  38. data/spec/spec_helper.rb +8 -10
  39. metadata +58 -14
  40. data/spec/generator/markdown_spec.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2dce2da10a7aa53142585ae1bcd71e01647ac0a
4
- data.tar.gz: 39cc4830e670c791553e3b2fc6682dac1f9f0d35
3
+ metadata.gz: f8f9176bd1f4dd32527fa0dc6377812681cbf904
4
+ data.tar.gz: 71e72348605a0c5bd5d33a2e4802c9d919cf39ab
5
5
  SHA512:
6
- metadata.gz: 14435b08ce425e42850d60294b562626fcbd0a74b9ac3df8f8a468b43cfb204607cb73a8590d74223cbd35acd38c3438a362cc531db4017450a70288abcf1456
7
- data.tar.gz: 76eb043df9dc0017a110e3d4f416d67f6f4f40eaeaea2447825b034e36a134fccdfa50e6f64b06db1e2892a8ba59e40e10844bd5730451b7c37171a1c4d95077
6
+ metadata.gz: be4a0a50a88523b6a6d5a25fd7d22902136dbe214e73c7952b3b4f4775ec028e3e19501ea587bb7bcd9158888ae3b93cca86e7a2e20bf270a8a43592a83237a9
7
+ data.tar.gz: 56704465cadef588fb6cbf1746974a199d571756098774b63e620d3eddf4d15ca167f09372262f98b3d31e2285e7e064d5dc19768501ab380c3fe15816a7f4b9
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  .ruby-version
7
7
  .rvmrc
8
8
  .utilsrc
9
+ .yardoc
9
10
  Gemfile.lock
10
11
  coverage
11
12
  errors.lst
@@ -1,9 +1,3 @@
1
- # Passes arguments to bundle install (http://gembundler.com/man/bundle-install.1.html)
2
- bundler_args: --binstubs
3
-
4
- # Specify which ruby versions you wish to run your tests on, each version will be used
5
1
  rvm:
6
- - 2.3.1
7
- script: "bundle exec rake"
8
- before_install:
9
- - gem update bundler
2
+ - 2.4.0
3
+ sudo: false
data/Gemfile CHANGED
@@ -4,5 +4,4 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem "codeclimate-test-reporter", group: :test, require: false
8
- gem 'byebug'
7
+ gem 'byebug', platform: 'mri'
data/Rakefile CHANGED
@@ -12,14 +12,16 @@ GemHadar do
12
12
  test_dir 'spec'
13
13
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
14
14
  '.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc',
15
- '.bundle', '.byebug_history', 'errors.lst'
15
+ '.bundle', '.byebug_history', 'errors.lst', '.yardoc'
16
16
  readme 'README.md'
17
- title "#{name.camelize} -- "
17
+ title "#{name.camelize}"
18
18
 
19
19
  dependency 'tins', '~>1.3', '>=1.3.5'
20
20
  dependency 'rails', '>=3', '<6'
21
21
  dependency 'term-ansicolor', '~>1.3'
22
22
  dependency 'complex_config', '~>0.5'
23
+ dependency 'infobar'
24
+ dependency 'mize'
23
25
  development_dependency 'simplecov'
24
26
  development_dependency 'rspec'
25
27
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -1,23 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterdocs 0.4.0 ruby lib
2
+ # stub: betterdocs 0.5.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterdocs".freeze
6
- s.version = "0.4.0"
6
+ s.version = "0.5.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["betterplace Developers".freeze]
11
- s.date = "2016-12-07"
11
+ s.date = "2017-03-20"
12
12
  s.description = "This library provides tools to generate API documention for a web site's REST-ful JSON API.".freeze
13
13
  s.email = "developers@betterplace.org".freeze
14
- s.extra_rdoc_files = ["README.md".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/version.rb".freeze]
15
- s.files = [".codeclimate.yml".freeze, ".gitignore".freeze, ".rspec".freeze, ".travis.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterdocs.gemspec".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/markdown/templates/README.md.erb".freeze, "lib/betterdocs/generator/markdown/templates/section.md.erb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/tasks/doc.rake".freeze, "lib/betterdocs/version.rb".freeze, "spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/assets/config/betterdocs.yml".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/generator/markdown_spec.rb".freeze, "spec/global_spec.rb".freeze, "spec/json_params_representer_spec.rb".freeze, "spec/json_type_mapper_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/result_representer_spec.rb".freeze, "spec/spec_helper.rb".freeze]
14
+ s.extra_rdoc_files = ["README.md".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/version.rb".freeze]
15
+ s.files = [".codeclimate.yml".freeze, ".gitignore".freeze, ".rspec".freeze, ".travis.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterdocs.gemspec".freeze, "lib/betterdocs.rb".freeze, "lib/betterdocs/controller_collector.rb".freeze, "lib/betterdocs/dsl.rb".freeze, "lib/betterdocs/dsl/common.rb".freeze, "lib/betterdocs/dsl/controller.rb".freeze, "lib/betterdocs/dsl/controller/action.rb".freeze, "lib/betterdocs/dsl/controller/action/param.rb".freeze, "lib/betterdocs/dsl/controller/action/response.rb".freeze, "lib/betterdocs/dsl/controller/controller.rb".freeze, "lib/betterdocs/dsl/controller/controller_base.rb".freeze, "lib/betterdocs/dsl/json_params.rb".freeze, "lib/betterdocs/dsl/json_params/param.rb".freeze, "lib/betterdocs/dsl/json_type_mapper.rb".freeze, "lib/betterdocs/dsl/naming.rb".freeze, "lib/betterdocs/dsl/representer.rb".freeze, "lib/betterdocs/dsl/result.rb".freeze, "lib/betterdocs/dsl/result/collection_property.rb".freeze, "lib/betterdocs/dsl/result/link.rb".freeze, "lib/betterdocs/dsl/result/property.rb".freeze, "lib/betterdocs/generator/config_shortcuts.rb".freeze, "lib/betterdocs/generator/markdown.rb".freeze, "lib/betterdocs/generator/markdown/templates/README.md.erb".freeze, "lib/betterdocs/generator/markdown/templates/section.md.erb".freeze, "lib/betterdocs/global.rb".freeze, "lib/betterdocs/json_params_representer.rb".freeze, "lib/betterdocs/json_params_representer_collector.rb".freeze, "lib/betterdocs/json_time_with_zone.rb".freeze, "lib/betterdocs/mix_into_controller.rb".freeze, "lib/betterdocs/railtie.rb".freeze, "lib/betterdocs/rake_tasks.rb".freeze, "lib/betterdocs/representer.rb".freeze, "lib/betterdocs/result_representer.rb".freeze, "lib/betterdocs/result_representer_collector.rb".freeze, "lib/betterdocs/sanitizer.rb".freeze, "lib/betterdocs/section.rb".freeze, "lib/betterdocs/tasks/doc.rake".freeze, "lib/betterdocs/version.rb".freeze, "spec/assets/app/assets/images/logos/logo.png".freeze, "spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/assets/app/views/api_v4/documentation/assets/CHANGELOG.md".freeze, "spec/assets/config/betterdocs.yml".freeze, "spec/betterdocs/dsl/controller/action/param_spec.rb".freeze, "spec/betterdocs/dsl/controller/action/response_spec.rb".freeze, "spec/betterdocs/dsl/json_type_mapper_spec.rb".freeze, "spec/betterdocs/dsl/result/collection_property_spec.rb".freeze, "spec/betterdocs/dsl/result/link_spec.rb".freeze, "spec/betterdocs/dsl/result/property_spec.rb".freeze, "spec/betterdocs/generator/markdown_spec.rb".freeze, "spec/betterdocs/global_spec.rb".freeze, "spec/betterdocs/json_params_representer_spec.rb".freeze, "spec/betterdocs/result_representer_spec.rb".freeze, "spec/betterdocs/sanitizer_spec.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/spec_helper.rb".freeze]
16
16
  s.homepage = "http://github.com/betterplace/betterdocs".freeze
17
- s.rdoc_options = ["--title".freeze, "Betterdocs -- ".freeze, "--main".freeze, "README.md".freeze]
18
- s.rubygems_version = "2.6.8".freeze
17
+ s.rdoc_options = ["--title".freeze, "Betterdocs".freeze, "--main".freeze, "README.md".freeze]
18
+ s.rubygems_version = "2.6.10".freeze
19
19
  s.summary = "Betterplace API documentation library".freeze
20
- s.test_files = ["spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/generator/markdown_spec.rb".freeze, "spec/global_spec.rb".freeze, "spec/json_params_representer_spec.rb".freeze, "spec/json_type_mapper_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/result_representer_spec.rb".freeze, "spec/spec_helper.rb".freeze]
20
+ s.test_files = ["spec/assets/app/controllers/api/foos_controller.rb".freeze, "spec/betterdocs/dsl/controller/action/param_spec.rb".freeze, "spec/betterdocs/dsl/controller/action/response_spec.rb".freeze, "spec/betterdocs/dsl/json_type_mapper_spec.rb".freeze, "spec/betterdocs/dsl/result/collection_property_spec.rb".freeze, "spec/betterdocs/dsl/result/link_spec.rb".freeze, "spec/betterdocs/dsl/result/property_spec.rb".freeze, "spec/betterdocs/generator/markdown_spec.rb".freeze, "spec/betterdocs/global_spec.rb".freeze, "spec/betterdocs/json_params_representer_spec.rb".freeze, "spec/betterdocs/result_representer_spec.rb".freeze, "spec/betterdocs/sanitizer_spec.rb".freeze, "spec/controller_dsl_spec.rb".freeze, "spec/result_representer_dsl_spec.rb".freeze, "spec/spec_helper.rb".freeze]
21
21
 
22
22
  if s.respond_to? :specification_version then
23
23
  s.specification_version = 4
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
30
30
  s.add_runtime_dependency(%q<rails>.freeze, ["< 6", ">= 3"])
31
31
  s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
32
32
  s.add_runtime_dependency(%q<complex_config>.freeze, ["~> 0.5"])
33
+ s.add_runtime_dependency(%q<infobar>.freeze, [">= 0"])
34
+ s.add_runtime_dependency(%q<mize>.freeze, [">= 0"])
33
35
  else
34
36
  s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
35
37
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
@@ -38,6 +40,8 @@ Gem::Specification.new do |s|
38
40
  s.add_dependency(%q<rails>.freeze, ["< 6", ">= 3"])
39
41
  s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
40
42
  s.add_dependency(%q<complex_config>.freeze, ["~> 0.5"])
43
+ s.add_dependency(%q<infobar>.freeze, [">= 0"])
44
+ s.add_dependency(%q<mize>.freeze, [">= 0"])
41
45
  end
42
46
  else
43
47
  s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
@@ -47,5 +51,7 @@ Gem::Specification.new do |s|
47
51
  s.add_dependency(%q<rails>.freeze, ["< 6", ">= 3"])
48
52
  s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
49
53
  s.add_dependency(%q<complex_config>.freeze, ["~> 0.5"])
54
+ s.add_dependency(%q<infobar>.freeze, [">= 0"])
55
+ s.add_dependency(%q<mize>.freeze, [">= 0"])
50
56
  end
51
57
  end
@@ -1,4 +1,5 @@
1
1
  require 'tins/xt'
2
+ require 'mize'
2
3
  require 'rails'
3
4
 
4
5
  module Betterdocs
@@ -14,6 +15,7 @@ end
14
15
 
15
16
  require 'betterdocs/version'
16
17
  require 'betterdocs/dsl'
18
+ require 'betterdocs/sanitizer'
17
19
  require 'betterdocs/result_representer'
18
20
  require 'betterdocs/result_representer_collector'
19
21
  require 'betterdocs/controller_collector'
@@ -3,7 +3,6 @@ module Betterdocs
3
3
  end
4
4
  end
5
5
 
6
- require 'betterdocs/dsl/naming'
7
6
  require 'betterdocs/dsl/controller'
8
7
  require 'betterdocs/dsl/result'
9
8
  require 'betterdocs/dsl/json_params'
@@ -15,11 +15,12 @@ class Betterdocs::Dsl::Controller::Action::Param
15
15
 
16
16
  dsl_accessor :description, 'TODO'
17
17
 
18
+ # This value should be used to construct an example URL.
18
19
  dsl_accessor :use_in_url, true
19
20
 
20
21
  alias use_in_url? use_in_url
21
22
 
22
23
  def to_s
23
- value
24
+ value.to_s
24
25
  end
25
26
  end
@@ -26,18 +26,15 @@ class Betterdocs::Dsl::Controller::Action::Response
26
26
  end
27
27
 
28
28
  def representer
29
- if data
30
- data.ask_and_send(:representer) ||
31
- data.singleton_class.ancestors.find { |c|
32
- Betterdocs::ResultRepresenter >= c && c.respond_to?(:docs)
33
- # Actually it's more like
34
- # Betterdocs::ResultRepresenter >= c && !c.singleton_class?
35
- # in newer rubies.
36
- # But singleton_class? is broken and private in ruby 2.1.x not
37
- # existant in <= ruby 2.0.x and finally works in ruby 2.2.x.
38
- # What a mess!
39
- }
40
- end
29
+ data or return
30
+ data.ask_and_send(:representer) || inherited_representer(data)
31
+ end
32
+
33
+ private\
34
+ def inherited_representer(data)
35
+ data.singleton_class.ancestors.find { |c|
36
+ Betterdocs::ResultRepresenter >= c && c.respond_to?(:docs)
37
+ }
41
38
  end
42
39
 
43
40
  def to_json(*a)
@@ -1,3 +1,5 @@
1
+ require 'betterdocs/dsl/naming'
2
+
1
3
  class Betterdocs::Dsl::JsonParams::Param < Betterdocs::Dsl::Representer
2
4
  extend Tins::DSLAccessor
3
5
  include Betterdocs::Dsl::Common
@@ -3,7 +3,7 @@ module Betterdocs::Dsl::JsonTypeMapper
3
3
 
4
4
  def derive_json_type_from(klass)
5
5
  Class === klass or klass = klass.class
6
- result = {
6
+ {
7
7
  TrueClass => 'boolean',
8
8
  FalseClass => 'boolean',
9
9
  NilClass => 'null',
@@ -29,6 +29,7 @@ class Betterdocs::Dsl::Result::Link < Betterdocs::Dsl::Representer
29
29
  }
30
30
  templated and link['templated'] = true
31
31
  result['links'].push(link)
32
+ self
32
33
  end
33
34
 
34
35
  def add_to_collector(collector)
@@ -14,7 +14,9 @@ class Betterdocs::Dsl::Result::Property < Betterdocs::Dsl::Representer
14
14
 
15
15
  dsl_accessor :example, 'TODO'
16
16
 
17
- dsl_accessor :types do [] end
17
+ dsl_accessor :types
18
+
19
+ dsl_accessor :sanitize do Betterdocs::Global.default_sanitize end
18
20
 
19
21
  def initialize(representer, name, options, &block)
20
22
  super
@@ -36,6 +38,7 @@ class Betterdocs::Dsl::Result::Property < Betterdocs::Dsl::Representer
36
38
  def assign(result, object)
37
39
  assign?(object) or return
38
40
  result[actual_property_name] = compute_value(object)
41
+ self
39
42
  end
40
43
 
41
44
  def compute_value(object)
@@ -46,10 +49,14 @@ class Betterdocs::Dsl::Result::Property < Betterdocs::Dsl::Representer
46
49
  elsif ActiveSupport::TimeWithZone === value
47
50
  value.extend Betterdocs::JsonTimeWithZone
48
51
  else
49
- value
52
+ sanitizer.sanitize(value)
50
53
  end
51
54
  end
52
55
 
56
+ def sanitizer
57
+ Betterdocs::Sanitizer.new(&sanitize)
58
+ end
59
+
53
60
  def add_to_collector(collector)
54
61
  collector.properties[name] = self
55
62
  end
@@ -1,11 +1,13 @@
1
+ require 'infobar'
2
+ require 'fileutils'
3
+ require 'term/ansicolor'
4
+
1
5
  module Betterdocs
2
6
  module Generator
3
7
  class Markdown
4
8
  include ::Betterdocs::Generator::ConfigShortcuts
5
- require 'fileutils'
6
- include FileUtils::Verbose
7
- require 'term/ansicolor'
8
9
  include Term::ANSIColor
10
+ include FileUtils
9
11
 
10
12
  def initialize(only: nil)
11
13
  only and @only = Regexp.new(only)
@@ -29,45 +31,58 @@ module Betterdocs
29
31
  end
30
32
 
31
33
  def configure_for_creation
32
- STDERR.puts "Setting asset_host to #{Betterdocs::Global.asset_host.inspect}."
34
+ infobar.puts color(40, "Setting asset_host to #{Betterdocs::Global.asset_host.inspect}.")
33
35
  Betterdocs.rails.configuration.action_controller.asset_host = Betterdocs::Global.asset_host
34
36
  options = {
35
37
  host: Betterdocs::Global.api_host,
36
38
  protocol: Betterdocs::Global.api_protocol
37
39
  }
38
- STDERR.puts "Setting default_url_options to #{options.inspect}."
40
+ infobar.puts color(40, "Setting default_url_options to #{options.inspect}.")
39
41
  Betterdocs.rails.application.routes.default_url_options = options
40
42
  self
41
43
  end
42
44
 
43
45
  def create_sections(dirname)
46
+ Infobar(total: sections.size)
44
47
  cd dirname do
45
48
  for section in sections.values
49
+ infobar.progress(
50
+ message: "Section #{section.name.to_s.inspect} %c/%t in %te ETA %e @%E",
51
+ force: true
52
+ )
46
53
  if @only
47
54
  @only =~ section.name or next
48
55
  end
49
- STDERR.puts on_color(33, "Creating section #{section.name.inspect}.")
50
56
  render_to "sections/#{section.name}.md", section_template, section.instance_eval('binding')
51
57
  end
52
58
  end
59
+ infobar.finish
60
+ infobar.newline
53
61
  self
54
62
  end
55
63
 
56
64
  def create_readme(dirname)
57
65
  name = 'README.md'
58
66
  cd dirname do
59
- STDERR.puts on_color(33, "Creating readme.")
67
+ infobar.puts color(40, "Creating readme.")
60
68
  render_to name, readme_template, binding
61
69
  end
62
70
  self
63
71
  end
64
72
 
65
73
  def create_assets
74
+ Infobar(total: config.assets.size)
66
75
  config.each_asset do |src, dst|
67
- STDERR.puts on_color(33, "Creating asset #{dst.inspect} from #{src.inspect}.")
76
+ infobar.progress(
77
+ message: "Asset #{File.basename(src).inspect} %c/%t in %te ETA %e @%E",
78
+ force: true
79
+ )
68
80
  mkdir_p File.dirname(dst)
69
- cp src, dst
81
+ cp Betterdocs.rails.root.join(src), dst
70
82
  end
83
+ infobar.finish
84
+ infobar.newline
85
+ self
71
86
  end
72
87
 
73
88
  private
@@ -75,18 +90,10 @@ module Betterdocs
75
90
  def fail_while_rendering(template, exception)
76
91
  message = blink(color(231, on_color(
77
92
  124, " *** ERROR #{exception.class}: #{exception.message.inspect} in template ***")))
78
- STDERR.puts message
79
- Timeout.timeout(5, Timeout::Error) do
80
- STDERR.print "Output long error message? (yes/NO) "
81
- if STDIN.gets =~ /\Ay/i
82
- STDERR.puts color(88, on_color(136, template)), message,
83
- color(136, (%w[Backtrace:] + exception.backtrace) * "\n"),
84
- message
85
- end
86
- end
87
- rescue Timeout::Error
88
- STDERR.puts "Nope…"
89
- ensure
93
+ infobar.puts message
94
+ infobar.puts color(88, on_color(136, template)), message,
95
+ color(136, (%w[Backtrace:] + exception.backtrace) * "\n"),
96
+ message
90
97
  exit 1
91
98
  end
92
99
 
@@ -105,7 +112,7 @@ module Betterdocs
105
112
  end
106
113
 
107
114
  def read_template(filename)
108
- STDERR.puts "Now reading #{filename.inspect}."
115
+ infobar.puts color(40, "Now reading #{filename.inspect}.")
109
116
  File.read(filename)
110
117
  end
111
118
 
@@ -117,19 +124,19 @@ module Betterdocs
117
124
  path = File.expand_path(template_subpath, default_templates_directory)
118
125
  File.file?(path) and return read_template(path)
119
126
  message = "#{template_subpath.inspect} missing"
120
- STDERR.puts " *** #{message}"
127
+ infobar.puts " *** #{message}"
121
128
  "[#{message}]"
122
129
  end
123
130
 
131
+ memoize method:
124
132
  def readme_template
125
133
  provide_template 'README.md.erb'
126
134
  end
127
- memoize_method :readme_template
128
135
 
136
+ memoize method:
129
137
  def section_template
130
138
  provide_template 'section.md.erb'
131
139
  end
132
- memoize_method :section_template
133
140
 
134
141
  def prepare_dir(dirname)
135
142
  dirname.present? or raise ArgumentError,
@@ -4,6 +4,6 @@ The <%= project_name %> API
4
4
  API ready for use
5
5
  -----------------
6
6
 
7
- <%- for secion in sections >
8
- - [<%=section.name.to_s.camelcase](<%= section(section.name) %>.md)
9
-
7
+ <%- for section in sections -%>
8
+ - [<%= section.name.to_s.camelcase %>](<%= section(section.name) %>.md)
9
+ <%- end -%>
@@ -4,6 +4,7 @@ module Betterdocs
4
4
  module Global
5
5
  class << self
6
6
  extend Tins::DSLAccessor
7
+ extend ComplexConfig::Provider::Shortcuts
7
8
 
8
9
  dsl_accessor :project_name, 'Project' # Name of the project
9
10
 
@@ -72,6 +73,11 @@ module Betterdocs
72
73
 
73
74
  dsl_accessor :ignore do [] end # All lines of the .gitignore file as an array
74
75
 
76
+ def default_sanitize(code = nil)
77
+ code and @default_sanitize = eval(code)
78
+ @default_sanitize
79
+ end
80
+
75
81
  def assets=(hash)
76
82
  @assets&.clear
77
83
  assets(hash)
@@ -79,11 +85,7 @@ module Betterdocs
79
85
 
80
86
  def assets(hash = nil)
81
87
  @assets ||= {}
82
- if hash
83
- hash.each do |path, to|
84
- asset path, to: to
85
- end
86
- end
88
+ hash&.each { |path, to| asset path, to: to }
87
89
  @assets
88
90
  end
89
91
 
@@ -116,7 +118,7 @@ module Betterdocs
116
118
  end
117
119
 
118
120
  def configuration_file
119
- complex_config.betterdocs
121
+ cc.betterdocs
120
122
  rescue ComplexConfig::ConfigurationFileMissing
121
123
  end
122
124
 
@@ -127,7 +129,6 @@ module Betterdocs
127
129
  end
128
130
 
129
131
  def configure(config = configuration_file, &block)
130
- Betterdocs.rails.env.development? or return
131
132
  config and configure_via_yaml(config)
132
133
  block and instance_eval(&block)
133
134
  self
@@ -13,6 +13,7 @@ module Betterdocs::ResultRepresenter
13
13
  assign_links result, object
14
14
  end
15
15
  end
16
+
16
17
  def doc(type, name, **options, &block)
17
18
  docs.add_element(self, type, name, options, &block)
18
19
  end
@@ -60,9 +61,5 @@ module Betterdocs::ResultRepresenter
60
61
  d = doc(:link, name, **options, &block) and links << d
61
62
  self
62
63
  end
63
-
64
- def api_url_for(options = {})
65
- Betterdocs::Global.url_for(options)
66
- end
67
64
  end
68
65
  end
@@ -0,0 +1,23 @@
1
+ class Betterdocs::Sanitizer
2
+ JSON_NONSTRING_TYPES = Tins::ModuleGroup[
3
+ TrueClass,
4
+ FalseClass,
5
+ NilClass,
6
+ Numeric,
7
+ Array,
8
+ Hash,
9
+ ]
10
+
11
+ def initialize(&sanitize)
12
+ @sanitize = sanitize
13
+ end
14
+
15
+ def sanitize(value)
16
+ @sanitize or return value
17
+ if JSON_NONSTRING_TYPES === value
18
+ value
19
+ else
20
+ @sanitize.(value.to_s)
21
+ end
22
+ end
23
+ end
@@ -1,6 +1,6 @@
1
1
  module Betterdocs
2
2
  # Betterdocs version
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,16 +1,19 @@
1
1
  ---
2
- project_name: My Example Project
3
- api_host: api.example.com:3000
4
- api_protocol: https
5
- platform_host: site.example.com
6
- platform_protocol: http
7
- asset_host: "https://assets.example.com"
8
- api_prefix: api
9
- templates_directory: documentation/templates
10
- output_directory: api_docs
11
- assets:
12
- 'app/views/api_v4/documentation/assets/CHANGELOG.md': :root
13
- 'app/assets/images/logos/logo.png': images/logo.png
14
- ignore:
15
- - .DS_Store
16
- publish_git: 'git@github.com:foo/bar.git'
2
+ development: &development
3
+ project_name: My Example Project
4
+ api_host: api.example.com:3000
5
+ api_protocol: https
6
+ platform_host: site.example.com
7
+ platform_protocol: http
8
+ asset_host: "https://assets.example.com"
9
+ api_prefix: api
10
+ templates_directory: documentation/templates
11
+ output_directory: api_docs
12
+ assets:
13
+ 'app/views/api_v4/documentation/assets/CHANGELOG.md': :root
14
+ 'app/assets/images/logos/logo.png': images/logo.png
15
+ ignore:
16
+ - .DS_Store
17
+ publish_git: 'git@github.com:foo/bar.git'
18
+ default_sanitize: -> text { ActionController::Base.helpers.sanitize text }
19
+ test: *development
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Dsl::Controller::Action::Param do
4
+ let :param do
5
+ described_class.new('test') do
6
+ value 666
7
+ end
8
+ end
9
+
10
+ it 'has a name' do
11
+ expect(param.name).to eq 'test'
12
+ end
13
+
14
+ it 'has a value' do
15
+ expect(param.value).to eq 666
16
+ end
17
+
18
+ it 'has a required setting' do
19
+ expect(param.required).to eq true
20
+ end
21
+
22
+ it 'has a description' do
23
+ expect(param.description).to eq 'TODO'
24
+ end
25
+
26
+ it 'has a use_in_url setting' do
27
+ expect(param.use_in_url).to eq true
28
+ end
29
+
30
+ it 'can be displayed as a string' do
31
+ expect(param.to_s).to eq '666'
32
+ end
33
+ end
34
+
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Dsl::Controller::Action::Response do
4
+ let :docs do
5
+ double(
6
+ 'Betterdocs::ResultRepresenterCollector',
7
+ nested_links: :links,
8
+ nested_properties: :properties
9
+ )
10
+ end
11
+
12
+ let :representer do
13
+ double('Representer', docs: docs)
14
+ end
15
+
16
+ let :result_data do
17
+ double(
18
+ 'Result',
19
+ representer: representer,
20
+ to_json: '{ "the": "result" }'
21
+ )
22
+ end
23
+
24
+ let :response do
25
+ data = result_data
26
+ described_class.new do
27
+ data
28
+ end
29
+ end
30
+
31
+ let :param_value do
32
+ double('Betterdocs::Dsl::Controller::Action::Param', value: 'foo')
33
+ end
34
+
35
+ it 'has params' do
36
+ allow(response).to receive(:param).with(:test).and_return param_value
37
+ expect(response.params[:test]).to eq 'foo'
38
+ end
39
+
40
+ it 'has data' do
41
+ expect(response.data).to eq result_data
42
+ end
43
+
44
+ it 'has properties' do
45
+ expect(response.properties).to eq :properties
46
+ end
47
+
48
+ it 'has links' do
49
+ expect(response.links).to eq :links
50
+ end
51
+
52
+ it 'has representer' do
53
+ expect(response.representer).to eq representer
54
+ end
55
+
56
+ it 'can be converted into a JSON document' do
57
+ expect(response.to_json).to eq '{ "the": "result" }'
58
+ end
59
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe Betterdocs::Dsl::JsonTypeMapper do
3
+ describe Betterdocs::Dsl::JsonTypeMapper do
4
4
  let :jtm do Betterdocs::Dsl::JsonTypeMapper end
5
5
 
6
6
  it "derives json types" do
@@ -11,9 +11,9 @@ RSpec.describe Betterdocs::Dsl::JsonTypeMapper do
11
11
  expect(jtm.derive_json_type_from(nil)).to eq 'null'
12
12
  expect(jtm.derive_json_type_from(NilClass)).to eq 'null'
13
13
  expect(jtm.derive_json_type_from(42)).to eq 'number'
14
- expect(jtm.derive_json_type_from(Fixnum)).to eq 'number'
14
+ expect(jtm.derive_json_type_from(Integer)).to eq 'number'
15
15
  expect(jtm.derive_json_type_from(42)).to eq 'number'
16
- expect(jtm.derive_json_type_from(Fixnum)).to eq 'number'
16
+ expect(jtm.derive_json_type_from(Integer)).to eq 'number'
17
17
  expect(jtm.derive_json_type_from(Math::PI)).to eq 'number'
18
18
  expect(jtm.derive_json_type_from(Float)).to eq 'number'
19
19
  expect(jtm.derive_json_type_from([])).to eq 'array'
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Dsl::Result::CollectionProperty do
4
+ let :result do
5
+ {}
6
+ end
7
+
8
+ let :representer do
9
+ double('Betterdocs::ResultRepresenter')
10
+ end
11
+
12
+ let :sub_representer do
13
+ double(
14
+ 'Betterdocs::ResultRepresenter',
15
+ hashify: { 'a' => 'hash' },
16
+ '<': true
17
+ )
18
+ end
19
+
20
+ let :property do
21
+ sr = sub_representer
22
+ described_class.new(representer, 'test', {}) do
23
+ represent_with sr
24
+ end
25
+ end
26
+
27
+ let :members do
28
+ [ double('Member'), double('Member') ]
29
+ end
30
+
31
+ it 'calls representer for every member' do
32
+ property.assign(result, double(test: members))
33
+ expect(result['test']).to eq [
34
+ { 'a' => 'hash' },
35
+ { 'a' => 'hash' },
36
+ ]
37
+ end
38
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Dsl::Result::Link do
4
+ let :result do
5
+ {
6
+ 'links' => []
7
+ }
8
+ end
9
+
10
+ let :representer do
11
+ double('Betterdocs::ResultRepresenter')
12
+ end
13
+
14
+ context 'mostly default values' do
15
+ let :link do
16
+ described_class.new(representer, 'test', {}) do
17
+ url { :url }
18
+ end
19
+ end
20
+
21
+ it 'has a name' do
22
+ expect(link.name).to eq :test
23
+ end
24
+
25
+ it 'has a description' do
26
+ expect(link.description).to eq 'TODO'
27
+ end
28
+
29
+ it 'has an templated predicate' do
30
+ expect(link.templated).to eq false
31
+ end
32
+
33
+ it 'has an url block' do
34
+ expect(link.url).to be_a Proc
35
+ expect(link.url.()).to eq :url
36
+ end
37
+
38
+ it 'can be assigned' do
39
+ link.assign(result, double(test: '<foo><evil><bar>'))
40
+ expect(result['links']).to eq [ { 'rel' => 'test', 'href' => 'url' } ]
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Dsl::Result::Property do
4
+ let :result do
5
+ {}
6
+ end
7
+
8
+ let :representer do
9
+ double('Betterdocs::ResultRepresenter')
10
+ end
11
+
12
+ context 'mostly default values' do
13
+ let :property do
14
+ described_class.new(representer, 'test', {})
15
+ end
16
+
17
+ it 'has a name' do
18
+ expect(property.name).to eq :test
19
+ end
20
+
21
+ it 'has a description' do
22
+ expect(property.description).to eq 'TODO'
23
+ end
24
+
25
+ it 'has an example' do
26
+ expect(property.example).to eq 'TODO'
27
+ end
28
+
29
+ it 'has a types array' do
30
+ expect(property.types).to eq []
31
+ end
32
+
33
+ it 'has a sanitize proc' do
34
+ expect(property.sanitize).to be_a Proc
35
+ end
36
+
37
+ it 'can be assigned' do
38
+ property.assign(result, double(test: '<p><evil></p>'))
39
+ expect(result['test']).to eq '<p></p>'
40
+ end
41
+ end
42
+
43
+ context 'configured values' do
44
+ let :sanitize_proc do
45
+ -> text { text.gsub('<evil>', '') }
46
+ end
47
+
48
+ let :property do
49
+ sp = sanitize_proc
50
+ described_class.new(representer, 'test', {}) do
51
+ description 'description'
52
+ example 'example'
53
+ types ''
54
+ sanitize sp
55
+ end
56
+ end
57
+
58
+ it 'has a name' do
59
+ expect(property.name).to eq :test
60
+ end
61
+
62
+ it 'has a description' do
63
+ expect(property.description).to eq 'description'
64
+ end
65
+
66
+ it 'has an example' do
67
+ expect(property.example).to eq 'example'
68
+ end
69
+
70
+ it 'has a types array' do
71
+ expect(property.types).to eq %w[ string ]
72
+ end
73
+
74
+ it 'has a sanitize proc' do
75
+ expect(property.sanitize).to eq sanitize_proc
76
+ end
77
+
78
+ it 'can be assigned' do
79
+ property.assign(result, double(test: '<foo><evil><bar>'))
80
+ expect(result['test']).to eq '<foo><bar>'
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Generator::Markdown do
4
+ let :rails do
5
+ double(
6
+ root: Pathname.pwd + 'spec/assets',
7
+ env: double(development?: true),
8
+ configuration: double.as_null_object,
9
+ application: double.as_null_object
10
+ )
11
+ end
12
+
13
+ before do
14
+ allow(Betterdocs).to receive(:rails).and_return rails
15
+ ComplexConfig::Provider.config_dir = 'spec/assets/config'
16
+ Betterdocs::Global.configure
17
+ end
18
+
19
+ let :generator do
20
+ described_class.new
21
+ end
22
+
23
+ let :output_directory do
24
+ Dir.mktmpdir('api_docs')
25
+ end
26
+
27
+ before do
28
+ allow(generator.config).to receive(:output_directory).and_return output_directory
29
+ end
30
+
31
+ it 'can be instantiated' do
32
+ expect(generator).to be_a described_class
33
+ end
34
+
35
+ it 'can generate' do
36
+ dirname = generator.config.output_directory
37
+ expect(generator).to receive(:generate_to).with(dirname).and_call_original
38
+ expect(generator).to receive(:configure_for_creation).and_call_original
39
+ expect(generator).to receive(:prepare_dir).with(dirname).and_call_original
40
+ expect(generator).to receive(:create_sections).with(dirname).and_call_original
41
+ expect(generator).to receive(:create_readme).with(dirname).and_call_original
42
+ expect(generator).to receive(:create_assets).and_call_original
43
+ expect(generator.generate).to eq generator
44
+ end
45
+ end
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'pathname'
3
3
 
4
- RSpec.describe Betterdocs::Global do
4
+ describe Betterdocs::Global do
5
5
  let :rails do
6
6
  double(
7
7
  root: Pathname.pwd + 'spec/assets',
8
- env: double(development?: true)
8
+ env: double(development?: true)
9
9
  )
10
10
  end
11
11
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe Betterdocs::JsonParamsRepresenter do
3
+ describe Betterdocs::JsonParamsRepresenter do
4
4
  module MyJsonParams
5
5
  include Betterdocs::JsonParamsRepresenter
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe Betterdocs::ResultRepresenter do
3
+ describe Betterdocs::ResultRepresenter do
4
4
  module MySubRepresenter
5
5
  include Betterdocs::ResultRepresenter
6
6
 
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Betterdocs::Sanitizer do
4
+ let :sanitizer do
5
+ described_class.new do |text|
6
+ text.gsub('<evil>', '')
7
+ end
8
+ end
9
+
10
+ let :text do
11
+ '<foo><evil><bar>'
12
+ end
13
+
14
+ it 'removes evil tags from strings' do
15
+ expect(sanitizer.sanitize(text)).to eq '<foo><bar>'
16
+ end
17
+
18
+ it 'ignores other JSON data types' do
19
+ expect(sanitizer.sanitize(nil)).to eq nil
20
+ end
21
+
22
+ it 'calls #to_s on the remaining types and sanitizes' do
23
+ expect(sanitizer.sanitize(double(to_s: text))).to eq '<foo><bar>'
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe 'controller dsl' do
3
+ describe 'controller dsl' do
4
4
  let :docs do
5
5
  Betterdocs::ControllerCollector.new
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe 'representer dsl' do
3
+ describe 'representer dsl' do
4
4
  let :docs do
5
5
  Betterdocs::ResultRepresenterCollector.new
6
6
  end
@@ -152,7 +152,6 @@ EOT
152
152
  end
153
153
  end
154
154
 
155
-
156
155
  module Person
157
156
  include Betterdocs::ResultRepresenter
158
157
 
@@ -1,19 +1,17 @@
1
1
  require 'simplecov'
2
- require "codeclimate-test-reporter"
3
2
  if ENV['START_SIMPLECOV'].to_i == 1
4
3
  SimpleCov.start do
5
4
  add_filter "#{File.basename(File.dirname(__FILE__))}/"
6
5
  end
7
6
  end
8
- if ENV['CODECLIMATE_REPO_TOKEN']
9
- if ENV['START_SIMPLECOV']
10
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
11
- SimpleCov::Formatter::HTMLFormatter,
12
- CodeClimate::TestReporter::Formatter
13
- ]
14
- end
15
- CodeClimate::TestReporter.start
16
- end
17
7
  require 'rspec'
18
8
  require 'byebug'
19
9
  require 'betterdocs'
10
+
11
+ RSpec.configure do |c|
12
+ c.before do
13
+ ComplexConfig::Provider.config_dir = 'spec/assets/config'
14
+ Betterdocs::Global.configure
15
+ end
16
+ end
17
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterdocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-07 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -120,6 +120,34 @@ dependencies:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0.5'
123
+ - !ruby/object:Gem::Dependency
124
+ name: infobar
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: mize
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
123
151
  description: This library provides tools to generate API documention for a web site's
124
152
  REST-ful JSON API.
125
153
  email: developers@betterplace.org
@@ -158,6 +186,7 @@ extra_rdoc_files:
158
186
  - lib/betterdocs/representer.rb
159
187
  - lib/betterdocs/result_representer.rb
160
188
  - lib/betterdocs/result_representer_collector.rb
189
+ - lib/betterdocs/sanitizer.rb
161
190
  - lib/betterdocs/section.rb
162
191
  - lib/betterdocs/version.rb
163
192
  files:
@@ -205,18 +234,27 @@ files:
205
234
  - lib/betterdocs/representer.rb
206
235
  - lib/betterdocs/result_representer.rb
207
236
  - lib/betterdocs/result_representer_collector.rb
237
+ - lib/betterdocs/sanitizer.rb
208
238
  - lib/betterdocs/section.rb
209
239
  - lib/betterdocs/tasks/doc.rake
210
240
  - lib/betterdocs/version.rb
241
+ - spec/assets/app/assets/images/logos/logo.png
211
242
  - spec/assets/app/controllers/api/foos_controller.rb
243
+ - spec/assets/app/views/api_v4/documentation/assets/CHANGELOG.md
212
244
  - spec/assets/config/betterdocs.yml
245
+ - spec/betterdocs/dsl/controller/action/param_spec.rb
246
+ - spec/betterdocs/dsl/controller/action/response_spec.rb
247
+ - spec/betterdocs/dsl/json_type_mapper_spec.rb
248
+ - spec/betterdocs/dsl/result/collection_property_spec.rb
249
+ - spec/betterdocs/dsl/result/link_spec.rb
250
+ - spec/betterdocs/dsl/result/property_spec.rb
251
+ - spec/betterdocs/generator/markdown_spec.rb
252
+ - spec/betterdocs/global_spec.rb
253
+ - spec/betterdocs/json_params_representer_spec.rb
254
+ - spec/betterdocs/result_representer_spec.rb
255
+ - spec/betterdocs/sanitizer_spec.rb
213
256
  - spec/controller_dsl_spec.rb
214
- - spec/generator/markdown_spec.rb
215
- - spec/global_spec.rb
216
- - spec/json_params_representer_spec.rb
217
- - spec/json_type_mapper_spec.rb
218
257
  - spec/result_representer_dsl_spec.rb
219
- - spec/result_representer_spec.rb
220
258
  - spec/spec_helper.rb
221
259
  homepage: http://github.com/betterplace/betterdocs
222
260
  licenses: []
@@ -224,7 +262,7 @@ metadata: {}
224
262
  post_install_message:
225
263
  rdoc_options:
226
264
  - "--title"
227
- - 'Betterdocs -- '
265
+ - Betterdocs
228
266
  - "--main"
229
267
  - README.md
230
268
  require_paths:
@@ -241,17 +279,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
279
  version: '0'
242
280
  requirements: []
243
281
  rubyforge_project:
244
- rubygems_version: 2.6.8
282
+ rubygems_version: 2.6.10
245
283
  signing_key:
246
284
  specification_version: 4
247
285
  summary: Betterplace API documentation library
248
286
  test_files:
249
287
  - spec/assets/app/controllers/api/foos_controller.rb
288
+ - spec/betterdocs/dsl/controller/action/param_spec.rb
289
+ - spec/betterdocs/dsl/controller/action/response_spec.rb
290
+ - spec/betterdocs/dsl/json_type_mapper_spec.rb
291
+ - spec/betterdocs/dsl/result/collection_property_spec.rb
292
+ - spec/betterdocs/dsl/result/link_spec.rb
293
+ - spec/betterdocs/dsl/result/property_spec.rb
294
+ - spec/betterdocs/generator/markdown_spec.rb
295
+ - spec/betterdocs/global_spec.rb
296
+ - spec/betterdocs/json_params_representer_spec.rb
297
+ - spec/betterdocs/result_representer_spec.rb
298
+ - spec/betterdocs/sanitizer_spec.rb
250
299
  - spec/controller_dsl_spec.rb
251
- - spec/generator/markdown_spec.rb
252
- - spec/global_spec.rb
253
- - spec/json_params_representer_spec.rb
254
- - spec/json_type_mapper_spec.rb
255
300
  - spec/result_representer_dsl_spec.rb
256
- - spec/result_representer_spec.rb
257
301
  - spec/spec_helper.rb
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Betterdocs::Generator::Markdown do
4
- it "does all kinds of stuff correctly"
5
- end