brief 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79796113d0d8f8f21e6d5143efa8a8da8faa46f8
4
- data.tar.gz: 9a788247f96dc6386db346f203acc6a6f227d207
3
+ metadata.gz: 2bff2a020e24fc30bab2b5b93c854ec96c70d3af
4
+ data.tar.gz: 711b3c62cdb58b3c67d4acb2ca7e3d2298305182
5
5
  SHA512:
6
- metadata.gz: 01fd22902ed25d4660b8e1b72cd6045541895459f766ad71ee58990703f1a4de4e7075d81e9f883249fe6df0ee1a7e7a762edddfdb63d1aa40dbf588f35912df
7
- data.tar.gz: ab24732776aa546dc91b46a1ff5d21ddbcd8081d311bf9733fd259b1e017db84c88a776c167b8507168ba091b399fe5895e9af5e7b79c6ee50fe6cd75c8419a1
6
+ metadata.gz: f118758e7e59399b8b0dd438bf226943d2ed2ff84f2f2f5941f8a64a5f23d32d192684ab82c8db6f7aa2280f764a159a5415826d25ffe5c73c109bf6d092091d
7
+ data.tar.gz: 457b6b9cd33a3a3597dd1f728a97bd4198fc0a6faa7054a67fae45e431c771e3cabf7da060a932707b8799fbb9d24c9f5c9a0cbfc8e9a15540dd9d2eeda62d43
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brief (1.4.5)
4
+ brief (1.5.0)
5
5
  activemodel
6
6
  activesupport
7
7
  commander
@@ -17,10 +17,6 @@ module Brief
17
17
  @path = Pathname(path)
18
18
  end
19
19
 
20
- if options[:Test]
21
- binding.pry
22
- end
23
-
24
20
  @options = options.to_mash
25
21
 
26
22
  if @path && self.path.exist?
@@ -18,7 +18,8 @@ module Brief
18
18
 
19
19
  def document_at(path)
20
20
  path = normalize_path(path)
21
- Brief::Document.new(path)
21
+ found = documents.find {|doc| doc.path == path }
22
+ found || Brief::Document.new(path).in_briefcase(briefcase)
22
23
  end
23
24
 
24
25
  def documents_at!(*paths)
@@ -34,7 +35,7 @@ module Brief
34
35
 
35
36
  paths.map! {|p| normalize_path(p) }
36
37
 
37
- paths.map {|p| p && Brief::Document.new(p)}
38
+ paths.map {|p| p && document_at(p) }
38
39
  end
39
40
 
40
41
  def models_at(*paths)
data/lib/brief/server.rb CHANGED
@@ -19,6 +19,7 @@ class Brief::Server
19
19
  headers["Content-Length"] = Rack::Utils.bytesize(body).to_s
20
20
  headers["Access-Control-Allow-Origin"] = "*"
21
21
  headers["Access-Control-Allow-Methods"] = "GET, POST, PUT"
22
+ headers["X-BRIEF-HANDLER"] = request.send(:handler).try(:to_s)
22
23
 
23
24
  [status, headers, [body]]
24
25
  end
@@ -6,7 +6,7 @@ module Brief::Server::Handlers
6
6
 
7
7
  writer = Writer.new(briefcase, path_args, request.params.symbolize_keys)
8
8
 
9
- headers = {"Content-Type"=>"application/json"}
9
+ headers = {"Content-Type"=>"application/json", "X-BRIEF-MODIFY-ACTION"=>action}
10
10
 
11
11
  response = writer.run(action)
12
12
 
@@ -87,7 +87,7 @@ module Brief::Server::Handlers
87
87
  contents = params[:content] || params[:contents]
88
88
  raw = params[:raw]
89
89
 
90
- document = Brief::Document.new(path).in_briefcase(briefcase)
90
+ document = briefcase.document_at(path)
91
91
 
92
92
  if document.nil? || !document.exist?
93
93
  @errors[:document] = "No document was found at #{ path_args }"
@@ -23,9 +23,12 @@ class Brief::Server::Route
23
23
  resp = handler.handle(path_args, briefcase, request: request, action: path_action)
24
24
 
25
25
  self.code = resp[0]
26
- self.headers.merge(resp[1])
26
+ self.headers.merge!(resp[1])
27
27
  self.body = resp[2]
28
28
 
29
+ headers["X-BRIEF-PATH-ACTION"] = path_action.to_s
30
+ headers["X-BRIEF-PATH-ARGS"] = path_args.to_s
31
+
29
32
  [code, headers, body]
30
33
  end
31
34
 
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.5.0'
2
+ VERSION = '1.5.1'
3
3
  end
@@ -35,10 +35,29 @@ describe "Modifying Documents", :type => :request do
35
35
  expect(last_response.status).to eq(200)
36
36
  end
37
37
 
38
+ it "updates both the content and the data" do
39
+ needle = rand(36**36).to_s(36)
40
+ post "/update/concept.html.md", content: "# Modified Content #{ needle }", data: {needle: needle}
41
+
42
+ doc = Brief::Document.new(Brief.example_path.join("docs","concept.html.md"))
43
+
44
+ expect(doc.data.values).to include(needle)
45
+ expect(doc.content).to include(needle)
46
+ end
47
+
48
+ it "refreshes the browse endpoint data after an update" do
49
+ needle = rand(36**36).to_s(36)
50
+ post "/update/concept.html.md", content: "# Modified Content #{ needle }", data: {needle: needle}
51
+ get("/browse/concepts")
52
+
53
+ needles = json.map {|h| h["data"]["needle"] }
54
+ expect(needles).to include(needle)
55
+ end
56
+
38
57
  it "lets me update just the metadata for an existing document" do
39
58
  needle = rand(36**36).to_s(36)
40
59
  post "/update/concept.html.md", data: {needle: needle}
41
-
60
+ expect(json["data"]["needle"]).to eq(needle)
42
61
  expect(last_response.status).to eq(200)
43
62
  end
44
63
 
@@ -0,0 +1,14 @@
1
+ class Brief::Concept
2
+ include Brief::Model
3
+
4
+ meta do
5
+ title
6
+ needle
7
+ subheading
8
+ status String, :in => %w(draft published)
9
+ end
10
+
11
+ content do
12
+ title "h1:first-of-type"
13
+ end
14
+ end
@@ -21,11 +21,11 @@ describe "The Briefcase" do
21
21
 
22
22
  context "Model Loading" do
23
23
  it "loads the model definitions from the models folder" do
24
- expect(Brief::Model.classes.length).to eq(3)
24
+ expect(Brief::Model.classes.length).to eq(4)
25
25
  end
26
26
 
27
27
  it "loads the model definitions from the DSL in the config file" do
28
- expect(Brief::Model.classes.length).to eq(3)
28
+ expect(Brief::Model.classes.length).to eq(4)
29
29
  end
30
30
 
31
31
  it "caches the output" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brief
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder
@@ -292,6 +292,7 @@ files:
292
292
  - spec/fixtures/example/docs/resource.html.md
293
293
  - spec/fixtures/example/docs/user_story.html.md
294
294
  - spec/fixtures/example/docs/wireframe.html.md
295
+ - spec/fixtures/example/models/concept.rb
295
296
  - spec/fixtures/example/models/epic.rb
296
297
  - spec/fixtures/example/models/page.rb
297
298
  - spec/fixtures/example/settings.yml
@@ -354,6 +355,7 @@ test_files:
354
355
  - spec/fixtures/example/docs/resource.html.md
355
356
  - spec/fixtures/example/docs/user_story.html.md
356
357
  - spec/fixtures/example/docs/wireframe.html.md
358
+ - spec/fixtures/example/models/concept.rb
357
359
  - spec/fixtures/example/models/epic.rb
358
360
  - spec/fixtures/example/models/page.rb
359
361
  - spec/fixtures/example/settings.yml