doc_repo 0.1.1 → 1.0.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +4 -4
- data/CHANGELOG.md +47 -0
- data/Gemfile +5 -0
- data/README.md +282 -16
- data/benchmarks/digests.rb +55 -0
- data/doc_repo.gemspec +5 -5
- data/lib/doc_repo/configuration.rb +65 -4
- data/lib/doc_repo/doc.rb +84 -0
- data/lib/doc_repo/error.rb +14 -0
- data/lib/doc_repo/gateway_error.rb +37 -0
- data/lib/doc_repo/http_error.rb +32 -0
- data/lib/doc_repo/http_result.rb +29 -0
- data/lib/doc_repo/net_http_adapter.rb +203 -0
- data/lib/doc_repo/rails/legacy_versioned_cache.rb +19 -0
- data/lib/doc_repo/rails.rb +37 -0
- data/lib/doc_repo/redirect.rb +19 -0
- data/lib/doc_repo/repository.rb +72 -20
- data/lib/doc_repo/result_handler.rb +30 -0
- data/lib/doc_repo/version.rb +1 -1
- data/lib/doc_repo.rb +20 -17
- data/spec/doc_repo/configuration_spec.rb +86 -31
- data/spec/doc_repo/doc_spec.rb +442 -0
- data/spec/doc_repo/net_http_adapter_spec.rb +435 -0
- data/spec/doc_repo/repository_spec.rb +325 -13
- data/spec/doc_repo/result_handler_spec.rb +43 -0
- data/spec/doc_repo_spec.rb +25 -3
- data/spec/spec_helper.rb +88 -3
- data/spec/support/in_memory_cache.rb +33 -0
- metadata +33 -20
- data/lib/doc_repo/github_file.rb +0 -45
- data/lib/doc_repo/page.rb +0 -35
- data/lib/doc_repo/response.rb +0 -25
- data/spec/doc_repo/page_spec.rb +0 -44
- data/spec/doc_repo/response_spec.rb +0 -19
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doc_repo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Sexton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rouge
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
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: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: redcarpet
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,42 +58,42 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12.0'
|
62
62
|
type: :development
|
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: '
|
68
|
+
version: '12.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.6'
|
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
|
-
version: '3.
|
82
|
+
version: '3.6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.0'
|
97
97
|
description: 'Doc Repo: Load in app documentation via an external Github repo'
|
98
98
|
email:
|
99
99
|
- github@codeography.com
|
@@ -104,25 +104,36 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
107
108
|
- Gemfile
|
108
109
|
- LICENSE.txt
|
109
110
|
- README.md
|
110
111
|
- Rakefile
|
112
|
+
- benchmarks/digests.rb
|
111
113
|
- doc_repo.gemspec
|
112
114
|
- lib/doc_repo.rb
|
113
115
|
- lib/doc_repo/configuration.rb
|
114
116
|
- lib/doc_repo/converters/markdown_parser.rb
|
115
|
-
- lib/doc_repo/
|
116
|
-
- lib/doc_repo/
|
117
|
+
- lib/doc_repo/doc.rb
|
118
|
+
- lib/doc_repo/error.rb
|
119
|
+
- lib/doc_repo/gateway_error.rb
|
120
|
+
- lib/doc_repo/http_error.rb
|
121
|
+
- lib/doc_repo/http_result.rb
|
122
|
+
- lib/doc_repo/net_http_adapter.rb
|
123
|
+
- lib/doc_repo/rails.rb
|
124
|
+
- lib/doc_repo/rails/legacy_versioned_cache.rb
|
125
|
+
- lib/doc_repo/redirect.rb
|
117
126
|
- lib/doc_repo/repository.rb
|
118
|
-
- lib/doc_repo/
|
127
|
+
- lib/doc_repo/result_handler.rb
|
119
128
|
- lib/doc_repo/version.rb
|
120
129
|
- spec/doc_repo/configuration_spec.rb
|
121
|
-
- spec/doc_repo/
|
130
|
+
- spec/doc_repo/doc_spec.rb
|
131
|
+
- spec/doc_repo/net_http_adapter_spec.rb
|
122
132
|
- spec/doc_repo/repository_spec.rb
|
123
|
-
- spec/doc_repo/
|
133
|
+
- spec/doc_repo/result_handler_spec.rb
|
124
134
|
- spec/doc_repo_spec.rb
|
125
135
|
- spec/spec_helper.rb
|
136
|
+
- spec/support/in_memory_cache.rb
|
126
137
|
- spec/support/string.rb
|
127
138
|
- spec/support/using_env.rb
|
128
139
|
homepage: https://github.com/RadiusNetworks/doc_repo
|
@@ -137,12 +148,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
148
|
requirements:
|
138
149
|
- - "~>"
|
139
150
|
- !ruby/object:Gem::Version
|
140
|
-
version: '2.
|
151
|
+
version: '2.3'
|
141
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
153
|
requirements:
|
143
|
-
- - "
|
154
|
+
- - ">"
|
144
155
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
156
|
+
version: 1.3.1
|
146
157
|
requirements: []
|
147
158
|
rubyforge_project:
|
148
159
|
rubygems_version: 2.6.11
|
@@ -151,10 +162,12 @@ specification_version: 4
|
|
151
162
|
summary: 'Doc Repo: Load in app documentation via an external Github repo'
|
152
163
|
test_files:
|
153
164
|
- spec/doc_repo/configuration_spec.rb
|
154
|
-
- spec/doc_repo/
|
165
|
+
- spec/doc_repo/doc_spec.rb
|
166
|
+
- spec/doc_repo/net_http_adapter_spec.rb
|
155
167
|
- spec/doc_repo/repository_spec.rb
|
156
|
-
- spec/doc_repo/
|
168
|
+
- spec/doc_repo/result_handler_spec.rb
|
157
169
|
- spec/doc_repo_spec.rb
|
158
170
|
- spec/spec_helper.rb
|
171
|
+
- spec/support/in_memory_cache.rb
|
159
172
|
- spec/support/string.rb
|
160
173
|
- spec/support/using_env.rb
|
data/lib/doc_repo/github_file.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
|
-
module DocRepo
|
4
|
-
class GithubFile
|
5
|
-
|
6
|
-
attr_reader :org, :repo, :branch, :file, :raw_url
|
7
|
-
def initialize(file,
|
8
|
-
org: DocRepo.configuration.org,
|
9
|
-
repo: DocRepo.configuration.repo,
|
10
|
-
branch: DocRepo.configuration.branch)
|
11
|
-
@file = file
|
12
|
-
@org = org
|
13
|
-
@repo = repo
|
14
|
-
@branch = branch
|
15
|
-
@raw_url = url(file)
|
16
|
-
end
|
17
|
-
|
18
|
-
alias_method :redirect_url, :raw_url
|
19
|
-
|
20
|
-
def read_remote_file
|
21
|
-
open(raw_url, headers).read
|
22
|
-
rescue OpenURI::HTTPError => http_error
|
23
|
-
raise DocRepo::NotFound.new(base: http_error)
|
24
|
-
end
|
25
|
-
|
26
|
-
def headers
|
27
|
-
hash = {
|
28
|
-
"Accept" => "application/vnd.github.v3.raw",
|
29
|
-
"User-Agent" => "RadiusNetworks-ProximityKit",
|
30
|
-
}
|
31
|
-
|
32
|
-
if ENV["GITHUB_TOKEN"]
|
33
|
-
hash["Authorization"] = "token #{ENV["GITHUB_TOKEN"]}"
|
34
|
-
end
|
35
|
-
|
36
|
-
hash
|
37
|
-
end
|
38
|
-
|
39
|
-
def url(file)
|
40
|
-
"https://raw.githubusercontent.com/#{org}/#{repo}/#{branch}/docs/#{file}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
data/lib/doc_repo/page.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require "doc_repo/converters/markdown_parser"
|
2
|
-
|
3
|
-
module DocRepo
|
4
|
-
class Page
|
5
|
-
attr_accessor :body
|
6
|
-
|
7
|
-
def initialize(file)
|
8
|
-
@body = GithubFile.new(default_ext(file)).read_remote_file
|
9
|
-
end
|
10
|
-
|
11
|
-
def default_ext(file)
|
12
|
-
if File.extname(file).empty?
|
13
|
-
"#{file}.md"
|
14
|
-
else
|
15
|
-
file
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_html
|
20
|
-
Converters::MarkdownParser.new(
|
21
|
-
extensions: %i[
|
22
|
-
no_intra_emphasis
|
23
|
-
tables
|
24
|
-
fenced_code_blocks
|
25
|
-
autolink
|
26
|
-
strikethrough
|
27
|
-
lax_spacing
|
28
|
-
superscript
|
29
|
-
with_toc_data
|
30
|
-
]
|
31
|
-
).convert(body)
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
data/lib/doc_repo/response.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module DocRepo
|
2
|
-
class Response
|
3
|
-
attr_reader :type, :params
|
4
|
-
def initialize(type, params)
|
5
|
-
@type = type ; @params = params
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.html(*params)
|
9
|
-
self.new :html, params
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.redirect(*params)
|
13
|
-
self.new :redirect, params
|
14
|
-
end
|
15
|
-
|
16
|
-
def html
|
17
|
-
yield(*params) if type == :html
|
18
|
-
end
|
19
|
-
|
20
|
-
def redirect
|
21
|
-
yield(*params) if type == :redirect
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
data/spec/doc_repo/page_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'support/string'
|
2
|
-
require 'webmock/rspec'
|
3
|
-
|
4
|
-
RSpec.describe DocRepo::Page do
|
5
|
-
before do
|
6
|
-
DocRepo.configure do |c|
|
7
|
-
c.org = 'RadiusNetworks'
|
8
|
-
c.repo = 'doc_spec'
|
9
|
-
c.branch = 'master'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:body){
|
14
|
-
<<-END.strip_heredoc
|
15
|
-
# A heading
|
16
|
-
|
17
|
-
Some content
|
18
|
-
END
|
19
|
-
}
|
20
|
-
|
21
|
-
let(:rendered_html){
|
22
|
-
<<-END.strip_heredoc
|
23
|
-
<h1 id=\"a-heading\">A heading</h1>
|
24
|
-
|
25
|
-
<p>Some content</p>
|
26
|
-
END
|
27
|
-
}
|
28
|
-
|
29
|
-
it "returns the markdown as html when there is no extension" do
|
30
|
-
stub_request(:get, "https://raw.githubusercontent.com/RadiusNetworks/doc_spec/master/docs/page.md")
|
31
|
-
.to_return(body: body)
|
32
|
-
|
33
|
-
page = DocRepo::Page.new("page")
|
34
|
-
expect(page.to_html).to eq rendered_html
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns the markdown as html when there is a .md extension" do
|
38
|
-
stub_request(:get, "https://raw.githubusercontent.com/RadiusNetworks/doc_spec/master/docs/page.md")
|
39
|
-
.to_return(body: body)
|
40
|
-
|
41
|
-
page = DocRepo::Page.new("page.md")
|
42
|
-
expect(page.to_html).to eq rendered_html
|
43
|
-
end
|
44
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe DocRepo::Page do
|
4
|
-
it "calls html block with 1 param" do
|
5
|
-
resp = DocRepo::Response.html 1
|
6
|
-
expect { |b| resp.html(&b) }.to yield_with_args(1)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "calls html block with 2 params" do
|
10
|
-
resp = DocRepo::Response.html 1, 2
|
11
|
-
expect { |b| resp.html(&b) }.to yield_with_args(1, 2)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "calls file block with 1 param" do
|
15
|
-
resp = DocRepo::Response.html "/path/to/file"
|
16
|
-
expect { |b| resp.html(&b) }.to yield_with_args("/path/to/file")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|