brief 1.9.8 → 1.9.9

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: 6e9d4f96cdfb13d6e754b942a4687f60e7d8888e
4
- data.tar.gz: 59caee15c35018c1b1bfebcec9bc2c9455fdc41a
3
+ metadata.gz: 1e5778cd99dfcb00c4420b4fedfb0e4e69b61d0b
4
+ data.tar.gz: 1c551d49bf311134309dcff740d1492200deeea2
5
5
  SHA512:
6
- metadata.gz: 9bddeba5d8229e39e3fb5e7d939ae57b2104862fd26d5d2f737404a965af4ba30bed1fa272937b2f814b793174fff0a082b6ab4c7bbb301d8726539628296acc
7
- data.tar.gz: 48af2ae16f06cef85620f6fe59c9f184748e2ffadb529645900be9da06f36db071174d1cfe8f79abb33f6fa0bb56ac194433823a770631b51505cc6161b5cbf7
6
+ metadata.gz: d23643282699bf917fb20805a229e82138abe51babef4454e137f90802ef3786d4d6b8ff61661a77b368a363fbf5b21d6871002e76d7b479458409111b7a4edd
7
+ data.tar.gz: 861e4cc4df911860dcc481bd3e25d208f815f3f3ce078d05ae515e0d07408c71559c309d6cfb69cb898b613b150a2fd2fe18f4c7b3574bb495be70ec575e9808
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.0
data/Gemfile.lock CHANGED
@@ -32,8 +32,8 @@ GEM
32
32
  coderay (1.1.0)
33
33
  coercible (1.0.0)
34
34
  descendants_tracker (~> 0.0.1)
35
- commander (4.3.2)
36
- highline (~> 1.7.1)
35
+ commander (4.3.3)
36
+ highline (~> 1.7.2)
37
37
  daemons (1.2.2)
38
38
  descendants_tracker (0.0.4)
39
39
  thread_safe (~> 0.3, >= 0.3.1)
@@ -51,7 +51,7 @@ GEM
51
51
  rack
52
52
  github-markdown (0.6.8)
53
53
  hashie (2.1.2)
54
- highline (1.7.1)
54
+ highline (1.7.2)
55
55
  hike (2.1.3)
56
56
  http_parser.rb (0.6.0)
57
57
  i18n (0.7.0)
@@ -60,7 +60,7 @@ GEM
60
60
  json (1.8.2)
61
61
  method_source (0.8.2)
62
62
  mini_portile (0.6.2)
63
- minitest (5.5.1)
63
+ minitest (5.6.1)
64
64
  multipart-post (2.0.0)
65
65
  nokogiri (1.6.5)
66
66
  mini_portile (~> 0.6.0)
data/REFACTOR.md ADDED
@@ -0,0 +1,4 @@
1
+ - `YAML.load_file(file)` will load frontmatter and discard the rest
2
+ - `File.basename(file, '.*')` gets the basename with no extensions
3
+ - Merge document and model classes
4
+ - Use ActiveModel
data/Rakefile CHANGED
@@ -2,9 +2,6 @@ Dir[File.join(Dir.pwd, 'tasks', '**', '*.rb')].each { |f| require f }
2
2
  Dir[File.join(Dir.pwd, 'tasks', '*.rake')].each { |f| load f }
3
3
 
4
4
  require "bundler/gem_tasks"
5
- require 'rspec/core/rake_task'
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
5
 
9
6
  Distribution.configure do |config|
10
7
  config.package_name = 'brief'
@@ -24,5 +21,3 @@ Distribution.configure do |config|
24
21
  'unf_ext-0.0.6'
25
22
  ]
26
23
  end
27
-
28
- task :default => :spec
data/bin/brief CHANGED
@@ -18,6 +18,8 @@ if ARGV[0] == "console"
18
18
  Pry.start($briefcase)
19
19
  else
20
20
  require 'commander/import'
21
+
22
+ $terminal.wrap_at = 120
21
23
 
22
24
  program :name, "Brief"
23
25
  program :description, "Brief lets you treat your markdown files like active record objects"
@@ -58,7 +58,12 @@ module Brief
58
58
  key: folder_name.to_s.parameterize,
59
59
  name: folder_name.to_s.titlecase,
60
60
  settings: settings,
61
- cache_key: cache_key
61
+ cache_key: cache_key,
62
+ root: root.to_s,
63
+ docs_path: docs_path.to_s,
64
+ assets_path: assets_path.to_s,
65
+ models_path: models_path.to_s,
66
+ data_path: data_path.to_s
62
67
  }
63
68
 
64
69
  if params[:include_data] || params[:data]
@@ -87,7 +92,11 @@ module Brief
87
92
  end
88
93
 
89
94
  def as_full_export(options={})
90
- options.reverse_merge!(content: true, rendered: true, models: true, schema: true)
95
+ options.reverse_merge!(content: true,
96
+ rendered: true,
97
+ models: true,
98
+ schema: true,
99
+ attachments: true)
91
100
  as_default(options)
92
101
  end
93
102
 
@@ -34,19 +34,6 @@ command 'dispatch export' do |c|
34
34
  data: options.include_data,
35
35
  attachments: options.include_attachments,
36
36
  models: options.include_models).as_json
37
-
38
- case
39
- when options.output && options.format.to_sym == :json
40
- Pathname(options.output).open("w+") do |fh|
41
- fh.write("#{options.prefix_output}#{result.to_json}")
42
- end
43
- when options.format.to_sym == :json
44
- puts "#{options.prefix_output}#{result.to_json}"
45
- when options.format.to_sym == :printed
46
- puts result
47
- end
48
-
49
-
50
37
  end
51
38
  end
52
39
 
@@ -12,27 +12,20 @@ command 'start gateway server' do |c|
12
12
  end
13
13
  end
14
14
 
15
- command 'start drb server' do |c|
16
- c.option '--host HOSTNAME', String, 'What hostname to listen on'
15
+ command 'start socket server' do |c|
17
16
  c.option '--port PORT', String, 'What port to listen on'
18
- c.option '--gateway', 'Create a gateway instead of a briefcase'
19
17
 
20
18
  c.action do |args, options|
21
- options.default(root: Brief.pwd)
19
+ options.default(root: Brief.pwd, port: 5054)
22
20
 
23
- require 'drb'
21
+ require 'brief/server/socket'
22
+ require 'em-websocket'
24
23
 
25
- root = Pathname(options.root)
26
24
 
27
- object = if options.gateway
28
- Brief::Server::Distributed.new(root: root, briefcase_options: {eager: true})
29
- else
30
- Brief::Briefcase.new(root: root, eager: true)
31
- end
32
-
33
- puts "== starting distributed service"
34
- DRb.start_service "druby://:#{ options.port || 9000 }", object
35
- trap("INT") { DRb.stop_service }
36
- DRb.thread.join()
25
+ EM.run {
26
+ EM::WebSocket.run(:host=>"0.0.0.0",:port => 8089) do |ws|
27
+ Brief::Server::Socket.new(root: options.root, websocket: ws)
28
+ end
29
+ }
37
30
  end
38
31
  end
@@ -127,7 +127,7 @@ module Brief
127
127
  end
128
128
 
129
129
  def briefcase
130
- (@briefcase_root && Brief.cases[@briefcase_root]) || Brief.case(true)
130
+ (@briefcase_root && Brief.cases[@briefcase_root.basename.to_s]) || Brief.case(true)
131
131
  end
132
132
 
133
133
  def has_sections?
@@ -0,0 +1,122 @@
1
+ module Brief class Server
2
+ class Socket
3
+ attr_reader :briefcases, :root, :websocket
4
+
5
+ def initialize(options={})
6
+ @root = Pathname(options.fetch(:root))
7
+ @websocket = options.fetch(:websocket)
8
+ @briefcases = {}.to_mash
9
+ @briefcase_options = options.fetch(:briefcase_options, {})
10
+ load_briefcases
11
+ setup_interface
12
+ end
13
+
14
+ def process(message={})
15
+ message.symbolize_keys!
16
+
17
+ action = message.fetch(:action)
18
+ message_id = message.fetch(:message_id)
19
+
20
+ case
21
+
22
+ when action == "brief:info"
23
+ respond_to(message_id) do
24
+ {
25
+ environment: Brief.environment_info,
26
+ root: root.to_s,
27
+ briefcases: briefcases.keys
28
+ }
29
+ end
30
+
31
+ when action == "list:briefcases"
32
+ presenter = message.fetch(:presenter, 'default')
33
+ options = message.fetch(:options, {})
34
+
35
+ respond_to(message_id) do
36
+ briefcases.values.map do |bc|
37
+ bc.present(presenter, options)
38
+ end
39
+ end
40
+
41
+ when action == "view:briefcase"
42
+ presenter = message.fetch(:presenter, 'default')
43
+ options = message.fetch(:options, {})
44
+ briefcase = briefcases.fetch(message[:briefcase])
45
+
46
+ respond_to(message_id) do
47
+ briefcase.present(presenter.to_sym, options)
48
+ end
49
+
50
+ when action == "view:document"
51
+ options = message.fetch(:options, {})
52
+ path = message.fetch(:path)
53
+ briefcase = briefcases.fetch(message[:briefcase])
54
+
55
+ respond_to(message_id) do
56
+ document = briefcase.document_at(path)
57
+ document.to_model.as_json(options)
58
+ end
59
+
60
+ when action == "query"
61
+ params = message.fetch(:params, {})
62
+ model_options = message.fetch(:model_options, {})
63
+ briefcase = briefcases.fetch(message[:briefcase])
64
+
65
+ respond_to(message_id) do
66
+ briefcase.where(params).all.map do |model|
67
+ model.as_json(model_options)
68
+ end
69
+ end
70
+
71
+ else
72
+ respond_to(message_id) do
73
+ {error:"Invalid Action: #{ action }"}
74
+ end
75
+ end
76
+ rescue
77
+ nil
78
+ end
79
+
80
+ def respond_to(message_id, &block)
81
+ body = block.call()
82
+
83
+ payload = {
84
+ action: "response",
85
+ message_id: message_id,
86
+ body: body
87
+ }
88
+
89
+ websocket.send(payload.to_json)
90
+ end
91
+
92
+ private
93
+
94
+ def setup_interface
95
+ socket = self
96
+
97
+ websocket.onmessage do |raw|
98
+ message = (JSON.parse(raw) rescue nil)
99
+
100
+ puts "== Received Message: #{message}"
101
+ socket.process(message)
102
+ end
103
+ end
104
+
105
+ def briefcase_options
106
+ (@briefcase_options || {})
107
+ end
108
+
109
+ def load_briefcases
110
+ config_path = briefcase_options.fetch(:config_path, "brief.rb")
111
+
112
+ root.children.select(&:directory?).each do |dir|
113
+ if dir.join(config_path).exist?
114
+ slug = dir.basename.to_s.parameterize
115
+ @briefcases[slug] ||= Brief::Briefcase.new(briefcase_options.merge(root: dir))
116
+ end
117
+ end
118
+ end
119
+
120
+ end
121
+ end
122
+ end
data/lib/brief/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Brief
2
- VERSION = '1.9.8'
2
+ VERSION = '1.9.9'
3
3
  end
data/lib/brief.rb CHANGED
@@ -43,6 +43,17 @@ module Brief
43
43
  @views ||= {}
44
44
  end
45
45
 
46
+ def self.environment_info
47
+ {
48
+ VERSION: Brief::VERSION,
49
+ lib_root: Brief.lib_root.to_s,
50
+ apps: {
51
+ search_paths: Brief::Apps.search_paths.map(&:to_s),
52
+ available: Brief::Apps.available_apps
53
+ }
54
+ }
55
+ end
56
+
46
57
  def self.configuration
47
58
  Brief::Configuration.instance
48
59
  end
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.9.8
4
+ version: 1.9.9
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-04-03 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -278,12 +278,14 @@ extensions: []
278
278
  extra_rdoc_files: []
279
279
  files:
280
280
  - ".gitignore"
281
+ - ".ruby-version"
281
282
  - ".travis.yml"
282
283
  - CHANGELOG.md
283
284
  - Gemfile
284
285
  - Gemfile.lock
285
286
  - LICENSE.txt
286
287
  - README.md
288
+ - REFACTOR.md
287
289
  - Rakefile
288
290
  - TUTORIAL.md
289
291
  - apps/blueprint/config.rb
@@ -353,6 +355,7 @@ files:
353
355
  - lib/brief/server/handlers/schema.rb
354
356
  - lib/brief/server/handlers/show.rb
355
357
  - lib/brief/server/route.rb
358
+ - lib/brief/server/socket.rb
356
359
  - lib/brief/util.rb
357
360
  - lib/brief/version.rb
358
361
  - packaging/wrapper.sh
@@ -446,7 +449,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
446
449
  version: '0'
447
450
  requirements: []
448
451
  rubyforge_project:
449
- rubygems_version: 2.2.2
452
+ rubygems_version: 2.4.5
450
453
  signing_key:
451
454
  specification_version: 4
452
455
  summary: Brief makes writing more powerful