brief 1.4.2 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/brief/model.rb +13 -3
- data/lib/brief/model/serializers.rb +24 -8
- data/lib/brief/server/gateway.rb +7 -2
- data/lib/brief/server/handlers/info.rb +15 -2
- data/lib/brief/version.rb +1 -1
- data/spec/fixtures/example/docs/concept.html.md +2 -2
- data/spec/lib/brief/model_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1051f1c7f8b82c1325913b4a8daa9e113404de69
|
4
|
+
data.tar.gz: cbb53d874b7f6b24d8d16164590f489d74f31fc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7885b7fef9d6705d66a930b0e4e522bac85c53afc11560b5b4dcceb7026551c0ee1c5f585d58a0d777a230b2fde11b2062915f0412f27e8ba221781c9d0bbbf
|
7
|
+
data.tar.gz: a5f1c7ee952d2b8ba5ceb3d72b324ebea099025cf03df6f7ef9f7de539b7d3d34feb6141fdf95b97231756d0883ec0bd93e88f1bdd6339dd6bb067d481bbc4c4
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/brief/model.rb
CHANGED
@@ -101,11 +101,21 @@ module Brief
|
|
101
101
|
module ClassMethods
|
102
102
|
def to_schema
|
103
103
|
{
|
104
|
-
|
105
|
-
|
104
|
+
schema: {
|
105
|
+
content: definition.content_schema,
|
106
|
+
metadata: definition.metadata_schema,
|
107
|
+
},
|
106
108
|
class_name: to_s,
|
107
109
|
type_alias: type_alias,
|
108
|
-
name: name
|
110
|
+
name: name,
|
111
|
+
group: name.to_s.pluralize,
|
112
|
+
actions: defined_actions,
|
113
|
+
example: definition.example_body.to_s,
|
114
|
+
template: definition.template_body.to_s,
|
115
|
+
urls: {
|
116
|
+
browse_url: "browse/#{ type_alias.to_s.pluralize }",
|
117
|
+
schema_url: "schema/#{ type_alias }"
|
118
|
+
}
|
109
119
|
}
|
110
120
|
end
|
111
121
|
|
@@ -1,18 +1,34 @@
|
|
1
1
|
module Brief::Model::Serializers
|
2
|
-
def as_json
|
2
|
+
def as_json(options={})
|
3
|
+
|
4
|
+
if options[:docs_path]
|
5
|
+
if path.absolute?
|
6
|
+
doc_path = path.relative_path_from(options[:docs_path])
|
7
|
+
else
|
8
|
+
doc_path = path
|
9
|
+
end
|
10
|
+
else
|
11
|
+
doc_path = path.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
# TEMP
|
15
|
+
title = data.try(:[], :title) || extracted_content.try(:title) || (send(:title) rescue nil) || path.basename.to_s.gsub(/\.html.md/,'')
|
16
|
+
title = title.to_s.gsub(/\.md/,'')
|
17
|
+
|
3
18
|
{
|
4
19
|
data: data,
|
5
|
-
path:
|
20
|
+
path: doc_path.to_s,
|
6
21
|
type: type,
|
22
|
+
title: title,
|
7
23
|
actions: self.class.defined_actions,
|
8
24
|
urls: {
|
9
|
-
view_content_url: "/view/content/#{
|
10
|
-
view_rendered_url: "/view/rendered/#{
|
11
|
-
view_details_url: "/view/details/#{
|
12
|
-
update_url: "/update/#{
|
13
|
-
remove_url: "/remove/#{
|
25
|
+
view_content_url: "/view/content/#{ doc_path }",
|
26
|
+
view_rendered_url: "/view/rendered/#{ doc_path }",
|
27
|
+
view_details_url: "/view/details/#{ doc_path }",
|
28
|
+
update_url: "/update/#{ doc_path }",
|
29
|
+
remove_url: "/remove/#{ doc_path }",
|
14
30
|
schema_url: "/schema/#{ type }",
|
15
|
-
actions_url: "/actions/:action/#{
|
31
|
+
actions_url: "/actions/:action/#{ doc_path }"
|
16
32
|
}
|
17
33
|
}
|
18
34
|
end
|
data/lib/brief/server/gateway.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class Brief::Server::Gateway
|
2
|
-
attr_reader :root
|
2
|
+
attr_reader :root, :briefcases
|
3
3
|
|
4
4
|
def initialize(options={})
|
5
5
|
@root = options.fetch(:root)
|
6
|
-
@briefcases = {}
|
6
|
+
@briefcases = {}.to_mash
|
7
7
|
@briefcase_options = options.fetch(:briefcase_options, {})
|
8
8
|
load_briefcases
|
9
9
|
end
|
@@ -25,6 +25,11 @@ class Brief::Server::Gateway
|
|
25
25
|
|
26
26
|
def call(env)
|
27
27
|
request = Rack::Request.new(env)
|
28
|
+
|
29
|
+
if request.path.match(/__info$/)
|
30
|
+
return [200, {}, [@briefcases.keys.to_json]]
|
31
|
+
end
|
32
|
+
|
28
33
|
name = request.path.match(/\/\w+\/(\w+)/)[1] rescue nil
|
29
34
|
|
30
35
|
if name && @briefcases[name]
|
@@ -1,7 +1,20 @@
|
|
1
1
|
module Brief::Server::Handlers
|
2
2
|
class Info
|
3
|
-
def self.handle(
|
4
|
-
|
3
|
+
def self.handle(path, briefcase, options={})
|
4
|
+
request = options.fetch(:request)
|
5
|
+
action = options.fetch(:action)
|
6
|
+
|
7
|
+
schema = {}
|
8
|
+
models = {}
|
9
|
+
|
10
|
+
Brief::Model.classes.map do |k|
|
11
|
+
schema[k.type_alias] = k.to_schema
|
12
|
+
|
13
|
+
a = k.type_alias.to_s.pluralize
|
14
|
+
models[a] = briefcase.send(a).map {|m| m.as_json(docs_path: briefcase.docs_path) }
|
15
|
+
end
|
16
|
+
|
17
|
+
[200, {}, {name: briefcase.folder_name.to_s, schema: schema, models: models}]
|
5
18
|
end
|
6
19
|
end
|
7
20
|
end
|
data/lib/brief/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
type: concept
|
3
3
|
title: Blueprint Concept Example
|
4
4
|
subheading: A key concept to the domain model
|
5
|
-
contents: "# Modified Content
|
6
|
-
needle:
|
5
|
+
contents: "# Modified Content sflavhtnupa7u6zniwsl4f8u7fhi16dkddbk"
|
6
|
+
needle: p2hrybcv4jp6nfuenrm671xq3cgfyp30v9vk
|
7
7
|
---
|
8
8
|
|
@@ -6,7 +6,7 @@ describe "The Brief Model" do
|
|
6
6
|
let(:user_story) { briefcase.user_stories.first }
|
7
7
|
|
8
8
|
it "exposes information about its schema" do
|
9
|
-
expect(epic.class.to_schema.keys).to include(:
|
9
|
+
expect(epic.class.to_schema.keys).to include(:schema, :name, :class_name, :type_alias)
|
10
10
|
end
|
11
11
|
|
12
12
|
context "DSL Style Declarations" do
|
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.4.
|
4
|
+
version: 1.4.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-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|