brief 1.9.7 → 1.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 983069845db550df399f38eaba6b784c2dcb05ac
4
- data.tar.gz: 9d42901a7a21ba82dcf6e54d24cc7c2d03ed4e19
3
+ metadata.gz: 6e9d4f96cdfb13d6e754b942a4687f60e7d8888e
4
+ data.tar.gz: 59caee15c35018c1b1bfebcec9bc2c9455fdc41a
5
5
  SHA512:
6
- metadata.gz: 881959cd3db5dfcd955669a1a70bbb16bdfcd9f8ef1dc2db58ec0e621af7f337be8d8eaf2374d125383c97c62912030df5c1e56625ac88e24c431912aada1125
7
- data.tar.gz: 0b4fec2df6686cdd302f9e5460996c54f3b2d3a8e67da30603c4eb93bd4f389651165cf9358b8211dca377c00fcc8a10682d67fc2eb64945fee6749115054506
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.6)
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
 
@@ -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: briefcase.folder_name.to_s.parameterize,
57
- name: briefcase.folder_name.to_s.titlecase,
58
+ key: folder_name.to_s.parameterize,
59
+ name: folder_name.to_s.titlecase,
58
60
  settings: settings,
59
- cache_key: briefcase.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 options.fetch(:assets_path) { config.assets_path }
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|
@@ -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'
@@ -0,0 +1,9 @@
1
+ command "run" do |c|
2
+ c.syntax = 'brief run FILE'
3
+ c.description = 'run a script in the context of the briefcase'
4
+
5
+ c.action do |args, options|
6
+ code = Pathname(args.first).read
7
+ Brief.case.instance_eval(code)
8
+ end
9
+ end
@@ -12,16 +12,27 @@ command 'start gateway server' do |c|
12
12
  end
13
13
  end
14
14
 
15
- command 'start socket gateway' do |c|
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 'em-websocket'
23
- require 'brief/server/gateway'
24
- require 'brief/server/socket'
25
- Brief::Server::Socket.start(port: options.port, host: options.host, root: Pathname(options.root))
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
@@ -10,6 +10,14 @@ class Brief::Document::Section
10
10
  @config = config
11
11
  end
12
12
 
13
+ def to_html
14
+ fragment.to_html
15
+ end
16
+
17
+ def text
18
+ fragment.text
19
+ end
20
+
13
21
  def items
14
22
  return @items if @items
15
23
 
@@ -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?(method)
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
 
@@ -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?(meth)
23
+ def respond_to?(*args)
24
+ meth = args.first
24
25
  super || model_groups.include?(meth.to_s)
25
26
  end
26
27
 
@@ -8,6 +8,8 @@ class Brief::Server::Gateway
8
8
  Rack::Handler::Thin.run(app, Port: port, Host: host)
9
9
  end
10
10
 
11
+ attr_reader :briefcases
12
+
11
13
  def initialize(options={})
12
14
  @root = options.fetch(:root)
13
15
  @briefcases = {}.to_mash
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.9.7'
2
+ VERSION = '1.9.8'
3
3
  end
@@ -1,9 +1,19 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "Rendering Attachments" do
4
- let(:doc) { Brief.testcase.releases.first }
4
+ let(:release) { Brief.testcase.releases.first }
5
+ let(:doc) { release.document }
5
6
 
6
- it "should include attachments in the serialized version" do
7
- expect(doc.render_attachments['test.svg']).not_to be_empty
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.7
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-01 00:00:00.000000000 Z
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
@@ -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