Skip to content

Instantly share code, notes, and snippets.

@datapimp
Last active August 29, 2015 14:13
Show Gist options
  • Save datapimp/6fb23133704316566b4f to your computer and use it in GitHub Desktop.
Save datapimp/6fb23133704316566b4f to your computer and use it in GitHub Desktop.
# This is a Brief::Model
#
# It allows me to describe the structure of a markdown file (with yaml frontmatter)
# and it creates a ruby class with methods that make all of the data easily accessible,
# and the repeatable structures accessible.
class Brief::Epic
include Brief::Model
meta do
title
subheading
status String, :in => %w(draft published)
end
content do
title "h1:first-child"
define_section "User Stories" do
heading("h2").is_a :user_story
heading("h2").has(:title => "h2",
:paragraph => "p:first-child",
:persona => "p:first-child strong:first-child",
:behavior => "p:first-child strong:second-child",
:goal => "p:first-child strong:third-child"
)
end
end
actions do
def custom_action
end
end
end
# Given the brief model, and the documents which follow the format the model describes
#
# I am able to access the various files and treat them as models.
epic = briefcase.find_epic_by_title('Epic Title')
epic.user_stories.length # => 2
epic.user_stories.map(&:title) # => ['A user wants to write epics', 'A user wants to separate an epic into stories']
epic.user_stories.map(&:goal) # => ['combine all my user stories in one doc', 'import the user stories into my project management tool']
# I can of course render them as html as well, since theyre markdown
epic.to_html
---
status: active
type: epic
---
# Epic Title
Write some stuff about this epic, in general.
# User Stories
## A user wants to write epics
As a **User** I would like to **write an epic** so that I can **combine all my user stories in one doc**
## A user wants to separate an epic into stories
As a **User** I would like to **take the finalized epic and break it down into user stories** so that I can **import the user stories into my project management tool**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment