rasti-web-api_doc 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 18e4f3e36ab7fafa94ed98bc51f2ecd2bd42ac62
4
- data.tar.gz: 22ff7c3a9a03b00a92ad655e1cd8c646d521af85
2
+ SHA256:
3
+ metadata.gz: f2918bc3d975edbbf5fc8ed202d501748a944426ea11a30ae013ef6a9a2d961d
4
+ data.tar.gz: 989e07a070c1140e02356fc9f124e24ee4346d379b23a53482b4368242696963
5
5
  SHA512:
6
- metadata.gz: 93d9e7b53dadbca34abc5ed5723e78adf2bac5694998eb14717d990b78dd7fa16a230200f7bb5e78544b8160a0586513c4c8ff05a17a5c54f09304191804f514
7
- data.tar.gz: a7252d3080118aed1904edf2002a2e3ed2f4526af05887f97c943885a01e6614fd98798c5f96933bd3476c501a452777214f9eace5ff726dfd08becfc6b67584
6
+ metadata.gz: c05140e0b79fd99903b5f130c2d40dce228ee3dc03d5c04bbb65125ab33ef886e7f9283c7a87d78d3bfbc25881f5ebb1f790151d069469d18ca50fff676f5089
7
+ data.tar.gz: 70c5dc918ad9af7f6e9b671472e3a6215dcdae74ea66de6c3a52563dafe79cd8932d54327e865d1f967d72bc1914896940b2e2ac1adf6b82222c1744593aaf93
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby 2.0
1
+ ruby-2.5.0
@@ -1,4 +1,4 @@
1
- require 'colorize'
1
+ require 'colorin'
2
2
  require 'stringio'
3
3
  require 'rake'
4
4
  require 'rake/tasklib'
@@ -36,9 +36,10 @@ module Rasti
36
36
  end
37
37
 
38
38
  def headers
