brief 1.8.11 → 1.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile.lock +1 -6
- data/README.md +2 -0
- data/apps/blueprint/config.rb +7 -0
- data/brief.gemspec +1 -1
- data/lib/brief/briefcase.rb +1 -9
- data/lib/brief/cli/01_extensions.rb +13 -0
- data/lib/brief/cli/write.rb +22 -12
- data/lib/brief/document.rb +17 -0
- data/lib/brief/model/serializers.rb +7 -0
- data/lib/brief/version.rb +1 -1
- data/spec/fixtures/example/brief.rb +5 -0
- data/spec/fixtures/example/docs/concept.html.md +10 -0
- data/spec/lib/brief/document_spec.rb +12 -0
- data/spec/lib/brief/repository_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -0
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c387f19c8ad49a0779cebe811c4bf7036400381
|
4
|
+
data.tar.gz: 60106d90ac046020fa178b28881ea88af8e672ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0f50b0dc77533e07e03b15e644e117856aba281fdf272a0d947175a59b2170162785c8eac04345cf528a8e0b0776839cd65dd7f851f3e018cafb45cbda4904
|
7
|
+
data.tar.gz: 7451362423fef638486fb758d03ca6818e6d82f8d291b29fa8ace319e192955ac1cd3de14d029db3c0a7e44956c4a68d703212fb748f07584721244973eedf6c
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brief (1.8.
|
5
|
-
activemodel
|
4
|
+
brief (1.8.12)
|
6
5
|
activesupport (>= 4.0)
|
7
6
|
commander (>= 4.2.1)
|
8
7
|
github-fs
|
@@ -15,9 +14,6 @@ PATH
|
|
15
14
|
GEM
|
16
15
|
remote: https://rubygems.org/
|
17
16
|
specs:
|
18
|
-
activemodel (4.2.1)
|
19
|
-
activesupport (= 4.2.1)
|
20
|
-
builder (~> 3.1)
|
21
17
|
activesupport (4.2.1)
|
22
18
|
i18n (~> 0.7)
|
23
19
|
json (~> 1.7, >= 1.7.7)
|
@@ -29,7 +25,6 @@ GEM
|
|
29
25
|
descendants_tracker (~> 0.0.4)
|
30
26
|
ice_nine (~> 0.11.0)
|
31
27
|
thread_safe (~> 0.3, >= 0.3.1)
|
32
|
-
builder (3.2.2)
|
33
28
|
coderay (1.1.0)
|
34
29
|
coercible (1.0.0)
|
35
30
|
descendants_tracker (~> 0.0.1)
|
data/README.md
CHANGED
data/apps/blueprint/config.rb
CHANGED
data/brief.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'github-fs'
|
24
24
|
spec.add_dependency 'virtus', '>= 1.0.3'
|
25
25
|
spec.add_dependency 'inflecto'
|
26
|
-
spec.add_dependency 'activemodel'
|
26
|
+
#spec.add_dependency 'activemodel'
|
27
27
|
spec.add_dependency 'activesupport', '>= 4.0'
|
28
28
|
spec.add_dependency 'nokogiri', '1.6.5'
|
29
29
|
|
data/lib/brief/briefcase.rb
CHANGED
@@ -33,14 +33,6 @@ module Brief
|
|
33
33
|
"#{slug}:#{repository.cache_key}"
|
34
34
|
end
|
35
35
|
|
36
|
-
def table_of_contents
|
37
|
-
table_of_contents_document.to_model
|
38
|
-
end
|
39
|
-
|
40
|
-
def table_of_contents_document
|
41
|
-
Brief::Document.new(docs_path.join("index.md"), document_type: "outline")
|
42
|
-
end
|
43
|
-
|
44
36
|
def slug
|
45
37
|
options.fetch(:slug) { root.basename.to_s.parameterize }
|
46
38
|
end
|
@@ -97,7 +89,7 @@ module Brief
|
|
97
89
|
def schema_map(include_all=false)
|
98
90
|
list = include_all ? Brief::Model.classes : model_classes
|
99
91
|
list.map(&:to_schema)
|
100
|
-
.reduce({}) {|m, k| m[k[:type_alias]] = k; m }
|
92
|
+
.reduce({}.to_mash) {|m, k| m[k[:type_alias]] = k; m }
|
101
93
|
end
|
102
94
|
|
103
95
|
def data
|
@@ -1,3 +1,16 @@
|
|
1
|
+
class Commander::Command
|
2
|
+
def action(*args, &block)
|
3
|
+
Brief.default_cli_options(self)
|
4
|
+
|
5
|
+
when_called do |args, options|
|
6
|
+
options.default(root: Brief.pwd)
|
7
|
+
Brief.case = Brief::Briefcase.new(root: Pathname(options.root))
|
8
|
+
|
9
|
+
block.call(args, options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
1
14
|
module Brief
|
2
15
|
def self.cli_action(c, &block)
|
3
16
|
c.action do |args, options|
|
data/lib/brief/cli/write.rb
CHANGED
@@ -2,22 +2,32 @@ command 'write' do |c|
|
|
2
2
|
c.syntax = 'brief write MODEL_TYPE [OPTIONS]'
|
3
3
|
c.description = 'Create a new document for a given model type'
|
4
4
|
|
5
|
-
c.action do |args,
|
6
|
-
|
7
|
-
|
5
|
+
c.action do |args, options|
|
6
|
+
schema_map = Brief.case.schema_map(true)
|
7
|
+
type_alias = args.first
|
8
8
|
|
9
|
-
|
9
|
+
model_class = schema_map.fetch(type_alias) do
|
10
|
+
raise "Unknown model type: #{ type_alias }. Available types are: #{ schema_map.keys.join(',') }"
|
11
|
+
end
|
12
|
+
|
13
|
+
default_example = "---\ntype:#{type_alias}\n---\n\n# Enter some content"
|
14
|
+
|
15
|
+
content = ask_editor(model_class.to_mash.example || default_example)
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
file = ask("Enter a filename")
|
18
|
+
|
19
|
+
if file.to_s.length == 0
|
20
|
+
rand_token = rand(36**36).to_s(36).slice(0,6)
|
21
|
+
file = "new-#{ type_alias }-#{ rand_token }.md"
|
15
22
|
end
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
folder = Brief.case.docs_path.join(type_alias.pluralize)
|
25
|
+
folder = folder.exist? ? folder : Brief.case.docs_path
|
26
|
+
|
27
|
+
folder.join(file).open("w+") do |fh|
|
28
|
+
fh.write(content)
|
29
|
+
end
|
19
30
|
|
20
|
-
puts file
|
21
|
-
puts document_contents
|
31
|
+
puts "== Successfully created #{ folder.join(file) }"
|
22
32
|
end
|
23
33
|
end
|
data/lib/brief/document.rb
CHANGED
@@ -121,6 +121,23 @@ module Brief
|
|
121
121
|
(@briefcase_root && Brief.cases[@briefcase_root]) || Brief.case
|
122
122
|
end
|
123
123
|
|
124
|
+
def has_sections?
|
125
|
+
model_class.section_mappings.length > 0
|
126
|
+
end
|
127
|
+
|
128
|
+
def section_headings
|
129
|
+
sections.keys
|
130
|
+
end
|
131
|
+
|
132
|
+
def sections_data
|
133
|
+
section_headings.reduce({}) do |memo, heading|
|
134
|
+
section = sections.send(heading)
|
135
|
+
items = section.items rescue nil
|
136
|
+
memo[heading] = items if items
|
137
|
+
memo
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
124
141
|
def sections
|
125
142
|
mappings = model_class.section_mappings
|
126
143
|
|
@@ -21,6 +21,8 @@ module Brief::Model::Serializers
|
|
21
21
|
updated_at: File.mtime(path).to_i,
|
22
22
|
id: Digest::MD5.hexdigest(path.to_s),
|
23
23
|
hash: file_hash,
|
24
|
+
sections: {},
|
25
|
+
section_headings: [],
|
24
26
|
urls: {
|
25
27
|
view_content_url: "/view/content/#{ doc_path }",
|
26
28
|
view_rendered_url: "/view/rendered/#{ doc_path }",
|
@@ -33,6 +35,11 @@ module Brief::Model::Serializers
|
|
33
35
|
}.tap do |h|
|
34
36
|
h[:content] = document.combined_data_and_content if options[:content]
|
35
37
|
h[:rendered] = document.to_html if options[:rendered]
|
38
|
+
end.tap do |h|
|
39
|
+
if document.has_sections?
|
40
|
+
h[:section_headings] = document.section_headings
|
41
|
+
h[:sections] = document.sections_data
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
data/lib/brief/version.rb
CHANGED
@@ -3,6 +3,11 @@ config do
|
|
3
3
|
set(:templates => Pathname(File.dirname(__FILE__)).join("templates"))
|
4
4
|
end
|
5
5
|
|
6
|
+
view :table_of_contents do
|
7
|
+
doc = Brief::Document.new(docs_path.join("index.md"), document_type: "outline")
|
8
|
+
doc && doc.to_model
|
9
|
+
end
|
10
|
+
|
6
11
|
view :custom_aggregator do
|
7
12
|
{aggregator:"custom"}
|
8
13
|
end
|
@@ -54,6 +54,18 @@ describe "The Brief Document" do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
context "defining sections" do
|
57
|
+
it "has sections" do
|
58
|
+
expect(sample).to be_has_sections
|
59
|
+
end
|
60
|
+
|
61
|
+
it "gives me info about the section headings" do
|
62
|
+
expect(sample.section_headings).to include("user_stories")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has the information from the sections" do
|
66
|
+
expect(sample.sections_data).not_to be_empty
|
67
|
+
end
|
68
|
+
|
57
69
|
it "lets me define content sections" do
|
58
70
|
expect(sample.sections).not_to be_empty
|
59
71
|
expect(sample.sections.user_stories).to be_present
|
@@ -26,12 +26,12 @@ describe "The Brief Document Repository" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "finds the first document matching a query" do
|
29
|
-
query = repository.where(state:"active")
|
29
|
+
query = repository.where(state:"active", type: "epic")
|
30
30
|
expect(query.first.type).to eq("epic")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "finds the last document matching a query" do
|
34
|
-
query = repository.where(state:"active")
|
34
|
+
query = repository.where(state:"active", type:"user_story")
|
35
35
|
expect(query.last.type).to eq("user_story")
|
36
36
|
end
|
37
37
|
|
data/spec/spec_helper.rb
CHANGED
@@ -37,6 +37,10 @@ RSpec.configure do |config|
|
|
37
37
|
config.mock_with :rspec
|
38
38
|
config.include Rack::Test::Methods
|
39
39
|
config.include TestHelpers
|
40
|
+
|
41
|
+
config.after(:suite) do
|
42
|
+
`git checkout spec/fixtures/example/docs` rescue nil
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
ENV['BRIEF_APPS_PATH'] = Brief.spec_root.join("fixtures","apps").to_s
|
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.12
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: activemodel
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: activesupport
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|