brief 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brief/briefcase.rb +4 -0
- data/lib/brief/cli/parse.rb +50 -0
- data/lib/brief/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5def0728ed54389129584f946fb33161b8ab138
|
4
|
+
data.tar.gz: 1792a378fa94f8475ebd3f88dd0d5ec9963c5b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df431f1e995f94e3841ed9a6473df7a2e254eb7f0801006f07a123411270bc44a26c14f52eee78777696c66b7bc81e679035ade1f76d2914392566fa489e9d63
|
7
|
+
data.tar.gz: 3c522d5ad2aecbe1dd8dff0a84100cad1dff2190ef69a1e4bd1f79ca5873d597978783335fa6dd1a36e17ea3fcc290fda1d8909ae3ceb2f0187e4a4469e861d9
|
data/lib/brief/briefcase.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
command 'parse' do |c|
|
2
|
+
c.syntax = 'brief parse PATH [OPTIONS]'
|
3
|
+
c.description = 'parse the briefcase path'
|
4
|
+
|
5
|
+
c.option '--root PATH', String, 'The briefcase root'
|
6
|
+
c.option '--output PATH', String, 'Save the output to the specified path'
|
7
|
+
c.option '--app APP', String, 'Use the specified app to get our models etc'
|
8
|
+
c.option '--config PATH', String, 'Use the specified config file'
|
9
|
+
c.option '--type TYPE', String, 'Valid options: hash, array; Output as a hash keyed by path, or an array. Defaults to array.'
|
10
|
+
|
11
|
+
c.action do |args, options|
|
12
|
+
options.default(root: Pathname(Dir.pwd), type: "array")
|
13
|
+
|
14
|
+
o = {
|
15
|
+
root: options.root
|
16
|
+
}
|
17
|
+
|
18
|
+
o[:app] = options.app if options.app
|
19
|
+
o[:config_path] = options.config if options.config
|
20
|
+
|
21
|
+
briefcase = Brief::Briefcase.new(o)
|
22
|
+
|
23
|
+
parsed = if args.empty?
|
24
|
+
briefcase.all_models.map do |model|
|
25
|
+
model.as_json(content:true, rendered: true)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
args.map do |a|
|
29
|
+
Dir[briefcase.root.join(a)].map do |f|
|
30
|
+
doc = Brief::Document.new(f).in_briefcase(briefcase)
|
31
|
+
doc.to_model.as_json(content: true, rendered: true)
|
32
|
+
end
|
33
|
+
end.flatten
|
34
|
+
end
|
35
|
+
|
36
|
+
if options.type == "hash"
|
37
|
+
parsed = parsed.inject({}) do |memo, obj|
|
38
|
+
path = obj[:path]
|
39
|
+
memo[path] = obj
|
40
|
+
memo
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if options.output
|
45
|
+
Pathname(options.output).open("w+") {|fh| fh.write(parsed.to_json) }
|
46
|
+
else
|
47
|
+
puts parsed.to_json
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/brief/version.rb
CHANGED
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.8.
|
4
|
+
version: 1.8.4
|
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-03-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- lib/brief/cli/change.rb
|
261
261
|
- lib/brief/cli/export.rb
|
262
262
|
- lib/brief/cli/init.rb
|
263
|
+
- lib/brief/cli/parse.rb
|
263
264
|
- lib/brief/cli/write.rb
|
264
265
|
- lib/brief/configuration.rb
|
265
266
|
- lib/brief/core_ext.rb
|