39
- {}.tap do |hash|
40
- hash['Content-Type'] = env['CONTENT_TYPE'] if env['CONTENT_TYPE']
41
- end
39
+ headers = env.select { |k,v| k.start_with?('HTTP_') || k == 'CONTENT_TYPE' }
40
+ .map { |k,v| [k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-'), v] }
41
+ .sort
42
+ Hash[headers]
42
43
  end
43
44
 
44
45
  private
@@ -28,22 +28,28 @@ module Rasti
28
28
 
29
29
  Rasti::Web::ApiDoc.tracker = Tracker.new application.all_routes
30
30
 
31
- # Hide test runner output
32
- $stdout = StringIO.new
33
- $stderr = StringIO.new
31
+ disable_test_runner_output
34
32
 
35
33
  at_exit do
36
34
  write_file
37
35
  print_summary
38
36
  end
39
37
 
40
- # Run all tests
41
- STDOUT.puts 'Building documentation'
42
- $LOAD_PATH.unshift path
43
- Dir.glob(File.expand_path(pattern)).each { |f| require f }
38
+ run_all_tests
44
39
  end
45
40
  end
46
41
 
42
+ def disable_test_runner_output
43
+ $stdout = StringIO.new
44
+ $stderr = StringIO.new
45
+ end
46
+
47
+ def run_all_tests
48
+ STDOUT.puts 'Building documentation'
49
+ $LOAD_PATH.unshift path
50
+ Dir.glob(File.expand_path(pattern)).each { |f| require f }
51
+ end
52
+
47
53
  def write_file
48
54
  File.open(File.expand_path(output), 'w') do |f|
49
55
  f.puts '# **Endpoints**'
@@ -96,15 +102,16 @@ module Rasti
96
102
  STDOUT.puts "\nPending endpoints" unless summary[:pending_list].empty?
97
103
  summary[:pending_list].each do |method, routes|
98
104
  routes.each do |route|
99
- STDOUT.puts " #{method} #{route}".red
105
+ STDOUT.puts " #{Colorin.amber_300(method.ljust(6, ' ')).bold} #{route}"
100
106
  end
101
107
  end
102
108
 
103
109
  STDOUT.puts
104
- STDOUT.print "#{summary[:endpoints]} endpoints, "
105
- STDOUT.print "#{summary[:documented]} documented".colorize(summary[:documented] == 0 ? :white : :green)
110
+ STDOUT.print Colorin.blue_a700("#{summary[:endpoints]} endpoints")
111
+ STDOUT.print ", "
112
+ STDOUT.print Colorin.green_500("#{summary[:documented]} documented")
106
113
  STDOUT.print ", "
107
- STDOUT.puts "#{summary[:pending]} pending".colorize(summary[:pending] == 0 ? :white : :red)
114
+ STDOUT.puts Colorin.amber_300("#{summary[:pending]} pending")
108
115
  end
109
116
 
110
117
  end
@@ -5,9 +5,9 @@ module Rasti
5
5
 
6
6
  attr_reader :tracks
7
7
 
8
- def initialize(routes)
8
+ def initialize(routes_by_method)
9
9
  @tracks = Hash.new { |h,k| h[k] = {} }
10
- routes.each do |method, routes|
10
+ routes_by_method.each do |method, routes|
11
11
  routes.each do |route|
12
12
  tracks[method][route] = nil
13
13
  end
@@ -19,7 +19,7 @@ module Rasti
19
19
  res = Rasti::Web::ApiDoc::Response.new(*response)
20
20
 
21
21
  if !tracks[req.method][req.route]
22
- STDOUT.puts " #{req.method} #{req.route}".green
22
+ STDOUT.puts " #{Colorin.green_500(req.method.ljust(6, ' ')).bold} #{req.route}"
23
23
  tracks[req.method][req.route] = [req, res]
24
24
  end
25
25
  end
@@ -32,7 +32,7 @@ module Rasti
32
32
  {
33
33
  endpoints: endpoints,
34
34
  documented: documented,
35
- pending: pending.count,
35
+ pending: pending.values.map(&:count).sum,
36
36
  pending_list: pending
37
37
  }
38
38
  end
@@ -1,7 +1,7 @@
1
1
  module Rasti
2
2
  module Web
3
3
  module ApiDoc
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
+ spec.add_dependency 'colorin', '~> 2.0'
22
23
  spec.add_dependency 'rasti-web'
23
- spec.add_dependency 'colorize', '~> 0.7'
24
- spec.add_dependency 'rake', '~> 10.0'
25
- spec.add_dependency 'rack-test', '~> 0.6'
24
+ spec.add_dependency 'rake'
25
+ spec.add_dependency 'rack-test'
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 1.11'
28
28
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-web-api_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-19 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rasti-web
14
+ name: colorin
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: colorize
28
+ name: rasti-web
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.7'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.7'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.6'
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0.6'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.11'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.11'
83
83
  description: Generate documentation of endpoint usage based on tests
@@ -87,15 +87,13 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .ruby-gemset
92
- - .ruby-version
90
+ - ".gitignore"
91
+ - ".ruby-gemset"
92
+ - ".ruby-version"
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
96
96
  - Rakefile
97
- - bin/console
98
- - bin/setup
99
97
  - lib/rasti/web/api_doc.rb
100
98
  - lib/rasti/web/api_doc/request.rb
101
99
  - lib/rasti/web/api_doc/response.rb
@@ -113,17 +111,17 @@ require_paths:
113
111
  - lib
114
112
  required_ruby_version: !ruby/object:Gem::Requirement
115
113
  requirements:
116
- - - '>='
114
+ - - ">="
117
115
  - !ruby/object:Gem::Version
118
116
  version: '0'
119
117
  required_rubygems_version: !ruby/object:Gem::Requirement
120
118
  requirements:
121
- - - '>='
119
+ - - ">="
122
120
  - !ruby/object:Gem::Version
123
121
  version: '0'
124
122
  requirements: []
125
123
  rubyforge_project:
126
- rubygems_version: 2.4.8
124
+ rubygems_version: 2.7.3
127
125
  signing_key:
128
126
  specification_version: 4
129
127
  summary: Generate documentation of endpoint usage based on tests
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "rasti/web/api_doc"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here