brief 1.4.2 → 1.4.4

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: 055abd801aa234c3de9e60c210185df6c67e4540
4
- data.tar.gz: 46c1cee01b0d35b50f5374d0841ab4a62f2264f0
3
+ metadata.gz: 1051f1c7f8b82c1325913b4a8daa9e113404de69
4
+ data.tar.gz: cbb53d874b7f6b24d8d16164590f489d74f31fc5
5
5
  SHA512:
6
- metadata.gz: 5407466db85657f41934b9660f4ce6a2194d662d3537aadcde89d90050aad5c75fa0bb46dbc8bccc0441c7d1e026d2038827aabb7adf6d900dd58d6ebad92ec9
7
- data.tar.gz: d430f1c6e7fd87ec5c375109a35cba223349c278c5e487a2169220cd469628b07555765b067dfac7590d1238f4312e0be3eb59055cde9434e697a48d134e0b88
6
+ metadata.gz: c7885b7fef9d6705d66a930b0e4e522bac85c53afc11560b5b4dcceb7026551c0ee1c5f585d58a0d777a230b2fde11b2062915f0412f27e8ba221781c9d0bbbf
7
+ data.tar.gz: a5f1c7ee952d2b8ba5ceb3d72b324ebea099025cf03df6f7ef9f7de539b7d3d34feb6141fdf95b97231756d0883ec0bd93e88f1bdd6339dd6bb067d481bbc4c4
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  # the test suite writes to this
2
2
  spec/fixtures/example/docs/epic.html.md
3
+ spec/fixtures/example/docs/concept.html.md
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.4.1)
4
+ brief (1.4.3)
5
5
  activemodel
6
6
  activesupport
7
7
  commander
data/lib/brief/model.rb CHANGED
@@ -101,11 +101,21 @@ module Brief
101
101
  module ClassMethods
102
102
  def to_schema
103
103
  {
104
- content: definition.content_schema,
105
- metadata: definition.metadata_schema,
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: path.to_s,
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/#{ path }",
10
- view_rendered_url: "/view/rendered/#{ path }",
11
- view_details_url: "/view/details/#{ path }",
12
- update_url: "/update/#{ path }",
13
- remove_url: "/remove/#{ path }",
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/#{ path }"
31
+ actions_url: "/actions/:action/#{ doc_path }"
16
32
  }
17
33
  }
18
34
  end
@@ -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(*args)
4
- [200, {}, {}]
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
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.4.2'
2
+ VERSION = '1.4.4'
3
3
  end
@@ -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 6sq2t5qtwxij7o06183sgfzrpar4bz38kam5"
6
- needle: b6w280kygg5axjfxsyi8gwtjvox2y6u9k785
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(:content, :metadata, :name, :class_name, :type_alias)
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.2
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-18 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie