brief 0.0.5 → 1.0.0
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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +71 -55
- data/README.md +149 -48
- data/Rakefile +15 -5
- data/bin/brief +15 -28
- data/brief.gemspec +17 -11
- data/examples/blog/brief.rb +54 -0
- data/examples/blog/docs/an-intro-to-brief.html.md +9 -0
- data/lib/.DS_Store +0 -0
- data/lib/brief/briefcase.rb +78 -0
- data/lib/brief/cli/change.rb +14 -0
- data/lib/brief/cli/init.rb +66 -0
- data/{spec/fixtures/generated/project_overview.json → lib/brief/cli/publish.rb} +0 -0
- data/lib/brief/cli/write.rb +0 -0
- data/lib/brief/configuration.rb +19 -115
- data/lib/brief/core_ext.rb +11 -0
- data/lib/brief/document/content_extractor.rb +33 -0
- data/lib/brief/document/front_matter.rb +20 -0
- data/lib/brief/document/rendering.rb +37 -0
- data/lib/brief/document.rb +43 -38
- data/lib/brief/document_mapper.rb +158 -0
- data/lib/brief/dsl.rb +42 -0
- data/lib/brief/model/definition.rb +117 -0
- data/lib/brief/model.rb +177 -0
- data/lib/brief/repository.rb +57 -0
- data/lib/brief/version.rb +1 -7
- data/lib/brief.rb +35 -40
- data/spec/fixtures/example/brief.rb +27 -0
- data/spec/fixtures/example/docs/concept.html.md +5 -0
- data/spec/fixtures/example/docs/epic.html.md +19 -0
- data/spec/fixtures/example/docs/persona.html.md +5 -0
- data/spec/fixtures/example/docs/release.html.md +7 -0
- data/spec/fixtures/example/docs/resource.html.md +5 -0
- data/spec/fixtures/example/docs/user_story.html.md +24 -0
- data/spec/fixtures/example/docs/wireframe.html.md +5 -0
- data/spec/fixtures/example/models/epic.rb +16 -0
- data/spec/lib/brief/briefcase_spec.rb +27 -0
- data/spec/lib/brief/document_spec.rb +14 -22
- data/spec/lib/brief/dsl_spec.rb +4 -15
- data/spec/lib/brief/model_spec.rb +84 -0
- data/spec/lib/brief/repository_spec.rb +60 -0
- data/spec/spec_helper.rb +12 -14
- data/spec/support/test_helpers.rb +0 -0
- data/tasks/brief/release.rake +0 -0
- metadata +120 -110
- data/.gitignore +0 -1
- data/Guardfile +0 -5
- data/examples/project_overview.md +0 -23
- data/lib/brief/cli/commands/config.rb +0 -40
- data/lib/brief/cli/commands/publish.rb +0 -27
- data/lib/brief/cli/commands/write.rb +0 -27
- data/lib/brief/formatters/base.rb +0 -12
- data/lib/brief/formatters/github_milestone_rollup.rb +0 -52
- data/lib/brief/git.rb +0 -19
- data/lib/brief/github/wiki.rb +0 -9
- data/lib/brief/github.rb +0 -141
- data/lib/brief/github_client/authentication.rb +0 -32
- data/lib/brief/github_client/client.rb +0 -86
- data/lib/brief/github_client/commands.rb +0 -5
- data/lib/brief/github_client/issue_labels.rb +0 -65
- data/lib/brief/github_client/issues.rb +0 -22
- data/lib/brief/github_client/milestone_issues.rb +0 -13
- data/lib/brief/github_client/organization_activity.rb +0 -9
- data/lib/brief/github_client/organization_issues.rb +0 -13
- data/lib/brief/github_client/organization_repositories.rb +0 -20
- data/lib/brief/github_client/organization_users.rb +0 -9
- data/lib/brief/github_client/repository_events.rb +0 -8
- data/lib/brief/github_client/repository_issue_events.rb +0 -9
- data/lib/brief/github_client/repository_issues.rb +0 -8
- data/lib/brief/github_client/repository_labels.rb +0 -18
- data/lib/brief/github_client/repository_milestones.rb +0 -9
- data/lib/brief/github_client/request.rb +0 -181
- data/lib/brief/github_client/request_wrapper.rb +0 -121
- data/lib/brief/github_client/response_object.rb +0 -50
- data/lib/brief/github_client/single_repository.rb +0 -9
- data/lib/brief/github_client/user_activity.rb +0 -16
- data/lib/brief/github_client/user_gists.rb +0 -9
- data/lib/brief/github_client/user_info.rb +0 -9
- data/lib/brief/github_client/user_issues.rb +0 -13
- data/lib/brief/github_client/user_organizations.rb +0 -9
- data/lib/brief/github_client/user_repositories.rb +0 -9
- data/lib/brief/github_client.rb +0 -43
- data/lib/brief/handlers/base.rb +0 -62
- data/lib/brief/handlers/github_issue.rb +0 -41
- data/lib/brief/handlers/github_milestone.rb +0 -37
- data/lib/brief/handlers/github_wiki.rb +0 -11
- data/lib/brief/line.rb +0 -69
- data/lib/brief/parser.rb +0 -354
- data/lib/brief/publisher/handler_manager.rb +0 -47
- data/lib/brief/publisher.rb +0 -142
- data/lib/brief/tree.rb +0 -43
- data/lib/core_ext.rb +0 -37
- data/spec/fixtures/front_end_tutorial.md +0 -33
- data/spec/fixtures/generator_dsl_example.rb +0 -22
- data/spec/fixtures/project_overview.md +0 -48
- data/spec/fixtures/sample.md +0 -19
- data/spec/lib/brief/line_spec.rb +0 -11
- data/spec/lib/brief/parser_spec.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de4de1da31d941ba973047d92612413463c2cfa
|
4
|
+
data.tar.gz: 9fbd98bbe85b00b6fdefabde34f79c03e6ceb6d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d96dd1a4537378b35dc5af7f8fef84e0d80fc484497d14c90119fed09776f3274ac0b464402f858f7348f555a26e8cb45dcb9d488124ad56010ef950661d3b
|
7
|
+
data.tar.gz: 536970830fd8c5d7b4c4b1a3eaad68043932f5b562d07d5b714f3852db1c39eb5ba3847c4f62d056e17ab291d772d10d4f0fb1a3d3cb656d255233c540b23525
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,79 +1,97 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brief (0.0
|
4
|
+
brief (1.0.0)
|
5
|
+
activemodel
|
5
6
|
activesupport
|
6
|
-
colored
|
7
7
|
commander
|
8
|
+
github-fs
|
8
9
|
hashie
|
9
|
-
|
10
|
+
inflecto
|
11
|
+
nokogiri
|
12
|
+
redcarpet
|
13
|
+
virtus (>= 1.0.3)
|
10
14
|
|
11
15
|
GEM
|
12
16
|
remote: https://rubygems.org/
|
13
17
|
specs:
|
14
|
-
|
15
|
-
|
18
|
+
activemodel (4.2.0)
|
19
|
+
activesupport (= 4.2.0)
|
20
|
+
builder (~> 3.1)
|
21
|
+
activesupport (4.2.0)
|
22
|
+
i18n (~> 0.7)
|
16
23
|
json (~> 1.7, >= 1.7.7)
|
17
24
|
minitest (~> 5.1)
|
18
|
-
thread_safe (~> 0.
|
25
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
19
26
|
tzinfo (~> 1.1)
|
20
|
-
|
21
|
-
|
27
|
+
addressable (2.3.6)
|
28
|
+
axiom-types (0.1.1)
|
29
|
+
descendants_tracker (~> 0.0.4)
|
30
|
+
ice_nine (~> 0.11.0)
|
31
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
32
|
+
builder (3.2.2)
|
22
33
|
coderay (1.1.0)
|
23
|
-
|
24
|
-
|
34
|
+
coercible (1.0.0)
|
35
|
+
descendants_tracker (~> 0.0.1)
|
36
|
+
commander (4.2.1)
|
25
37
|
highline (~> 1.6.11)
|
38
|
+
descendants_tracker (0.0.4)
|
39
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
26
40
|
diff-lcs (1.2.5)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
guard-rspec (4.2.10)
|
36
|
-
guard (~> 2.1)
|
37
|
-
rspec (>= 2.14, < 4.0)
|
38
|
-
hashie (2.1.2)
|
41
|
+
equalizer (0.0.9)
|
42
|
+
faraday (0.9.0)
|
43
|
+
multipart-post (>= 1.2, < 3)
|
44
|
+
github-fs (0.0.1)
|
45
|
+
activesupport (> 3.2.0)
|
46
|
+
octokit
|
47
|
+
rack
|
48
|
+
hashie (3.3.2)
|
39
49
|
highline (1.6.21)
|
40
|
-
i18n (0.
|
50
|
+
i18n (0.7.0)
|
51
|
+
ice_nine (0.11.1)
|
52
|
+
inflecto (0.0.2)
|
41
53
|
json (1.8.1)
|
42
|
-
listen (2.7.9)
|
43
|
-
celluloid (>= 0.15.2)
|
44
|
-
rb-fsevent (>= 0.9.3)
|
45
|
-
rb-inotify (>= 0.9)
|
46
|
-
lumberjack (1.0.7)
|
47
54
|
method_source (0.8.2)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
55
|
+
mini_portile (0.6.2)
|
56
|
+
minitest (5.5.0)
|
57
|
+
multipart-post (2.0.0)
|
58
|
+
nokogiri (1.6.5)
|
59
|
+
mini_portile (~> 0.6.0)
|
60
|
+
octokit (3.7.0)
|
61
|
+
sawyer (~> 0.6.0, >= 0.5.3)
|
62
|
+
pry (0.10.1)
|
63
|
+
coderay (~> 1.1.0)
|
64
|
+
method_source (~> 0.8.1)
|
52
65
|
slop (~> 3.4)
|
53
|
-
pry-nav (0.2.
|
54
|
-
pry (
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
rspec-
|
61
|
-
rspec-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
rspec-expectations (3.0.2)
|
66
|
+
pry-nav (0.2.4)
|
67
|
+
pry (>= 0.9.10, < 0.11.0)
|
68
|
+
rack (1.6.0)
|
69
|
+
rake (10.4.2)
|
70
|
+
redcarpet (3.2.0)
|
71
|
+
rspec (3.1.0)
|
72
|
+
rspec-core (~> 3.1.0)
|
73
|
+
rspec-expectations (~> 3.1.0)
|
74
|
+
rspec-mocks (~> 3.1.0)
|
75
|
+
rspec-core (3.1.7)
|
76
|
+
rspec-support (~> 3.1.0)
|
77
|
+
rspec-expectations (3.1.2)
|
66
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-mocks (3.
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-support (3.
|
71
|
-
|
72
|
-
|
79
|
+
rspec-support (~> 3.1.0)
|
80
|
+
rspec-mocks (3.1.3)
|
81
|
+
rspec-support (~> 3.1.0)
|
82
|
+
rspec-support (3.1.2)
|
83
|
+
sawyer (0.6.0)
|
84
|
+
addressable (~> 2.3.5)
|
85
|
+
faraday (~> 0.8, < 0.10)
|
86
|
+
slop (3.6.0)
|
73
87
|
thread_safe (0.3.4)
|
74
|
-
|
75
|
-
tzinfo (1.2.1)
|
88
|
+
tzinfo (1.2.2)
|
76
89
|
thread_safe (~> 0.1)
|
90
|
+
virtus (1.0.3)
|
91
|
+
axiom-types (~> 0.1)
|
92
|
+
coercible (~> 1.0)
|
93
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
94
|
+
equalizer (~> 0.0, >= 0.0.9)
|
77
95
|
|
78
96
|
PLATFORMS
|
79
97
|
ruby
|
@@ -81,8 +99,6 @@ PLATFORMS
|
|
81
99
|
DEPENDENCIES
|
82
100
|
brief!
|
83
101
|
bundler (~> 1.3)
|
84
|
-
guard
|
85
|
-
guard-rspec
|
86
102
|
pry
|
87
103
|
pry-nav
|
88
104
|
rake
|
data/README.md
CHANGED
@@ -1,71 +1,172 @@
|
|
1
|
-
# Brief
|
1
|
+
# Brief
|
2
2
|
|
3
|
-
|
4
|
-
of it like a preprocessor for markdown.
|
3
|
+
An ActiveRecord style layer on top of a folder of markdown files.
|
5
4
|
|
6
|
-
|
7
|
-
used to automate tasks and generate more specific content elements.
|
5
|
+
### No more dead documents
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
Brief is a tool that lets you build simple applications on top of
|
8
|
+
collections of markdown files. The metaphor we use is a briefcase,
|
9
|
+
which contains folders with different document types.
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
Every document type, or model, can define a simple schema of attributes,
|
12
|
+
which can be specified in a YAML frontmatter preamble at the very top of
|
13
|
+
each document.
|
16
14
|
|
17
|
-
|
15
|
+
In addition to frontmatter metadata, you can declare other model
|
16
|
+
attributes as CSS selectors. For example, the very first h1 heading
|
17
|
+
could be the title for your document, and the corresponding model for
|
18
|
+
that document would have a `title` method which returned its value.
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
This is a great way to build applications whose primary interface is the
|
21
|
+
text editor, allowing writing and thought to flow as freely as possible
|
22
|
+
and to later be used to power some automation tasks.
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
of the elements.
|
24
|
+
**Think of it as an ActiveRecord like layer on top of a folder of
|
25
|
+
Markdown files**. Brief turns static text into a 'living' data object.
|
25
26
|
|
26
|
-
##
|
27
|
-
|
28
|
-
This content will go in the milestone body. The wiki page
|
29
|
-
that this belongs to, will include a different kind of view of this
|
30
|
-
content.
|
31
|
-
|
32
|
-
### An issue title
|
33
|
-
|
34
|
-
This goes in the issue's body. The wiki page this belongs to will
|
35
|
-
possibly have a link to the issue and a label for its status.
|
36
|
-
|
37
|
-
### Another issue title
|
38
|
-
|
39
|
-
This goes in this issue's body. Same thing. It obviously belongs to the
|
40
|
-
milestone.
|
27
|
+
## Getting started
|
41
28
|
|
29
|
+
```bash
|
30
|
+
gem install brief
|
31
|
+
mkdir blog
|
32
|
+
cd blog
|
33
|
+
brief init
|
42
34
|
```
|
43
35
|
|
44
|
-
|
36
|
+
This will create a new folder for your briefcase, along with the
|
37
|
+
following config file and structure.
|
45
38
|
|
46
39
|
```
|
47
|
-
|
40
|
+
- docs/
|
41
|
+
- an-introduction-to-brief.html.md
|
42
|
+
- models/
|
43
|
+
- brief.rb
|
48
44
|
```
|
49
45
|
|
50
|
-
|
51
|
-
|
46
|
+
The config file will look like:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
|
50
|
+
# configuration options for this briefcase
|
51
|
+
config do
|
52
|
+
set(:models_path => Pathname(__FILE__).parent.join("models"))
|
53
|
+
end
|
54
|
+
|
55
|
+
# define a Post model
|
56
|
+
define("Post") do
|
57
|
+
|
58
|
+
# the post model will have YAML frontmatter
|
59
|
+
# with values for 'status' and 'date'
|
60
|
+
meta do
|
61
|
+
status
|
62
|
+
date DateTime, :default => lambda {|post, attr| post.document.created_at }
|
63
|
+
end
|
64
|
+
|
65
|
+
# the post model will have a 'title' method which returns the text
|
66
|
+
# from the first h1 heading
|
67
|
+
content do
|
68
|
+
title "h1"
|
69
|
+
has_many :subheadings, "h2"
|
70
|
+
end
|
71
|
+
|
72
|
+
helpers do
|
73
|
+
def publish(options={})
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Whenever we call post.save() and the status attribute changes
|
79
|
+
# from draft to published, do something with the model
|
80
|
+
on_status_change(:from => "draft", :to => "published") do |model|
|
81
|
+
# Do Something
|
82
|
+
# mail_service.send_html_email_campaign(model.to_html)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# this creates a custom command in the brief CLI tool
|
87
|
+
#
|
88
|
+
# so when you run:
|
89
|
+
#
|
90
|
+
# brief publish posts /path/to/*.html.md.
|
91
|
+
#
|
92
|
+
# the brief CLI will find models for the post files you reference,
|
93
|
+
# and call whatever methods you want.
|
94
|
+
|
95
|
+
action "publish posts" do |briefcase, models, options|
|
96
|
+
|
97
|
+
say "== Publishing #{ models.length } posts"
|
98
|
+
|
99
|
+
Array(models).each do |post|
|
100
|
+
post.publish()
|
101
|
+
end
|
102
|
+
end
|
103
|
+
```
|
52
104
|
|
53
|
-
|
54
|
-
(TODO INSERT LINK)
|
105
|
+
### Real World Application
|
55
106
|
|
56
|
-
|
107
|
+
My company Architects.io, Inc. uses brief to power our Blueprint
|
108
|
+
software. A Blueprint is a collection of related documents that are
|
109
|
+
used in the software architecture and design process, as well as in the
|
110
|
+
day to day writing that takes place while building the software itself.
|
57
111
|
|
58
|
-
|
59
|
-
markdown input.
|
112
|
+
This includes things like:
|
60
113
|
|
61
|
-
|
114
|
+
- daily standups
|
115
|
+
- bug reports
|
116
|
+
- code reviews
|
117
|
+
- feature epics
|
118
|
+
- user stories
|
119
|
+
- integration tests
|
120
|
+
- release notes
|
121
|
+
- wireframe annotations
|
62
122
|
|
63
|
-
|
123
|
+
All of these things are simple markdown files. They live in the
|
124
|
+
projects we are working on, and by treating our writing as a structured
|
125
|
+
exercise we are able to do a lot more things with it than just read it.
|
64
126
|
|
65
|
-
|
66
|
-
of the template you intend to use. It will open up $EDITOR for you with
|
67
|
-
some example input.
|
127
|
+
For example we can do:
|
68
128
|
|
69
|
-
```bash
|
70
|
-
brief write project overview #=> Opens up $EDITOR with some example content in it
|
71
129
|
```
|
130
|
+
brief publish user stories /path/to/user-stories/*.html.md
|
131
|
+
```
|
132
|
+
|
133
|
+
which is implemented by:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
# brief.rb
|
137
|
+
|
138
|
+
define "User Story" do
|
139
|
+
meta do
|
140
|
+
status
|
141
|
+
end
|
142
|
+
|
143
|
+
content do
|
144
|
+
title "h1"
|
145
|
+
paragraph "p:first-child"
|
146
|
+
persona "p:first-child strong:1st-child"
|
147
|
+
behavior "p:first-child strong:2nd-child"
|
148
|
+
goal "p:first-child strong:3rd-child"
|
149
|
+
end
|
150
|
+
|
151
|
+
helpers do
|
152
|
+
def create_github_issue
|
153
|
+
issue = github.create_issue(title: title, body: document.content)
|
154
|
+
set(issue_number: issue.number)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
action "publish user stories" do |briefcase, models, options|
|
160
|
+
user_stories = models
|
161
|
+
|
162
|
+
user_stories.each do |user_story|
|
163
|
+
if user_story.create_github_issue()
|
164
|
+
user_story.status = "published"
|
165
|
+
user_story.save
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
```
|
170
|
+
|
171
|
+
As you can see, Brief can be a way to make your Markdown writing efforts
|
172
|
+
much more productive.
|
data/Rakefile
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
#!/usr/bin/env rake
|
4
|
+
begin
|
5
|
+
require 'bundler/setup'
|
6
|
+
rescue LoadError
|
7
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
8
|
+
end
|
4
9
|
|
5
10
|
Bundler::GemHelper.install_tasks
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
13
|
+
|
14
|
+
require 'rspec/core'
|
15
|
+
require 'rspec/core/rake_task'
|
16
|
+
|
17
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
20
|
|
11
21
|
task :default => :spec
|
data/bin/brief
CHANGED
@@ -1,35 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
lib = File.join(File.dirname(__FILE__), '../lib')
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
2
|
|
6
|
-
|
7
|
-
require "rubygems"
|
8
|
-
require 'colored'
|
9
|
-
require "commander/import"
|
10
|
-
require "pry"
|
11
|
-
require "brief"
|
12
|
-
end
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
13
4
|
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
require 'rubygems'
|
6
|
+
require 'brief'
|
7
|
+
require 'brief/dsl'
|
17
8
|
|
18
|
-
|
19
|
-
c.syntax = 'brief inspect file [options]'
|
20
|
-
c.description = 'Debug the parsing of a brief'
|
9
|
+
$briefcase = Brief::Briefcase.new(root: Dir.pwd())
|
21
10
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
11
|
+
if ARGV[0] == "console"
|
12
|
+
require 'pry'
|
13
|
+
Pry.start($briefcase)
|
14
|
+
else
|
15
|
+
require 'commander/import'
|
16
|
+
|
17
|
+
program :name, "Brief"
|
18
|
+
program :description, "Brief makes writing markdown more productive"
|
19
|
+
program :version, "0.0.1"
|
32
20
|
|
33
|
-
|
34
|
-
require(File.expand_path(f)) if f.file?
|
21
|
+
Brief.load_commands()
|
35
22
|
end
|
data/brief.gemspec
CHANGED
@@ -1,33 +1,39 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'brief/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "brief"
|
7
|
-
spec.version =
|
8
|
+
spec.version = Brief::VERSION
|
8
9
|
spec.authors = ["Jonathan Soeder"]
|
9
10
|
spec.email = ["jonathan.soeder@gmail.com"]
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.homepage = "
|
11
|
+
spec.summary = %q{Brief makes writing more powerful}
|
12
|
+
spec.description = %q{Brief is a library for developing applications whose primary interface is the text editor}
|
13
|
+
spec.homepage = ""
|
13
14
|
spec.license = "MIT"
|
14
15
|
|
15
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
19
|
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
+
|
20
21
|
spec.add_dependency 'hashie'
|
21
22
|
spec.add_dependency 'commander'
|
22
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'github-fs'
|
24
|
+
spec.add_dependency 'virtus', '>= 1.0.3'
|
25
|
+
spec.add_dependency 'inflecto'
|
26
|
+
spec.add_dependency 'activemodel'
|
23
27
|
spec.add_dependency 'activesupport'
|
24
|
-
spec.add_dependency '
|
28
|
+
spec.add_dependency 'redcarpet'
|
29
|
+
spec.add_dependency 'nokogiri'
|
25
30
|
|
26
31
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
32
|
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "rspec"
|
29
33
|
spec.add_development_dependency "pry"
|
30
34
|
spec.add_development_dependency "pry-nav"
|
31
|
-
spec.add_development_dependency "
|
32
|
-
|
35
|
+
spec.add_development_dependency "rspec"
|
36
|
+
|
33
37
|
end
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# configuration options for this briefcase
|
2
|
+
config do
|
3
|
+
set(:models_path => Pathname(__FILE__).parent.join("models"))
|
4
|
+
end
|
5
|
+
|
6
|
+
# define a Post model
|
7
|
+
define("Post") do
|
8
|
+
|
9
|
+
# the post model will have YAML frontmatter
|
10
|
+
# with values for 'status' and 'date'
|
11
|
+
meta do
|
12
|
+
status
|
13
|
+
date DateTime, :default => lambda {|post, attr| post.document.created_at }
|
14
|
+
end
|
15
|
+
|
16
|
+
# the post model will have a 'title' method which returns the text
|
17
|
+
# from the first h1 heading
|
18
|
+
content do
|
19
|
+
title "h1"
|
20
|
+
has_many :subheadings, "h2"
|
21
|
+
end
|
22
|
+
|
23
|
+
helpers do
|
24
|
+
def publish(options={})
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Whenever we call post.save() and the status attribute changes
|
30
|
+
# from draft to published, do something with the model
|
31
|
+
on_status_change(:from => "draft", :to => "published") do |model|
|
32
|
+
# Do Something
|
33
|
+
# mail_service.send_html_email_campaign(model.to_html)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# this creates a custom command in the brief CLI tool
|
38
|
+
#
|
39
|
+
# so when you run:
|
40
|
+
#
|
41
|
+
# brief publish posts /path/to/*.html.md.
|
42
|
+
#
|
43
|
+
# the brief CLI will find models for the post files you reference,
|
44
|
+
# and call whatever methods you want.
|
45
|
+
|
46
|
+
action "publish posts" do |briefcase, models, options|
|
47
|
+
|
48
|
+
say "== Publishing #{ models.length } posts"
|
49
|
+
|
50
|
+
Array(models).each do |post|
|
51
|
+
post.publish()
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Brief
|
2
|
+
class Briefcase
|
3
|
+
include Brief::DSL
|
4
|
+
|
5
|
+
attr_reader :options,
|
6
|
+
:model_definitions
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
@options = options.to_mash
|
10
|
+
|
11
|
+
load_configuration
|
12
|
+
load_model_definitions
|
13
|
+
|
14
|
+
if Brief.case.nil?
|
15
|
+
Brief.case = self
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def config
|
20
|
+
Brief::Configuration.instance
|
21
|
+
end
|
22
|
+
|
23
|
+
# Loads the configuration for this briefcase, either from the current working directory
|
24
|
+
# or the configured path for the configuration file.
|
25
|
+
def load_configuration
|
26
|
+
config_path = options.fetch(:config_path) do
|
27
|
+
root.join("brief.rb")
|
28
|
+
end
|
29
|
+
|
30
|
+
if config_path.exist?
|
31
|
+
instance_eval(config_path.read)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_model_definitions
|
36
|
+
if models_path.exist?
|
37
|
+
Dir[models_path.join("**/*.rb")].each {|f| require(f) }
|
38
|
+
end
|
39
|
+
|
40
|
+
Brief::Model.finalize
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns a model name by its human readable description or its type alias
|
44
|
+
def model(name_or_type)
|
45
|
+
table = Brief::Model.table
|
46
|
+
|
47
|
+
table.fetch(name_or_type) do
|
48
|
+
table.values.find do |k|
|
49
|
+
k.name == name_or_type
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def root
|
55
|
+
Pathname(options.fetch(:root) { Dir.pwd })
|
56
|
+
end
|
57
|
+
|
58
|
+
def docs_path
|
59
|
+
root.join options.fetch(:docs_path) { config.docs_path }
|
60
|
+
end
|
61
|
+
|
62
|
+
def models_path
|
63
|
+
root.join options.fetch(:models_path) { config.models_path }
|
64
|
+
end
|
65
|
+
|
66
|
+
def repository
|
67
|
+
@repository ||= Brief::Repository.new(self, options)
|
68
|
+
end
|
69
|
+
|
70
|
+
def method_missing(meth, *args, &block)
|
71
|
+
if repository.respond_to?(meth)
|
72
|
+
repository.send(meth, *args, &block)
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|