brief 1.9.7 → 1.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -2
- data/lib/brief/briefcase.rb +15 -12
- data/lib/brief/cli/export.rb +52 -0
- data/lib/brief/cli/run.rb +9 -0
- data/lib/brief/cli/server.rb +16 -5
- data/lib/brief/document/section.rb +8 -0
- data/lib/brief/document.rb +3 -2
- data/lib/brief/repository.rb +3 -2
- data/lib/brief/server/gateway.rb +2 -0
- data/lib/brief/version.rb +1 -1
- data/spec/lib/brief/attachments_spec.rb +13 -3
- metadata +3 -3
- data/lib/brief/server/socket.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9d4f96cdfb13d6e754b942a4687f60e7d8888e
|
4
|
+
data.tar.gz: 59caee15c35018c1b1bfebcec9bc2c9455fdc41a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bddeba5d8229e39e3fb5e7d939ae57b2104862fd26d5d2f737404a965af4ba30bed1fa272937b2f814b793174fff0a082b6ab4c7bbb301d8726539628296acc
|
7
|
+
data.tar.gz: 48af2ae16f06cef85620f6fe59c9f184748e2ffadb529645900be9da06f36db071174d1cfe8f79abb33f6fa0bb56ac194433823a770631b51505cc6161b5cbf7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brief (1.9.
|
4
|
+
brief (1.9.8)
|
5
5
|
activesupport (~> 4.0)
|
6
6
|
commander (~> 4.3)
|
7
7
|
em-websocket (= 0.5.1)
|
@@ -12,7 +12,6 @@ PATH
|
|
12
12
|
hike (~> 2.1)
|
13
13
|
inflecto (~> 0)
|
14
14
|
nokogiri (= 1.6.5)
|
15
|
-
nokogiri (= 1.6.5)
|
16
15
|
thin (= 1.6.3)
|
17
16
|
virtus (~> 1.0)
|
18
17
|
|
data/lib/brief/briefcase.rb
CHANGED
@@ -21,6 +21,8 @@ module Brief
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def present(style="default", params={})
|
24
|
+
style = "default" if style.nil?
|
25
|
+
|
24
26
|
if respond_to?("as_#{style}")
|
25
27
|
send("as_#{style}", params)
|
26
28
|
elsif Brief.views.key?(style.to_sym)
|
@@ -53,10 +55,10 @@ module Brief
|
|
53
55
|
|
54
56
|
base = {
|
55
57
|
views: Brief.views.keys,
|
56
|
-
key:
|
57
|
-
name:
|
58
|
+
key: folder_name.to_s.parameterize,
|
59
|
+
name: folder_name.to_s.titlecase,
|
58
60
|
settings: settings,
|
59
|
-
cache_key:
|
61
|
+
cache_key: cache_key
|
60
62
|
}
|
61
63
|
|
62
64
|
if params[:include_data] || params[:data]
|
@@ -196,7 +198,7 @@ module Brief
|
|
196
198
|
end
|
197
199
|
|
198
200
|
def root
|
199
|
-
Pathname(options.fetch(:root) { Brief.pwd })
|
201
|
+
Pathname(options.fetch(:root) { Brief.pwd }).expand_path
|
200
202
|
end
|
201
203
|
|
202
204
|
def find_asset(needle)
|
@@ -205,7 +207,15 @@ module Brief
|
|
205
207
|
end
|
206
208
|
|
207
209
|
def assets_path
|
208
|
-
root.join
|
210
|
+
root.join(options.fetch(:assets_path) { config.assets_path }).expand_path
|
211
|
+
end
|
212
|
+
|
213
|
+
def docs_path
|
214
|
+
root.join(options.fetch(:docs_path) { config.docs_path }).expand_path
|
215
|
+
end
|
216
|
+
|
217
|
+
def data_path
|
218
|
+
root.join(options.fetch(:data_path) { config.data_path }).expand_path
|
209
219
|
end
|
210
220
|
|
211
221
|
def assets_trail
|
@@ -222,13 +232,6 @@ module Brief
|
|
222
232
|
end
|
223
233
|
end
|
224
234
|
|
225
|
-
def docs_path
|
226
|
-
root.join options.fetch(:docs_path) { config.docs_path }
|
227
|
-
end
|
228
|
-
|
229
|
-
def data_path
|
230
|
-
root.join options.fetch(:data_path) { config.data_path }
|
231
|
-
end
|
232
235
|
|
233
236
|
def data_trail
|
234
237
|
@docs_trail ||= Hike::Trail.new(data_path).tap do |trail|
|
data/lib/brief/cli/export.rb
CHANGED
@@ -1,3 +1,55 @@
|
|
1
|
+
command 'dispatch export' do |c|
|
2
|
+
c.syntax = 'brief dispatch export PATH [OPTIONS]'
|
3
|
+
c.description = 'dispatch the export the briefcase found in PATH'
|
4
|
+
|
5
|
+
c.option '--presenter-format FORMAT', String, 'Which presenter to use?'
|
6
|
+
c.option '--include-schema', 'Include schema information'
|
7
|
+
c.option '--include-models', 'Include individual models as well'
|
8
|
+
c.option '--include-data', 'Gets passed to the model renderers if present'
|
9
|
+
c.option '--include-content', 'Gets passed to the model renderers if present'
|
10
|
+
c.option '--include-rendered', 'Gets passed to the model renderers if present'
|
11
|
+
c.option '--include-attachments', 'Gets passed to the model renderers if present'
|
12
|
+
c.option '--include-urls', 'Gets passed to the model renderers if present'
|
13
|
+
c.option '--gateway', 'The remote server is a gateway'
|
14
|
+
c.option '--port DRB_PORT', String, 'The DRb port to use'
|
15
|
+
c.option '--briefcase KEY', String, 'Which briefcase should we use? if this is a gateway'
|
16
|
+
c.option '--output FILE', String, 'Save the output in the specified path'
|
17
|
+
c.option '--format FORMAT', String, 'How to format the CLI output: defaults to printed, accepts printed,json'
|
18
|
+
c.option '--prefix-output CONTENT', String, 'Prefix the generated output with the following content'
|
19
|
+
|
20
|
+
c.when_called do |args, options|
|
21
|
+
require 'drb'
|
22
|
+
options.default(:port => 9000, briefcase: Pathname(Brief.pwd).dirname.to_s)
|
23
|
+
|
24
|
+
remote = DRbObject.new(nil, "druby://:#{ options.port }")
|
25
|
+
|
26
|
+
if options.gateway
|
27
|
+
remote = remote.briefcases[options.briefcase]
|
28
|
+
end
|
29
|
+
|
30
|
+
result = remote.present(options.presenter_format, rendered: options.include_rendered,
|
31
|
+
content: options.include_content,
|
32
|
+
urls: options.include_urls,
|
33
|
+
schema: options.include_schema,
|
34
|
+
data: options.include_data,
|
35
|
+
attachments: options.include_attachments,
|
36
|
+
models: options.include_models).as_json
|
37
|
+
|
38
|
+
case
|
39
|
+
when options.output && options.format.to_sym == :json
|
40
|
+
Pathname(options.output).open("w+") do |fh|
|
41
|
+
fh.write("#{options.prefix_output}#{result.to_json}")
|
42
|
+
end
|
43
|
+
when options.format.to_sym == :json
|
44
|
+
puts "#{options.prefix_output}#{result.to_json}"
|
45
|
+
when options.format.to_sym == :printed
|
46
|
+
puts result
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
1
53
|
command 'export' do |c|
|
2
54
|
c.syntax = 'brief export PATH [OPTIONS]'
|
3
55
|
c.description = 'export the briefcase found in PATH'
|
data/lib/brief/cli/server.rb
CHANGED
@@ -12,16 +12,27 @@ command 'start gateway server' do |c|
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
command 'start
|
15
|
+
command 'start drb server' do |c|
|
16
16
|
c.option '--host HOSTNAME', String, 'What hostname to listen on'
|
17
17
|
c.option '--port PORT', String, 'What port to listen on'
|
18
|
+
c.option '--gateway', 'Create a gateway instead of a briefcase'
|
18
19
|
|
19
20
|
c.action do |args, options|
|
20
21
|
options.default(root: Brief.pwd)
|
21
22
|
|
22
|
-
require '
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
require 'drb'
|
24
|
+
|
25
|
+
root = Pathname(options.root)
|
26
|
+
|
27
|
+
object = if options.gateway
|
28
|
+
Brief::Server::Distributed.new(root: root, briefcase_options: {eager: true})
|
29
|
+
else
|
30
|
+
Brief::Briefcase.new(root: root, eager: true)
|
31
|
+
end
|
32
|
+
|
33
|
+
puts "== starting distributed service"
|
34
|
+
DRb.start_service "druby://:#{ options.port || 9000 }", object
|
35
|
+
trap("INT") { DRb.stop_service }
|
36
|
+
DRb.thread.join()
|
26
37
|
end
|
27
38
|
end
|
data/lib/brief/document.rb
CHANGED
@@ -127,7 +127,7 @@ module Brief
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def briefcase
|
130
|
-
(@briefcase_root && Brief.cases[@briefcase_root]) || Brief.case
|
130
|
+
(@briefcase_root && Brief.cases[@briefcase_root]) || Brief.case(true)
|
131
131
|
end
|
132
132
|
|
133
133
|
def has_sections?
|
@@ -265,7 +265,8 @@ module Brief
|
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
-
def respond_to?(
|
268
|
+
def respond_to?(*args)
|
269
|
+
method = args.first
|
269
270
|
super || (data && data.respond_to?(method)) || (data && data.key?(method))
|
270
271
|
end
|
271
272
|
|
data/lib/brief/repository.rb
CHANGED
@@ -13,14 +13,15 @@ module Brief
|
|
13
13
|
@briefcase = briefcase
|
14
14
|
@options = options
|
15
15
|
|
16
|
-
load_documents
|
16
|
+
load_documents if options[:eager]
|
17
17
|
end
|
18
18
|
|
19
19
|
def cache_key
|
20
20
|
"#{documents.count}-#{documents.map {|d| d.path.mtime.to_i }.max}"
|
21
21
|
end
|
22
22
|
|
23
|
-
def respond_to?(
|
23
|
+
def respond_to?(*args)
|
24
|
+
meth = args.first
|
24
25
|
super || model_groups.include?(meth.to_s)
|
25
26
|
end
|
26
27
|
|
data/lib/brief/server/gateway.rb
CHANGED
data/lib/brief/version.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "Rendering Attachments" do
|
4
|
-
let(:
|
4
|
+
let(:release) { Brief.testcase.releases.first }
|
5
|
+
let(:doc) { release.document }
|
5
6
|
|
6
|
-
it "
|
7
|
-
expect(doc
|
7
|
+
it "detects attachments" do
|
8
|
+
expect(doc).to be_has_attachments
|
9
|
+
end
|
10
|
+
|
11
|
+
it "makes attachments content available" do
|
12
|
+
expect(doc.render_attachments).not_to be_empty
|
13
|
+
end
|
14
|
+
|
15
|
+
it "optionally makes attachments available in the model serializer" do
|
16
|
+
expect(release.as_json()).not_to have_key(:attachments)
|
17
|
+
expect(release.as_json(attachments: true)[:attachments]).not_to be_empty
|
8
18
|
end
|
9
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brief
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Soeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -319,6 +319,7 @@ files:
|
|
319
319
|
- lib/brief/cli/export.rb
|
320
320
|
- lib/brief/cli/parse.rb
|
321
321
|
- lib/brief/cli/render.rb
|
322
|
+
- lib/brief/cli/run.rb
|
322
323
|
- lib/brief/cli/schema.rb
|
323
324
|
- lib/brief/cli/server.rb
|
324
325
|
- lib/brief/cli/write.rb
|
@@ -352,7 +353,6 @@ files:
|
|
352
353
|
- lib/brief/server/handlers/schema.rb
|
353
354
|
- lib/brief/server/handlers/show.rb
|
354
355
|
- lib/brief/server/route.rb
|
355
|
-
- lib/brief/server/socket.rb
|
356
356
|
- lib/brief/util.rb
|
357
357
|
- lib/brief/version.rb
|
358
358
|
- packaging/wrapper.sh
|
data/lib/brief/server/socket.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
class Brief::Server::Socket
|
2
|
-
def self.start(options={}, &block)
|
3
|
-
require 'em-websocket' unless defined?(EM::WebSocket)
|
4
|
-
|
5
|
-
host = options.fetch(:host, '0.0.0.0')
|
6
|
-
host = options.fetch(:port, '8023')
|
7
|
-
|
8
|
-
gateway = Brief::Server::Gateway.new(options)
|
9
|
-
|
10
|
-
socket = new(gateway: gateway)
|
11
|
-
|
12
|
-
EM.run {
|
13
|
-
socket.start
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :gateway,
|
18
|
-
:options,
|
19
|
-
:host,
|
20
|
-
:port
|
21
|
-
|
22
|
-
def initialize(options={})
|
23
|
-
@options = options
|
24
|
-
@gateway = gateway
|
25
|
-
@host = options.fetch(:host, '0.0.0.0')
|
26
|
-
@port = options.fetch(:port, 9099)
|
27
|
-
end
|
28
|
-
|
29
|
-
def log(message)
|
30
|
-
if options[:log_to_console]
|
31
|
-
puts(message)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def start
|
36
|
-
log "Starting socket gateway: #{port} host: #{ host }"
|
37
|
-
EM::WebSocket.run(:host => host, :port => port) do |ws|
|
38
|
-
ws.onopen do |handshake|
|
39
|
-
log("== Brief client connected")
|
40
|
-
log(handshake.inspect)
|
41
|
-
end
|
42
|
-
|
43
|
-
ws.onclose do
|
44
|
-
log("brief Connection closed")
|
45
|
-
end
|
46
|
-
|
47
|
-
ws.onmessage do |data|
|
48
|
-
message = OpenStruct.new(JSON.parse(data))
|
49
|
-
log "== Websocket Command: #{ message }"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|