brief 0.0.1 → 0.0.2

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.
Files changed (71) hide show
  1. checksums.yaml +5 -13
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +81 -0
  4. data/Guardfile +5 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +71 -0
  7. data/Rakefile +11 -0
  8. data/bin/brief +35 -0
  9. data/brief-0.0.1.gem +0 -0
  10. data/brief.gemspec +33 -0
  11. data/examples/project_overview.md +23 -0
  12. data/lib/brief/cli/commands/config.rb +40 -0
  13. data/lib/brief/cli/commands/publish.rb +27 -0
  14. data/lib/brief/cli/commands/write.rb +26 -0
  15. data/lib/brief/configuration.rb +134 -0
  16. data/lib/brief/document.rb +68 -0
  17. data/lib/brief/dsl.rb +0 -0
  18. data/lib/brief/formatters/base.rb +12 -0
  19. data/lib/brief/formatters/github_milestone_rollup.rb +52 -0
  20. data/lib/brief/git.rb +19 -0
  21. data/lib/brief/github/wiki.rb +9 -0
  22. data/lib/brief/github.rb +78 -0
  23. data/lib/brief/github_client/authentication.rb +32 -0
  24. data/lib/brief/github_client/client.rb +86 -0
  25. data/lib/brief/github_client/commands.rb +5 -0
  26. data/lib/brief/github_client/issue_labels.rb +65 -0
  27. data/lib/brief/github_client/issues.rb +22 -0
  28. data/lib/brief/github_client/milestone_issues.rb +13 -0
  29. data/lib/brief/github_client/organization_activity.rb +9 -0
  30. data/lib/brief/github_client/organization_issues.rb +13 -0
  31. data/lib/brief/github_client/organization_repositories.rb +20 -0
  32. data/lib/brief/github_client/organization_users.rb +9 -0
  33. data/lib/brief/github_client/repository_events.rb +8 -0
  34. data/lib/brief/github_client/repository_issue_events.rb +9 -0
  35. data/lib/brief/github_client/repository_issues.rb +8 -0
  36. data/lib/brief/github_client/repository_labels.rb +18 -0
  37. data/lib/brief/github_client/repository_milestones.rb +9 -0
  38. data/lib/brief/github_client/request.rb +181 -0
  39. data/lib/brief/github_client/request_wrapper.rb +121 -0
  40. data/lib/brief/github_client/response_object.rb +50 -0
  41. data/lib/brief/github_client/single_repository.rb +9 -0
  42. data/lib/brief/github_client/user_activity.rb +16 -0
  43. data/lib/brief/github_client/user_gists.rb +9 -0
  44. data/lib/brief/github_client/user_info.rb +9 -0
  45. data/lib/brief/github_client/user_issues.rb +13 -0
  46. data/lib/brief/github_client/user_organizations.rb +9 -0
  47. data/lib/brief/github_client/user_repositories.rb +9 -0
  48. data/lib/brief/github_client.rb +43 -0
  49. data/lib/brief/handlers/base.rb +62 -0
  50. data/lib/brief/handlers/github_issue.rb +41 -0
  51. data/lib/brief/handlers/github_milestone.rb +37 -0
  52. data/lib/brief/handlers/github_wiki.rb +11 -0
  53. data/lib/brief/line.rb +69 -0
  54. data/lib/brief/parser.rb +354 -0
  55. data/lib/brief/publisher/handler_manager.rb +47 -0
  56. data/lib/brief/publisher.rb +142 -0
  57. data/lib/brief/tree.rb +42 -0
  58. data/lib/brief/version.rb +9 -0
  59. data/lib/brief.rb +56 -0
  60. data/lib/core_ext.rb +37 -0
  61. data/spec/fixtures/front_end_tutorial.md +33 -0
  62. data/spec/fixtures/generated/project_overview.json +0 -0
  63. data/spec/fixtures/generator_dsl_example.rb +22 -0
  64. data/spec/fixtures/project_overview.md +48 -0
  65. data/spec/fixtures/sample.md +19 -0
  66. data/spec/lib/brief/document_spec.rb +35 -0
  67. data/spec/lib/brief/dsl_spec.rb +21 -0
  68. data/spec/lib/brief/line_spec.rb +11 -0
  69. data/spec/lib/brief/parser_spec.rb +12 -0
  70. data/spec/spec_helper.rb +25 -0
  71. metadata +231 -9
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTdkMDJhN2M2MWY1NDAxYzVhZDZlMzZlOTJhZWJkY2IxMTQ4YzI5Mw==
5
- data.tar.gz: !binary |-
6
- OWU2NWMwZjRjZWJmMjgxMTM4ZjI3ZGYzMGFhMjI3ZDIyOGJkMWNjZA==
2
+ SHA1:
3
+ metadata.gz: 7c6f64e7e55cb875b980ad06e7dbd5e66d0757d7
4
+ data.tar.gz: a285a1c7344f503d47c10cec106fe4e18f9a8443
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDkxNzk3NGY2MTQxNmMxNjBlNGZjMjdlMjhiNGQyZGIyNjlkM2YxYjhkYWVl
10
- YTg5NjE3OTczN2Q2NTQwMGFmMjNkYzYwYjA5ZGJmMDRmZjUzM2ZkNTRmMzUy
11
- YWFiY2M5OTM1NWU3Y2RhMWM5NzRjZTFjMmJkNTE1NTdlOTZiOWY=
12
- data.tar.gz: !binary |-
13
- ZDEwYWIyZDk0ZTE3ODI1MzU1MTE0YWVhODAxNDRlYzYyNjM2MWNlYzdmNjQ4
14
- NzI0ZGI2NGJjZDFkNDY0NDVjNmQxYTljMWZmNGNkZTc0MThjZGMyNGVjOGY2
15
- N2U0NjQzOTU4NDk5MmU2ODRkYmUwNTU1Mjg2ZTVmNzg5ZDg5ZDI=
6
+ metadata.gz: a97e7f32844a0e7494e619a83ac5d8d08a775331ed97b4083b4833cd5117ad8568c2623048e72c702324ba81c59d508f4a63124b13b431bf4e96e4ef20fc2003
7
+ data.tar.gz: 3e5ee5019ef3cf20c4740b1957553b403772b0158b99bb896e449b9649b77b214ccba53fe3008c80f98abebb397397b50680bc395619baa2437b2ffacd8575b0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in datapimp.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ brief (0.0.1)
5
+ active_support
6
+ colored
7
+ commander
8
+ hashie
9
+ i18n
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ active_support (3.0.0)
15
+ activesupport (= 3.0.0)
16
+ activesupport (3.0.0)
17
+ celluloid (0.15.2)
18
+ timers (~> 1.1.0)
19
+ coderay (1.1.0)
20
+ colored (1.2)
21
+ commander (4.2.0)
22
+ highline (~> 1.6.11)
23
+ diff-lcs (1.2.5)
24
+ ffi (1.9.3)
25
+ formatador (0.2.5)
26
+ guard (2.6.1)
27
+ formatador (>= 0.2.4)
28
+ listen (~> 2.7)
29
+ lumberjack (~> 1.0)
30
+ pry (>= 0.9.12)
31
+ thor (>= 0.18.1)
32
+ guard-rspec (4.2.10)
33
+ guard (~> 2.1)
34
+ rspec (>= 2.14, < 4.0)
35
+ hashie (2.1.2)
36
+ highline (1.6.21)
37
+ i18n (0.6.9)
38
+ listen (2.7.9)
39
+ celluloid (>= 0.15.2)
40
+ rb-fsevent (>= 0.9.3)
41
+ rb-inotify (>= 0.9)
42
+ lumberjack (1.0.7)
43
+ method_source (0.8.2)
44
+ pry (0.9.12.6)
45
+ coderay (~> 1.0)
46
+ method_source (~> 0.8)
47
+ slop (~> 3.4)
48
+ pry-nav (0.2.3)
49
+ pry (~> 0.9.10)
50
+ rake (10.3.2)
51
+ rb-fsevent (0.9.4)
52
+ rb-inotify (0.9.5)
53
+ ffi (>= 0.5.0)
54
+ rspec (3.0.0)
55
+ rspec-core (~> 3.0.0)
56
+ rspec-expectations (~> 3.0.0)
57
+ rspec-mocks (~> 3.0.0)
58
+ rspec-core (3.0.2)
59
+ rspec-support (~> 3.0.0)
60
+ rspec-expectations (3.0.2)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.0.0)
63
+ rspec-mocks (3.0.2)
64
+ rspec-support (~> 3.0.0)
65
+ rspec-support (3.0.2)
66
+ slop (3.5.0)
67
+ thor (0.19.1)
68
+ timers (1.1.0)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ brief!
75
+ bundler (~> 1.3)
76
+ guard
77
+ guard-rspec
78
+ pry
79
+ pry-nav
80
+ rake
81
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :all_on_start => true do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec/" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jonathan Soeder
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Brief
2
+
3
+ Brief is a tool to make writing markdown more productive. You can think
4
+ of it like a preprocessor for markdown.
5
+
6
+ Brief converts raw markdown into a nested structure which can be
7
+ used to automate tasks and generate more specific content elements.
8
+
9
+ Based on which headings you use and how you nest them, brief
10
+ will allow you to define mappings to objects which can be used to
11
+ automate other tasks.
12
+
13
+ I personally use the brief tool to allow me to take a single markdown
14
+ file and create a project wiki page, with links to related milestones
15
+ and github issues.
16
+
17
+ Example:
18
+
19
+ ```markdown
20
+ # Wiki Page Heading
21
+
22
+ Content. Will go on a wiki page. The content below here,
23
+ and the subheadings, will be replaced with a roll-up / summary
24
+ of the elements.
25
+
26
+ ## Milestone Heading
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.
41
+
42
+ ```
43
+
44
+ Given the example above, I run:
45
+
46
+ ```
47
+ brief publish project overview /path/to/markdown
48
+ ```
49
+
50
+ This will create a Github Wiki entry in the repo that I specify, and
51
+ this wiki entry will include links to the milestones and issues.
52
+
53
+ You can see a sample of this Wiki page here:
54
+ (TODO INSERT LINK)
55
+
56
+ ### Publishing Briefs
57
+
58
+ Publishing a brief allows you to run some publishing tasks using raw
59
+ markdown input.
60
+
61
+ (TODO) show some examples of a publisher
62
+
63
+ ### Writing Briefs
64
+
65
+ Writing a brief is as easy as running the brief command, with the name
66
+ of the template you intend to use. It will open up $EDITOR for you with
67
+ some example input.
68
+
69
+ ```bash
70
+ brief write project overview #=> Opens up $EDITOR with some example content in it
71
+ ```
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "bundler/setup"
3
+ require "rspec/core/rake_task"
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |rspec|
8
+ rspec.rspec_opts = ['--backtrace']
9
+ end
10
+
11
+ task :default => :spec
data/bin/brief ADDED
@@ -0,0 +1,35 @@
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
+
6
+ begin
7
+ require "rubygems"
8
+ require 'colored'
9
+ require "commander/import"
10
+ require "pry"
11
+ require "brief"
12
+ end
13
+
14
+ program :name, 'Brief'
15
+ program :version, Brief::Version
16
+ program :description, 'Brief CLI'
17
+
18
+ command :inspect do |c|
19
+ c.syntax = 'brief inspect file [options]'
20
+ c.description = 'Debug the parsing of a brief'
21
+
22
+ c.action do |args, options|
23
+ path = Pathname(args.first)
24
+ path = path.relative? ? Brief.root.join(path) : path
25
+ doc = Brief::Document.new(path)
26
+
27
+ doc.elements do |el|
28
+ puts el.inspect
29
+ end
30
+ end
31
+ end
32
+
33
+ Pathname(lib).join("brief","cli","commands").children.each do |f|
34
+ require(File.expand_path(f)) if f.file?
35
+ end
data/brief-0.0.1.gem ADDED
Binary file
data/brief.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "brief"
7
+ spec.version = '0.0.2'
8
+ spec.authors = ["Jonathan Soeder"]
9
+ spec.email = ["jonathan.soeder@gmail.com"]
10
+ spec.description = %q{Brief is a utility to make writing more productive for software architects. It allows you write to places like Github Wiki, The Github Issues API all from the command line and a single file.}
11
+ spec.summary = %q{Brief is a utility to make writing more productive for software architects.}
12
+ spec.homepage = "http://architects.io/brief"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'hashie'
21
+ spec.add_dependency 'commander'
22
+ spec.add_dependency 'colored'
23
+ spec.add_dependency 'active_support'
24
+ spec.add_dependency 'i18n'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "pry-nav"
31
+ spec.add_development_dependency "guard"
32
+ spec.add_development_dependency "guard-rspec"
33
+ end
@@ -0,0 +1,23 @@
1
+ ```settings
2
+ status: proposed
3
+ edited_by: jonathan soeder
4
+ ```
5
+
6
+ # This is a project overview
7
+
8
+ A body paragraph or two here will be the content for a cover page. You can supply whatever background
9
+ info, domain knowledge requirements, processes, file dependencies and links, whatever.
10
+
11
+ The content for the nested milestones and issues below will be transformed into raw markdown
12
+ which will generate a status summary of the milestones and issues as they get created in the Github API.
13
+
14
+ ## This is a milestone heading
15
+
16
+ A milestone is some logical way of grouping issues and attaching a date to them. You will write the body
17
+ of the individual issues and optionally assign them or label them by writing them below. When this brief
18
+ gets published, the issues will be created and added to the milestone.
19
+
20
+ ### This is an issue that belongs to the above milestone
21
+
22
+ The content of your issue goes here. Normal github flavored markdown is supported.
23
+
@@ -0,0 +1,40 @@
1
+ command :config do |c|
2
+ c.syntax = 'brief config [options]'
3
+ c.description = 'manipulate brief configuration settings'
4
+
5
+ c.action do |args, options|
6
+ Brief::Configuration.initialize!
7
+
8
+ # Setting a value manually
9
+ if args.first == 'set'
10
+ args.slice(1, args.length).map(&:strip).each do |pair|
11
+ key, value = pair.split('=')
12
+ Brief.configuration.set(key, value, false)
13
+ end
14
+
15
+ Brief.configuration.save!
16
+ end
17
+
18
+ if args.empty? && !(Brief.config.github_username || Brief.config.github_token)
19
+ args.push "github"
20
+ end
21
+
22
+ if args.first == "github"
23
+ username = ask("What is your github username: ", String)
24
+
25
+ say "If you haven't generated a personal access token yet, do so here: https://github.com/settings/tokens/new"
26
+ access_token = ask("Enter your private access token: ")
27
+
28
+ if username
29
+ Brief.config.set "github_username", username
30
+ end
31
+
32
+ if access_token
33
+ # TODO
34
+ # We could validate the token for them.
35
+ Brief.config.set "github_token", access_token
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,27 @@
1
+ command :publish do |c|
2
+ c.syntax = 'brief publish PUBLISHER [options]'
3
+ c.description = 'publish a brief file with whatever publisher template you want to use.'
4
+
5
+ c.option '--from FILE', 'Specify a file to read from. Otherwise we use $EDITOR'
6
+
7
+ c.action do |args, options|
8
+ path = case
9
+ when options.from
10
+ Pathname(options.from)
11
+ when (Pathname(args.last).exist? rescue false)
12
+ Pathname(args.pop)
13
+ end
14
+
15
+ document = Brief::Document.new(path: path)
16
+
17
+ publisher = if path && path.exist? && args.empty?
18
+ guess = path.basename.to_s.gsub(/\.\w+$/,'')
19
+
20
+ Brief::Publisher.find(guess)
21
+ else
22
+ Brief::Publisher.find(args)
23
+ end
24
+
25
+ document.publish(publisher)
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ command :write do |c|
2
+ c.syntax = 'brief write PUBLISHER [options]'
3
+
4
+ c.option '--file FILE', 'Specify a file to read from. Otherwise we use $EDITOR'
5
+
6
+ c.action do |args, options|
7
+ path = case
8
+ when options.file
9
+ Pathname(options.file)
10
+ when (Pathname(args.last).exist? rescue false)
11
+ Pathname(args.pop)
12
+ end
13
+
14
+
15
+ publisher = Brief::Publisher.find(args)
16
+
17
+ content = ask_editor(publisher.sample)
18
+
19
+ if content == publisher.sample
20
+ say "Ignoring editor input, same as sample"
21
+ end
22
+
23
+ binding.pry
24
+ end
25
+ end
26
+
@@ -0,0 +1,134 @@
1
+ require "singleton"
2
+ require "json"
3
+
4
+ module Brief
5
+ class Configuration
6
+ include Singleton
7
+
8
+ DefaultSettings = {
9
+ github_username: "",
10
+ github_api_token: ""
11
+ }
12
+
13
+ def self.method_missing meth, *args, &block
14
+ if instance.respond_to?(meth)
15
+ return instance.send meth, *args, &block
16
+ end
17
+
18
+ nil
19
+ end
20
+
21
+ def initialize!
22
+ FileUtils.mkdir_p home_config_path.dirname
23
+ end
24
+
25
+ def method_missing meth, *args, &block
26
+ if current.has_key?(meth.to_s)
27
+ return current.fetch(meth)
28
+ end
29
+
30
+ super
31
+ end
32
+
33
+ def current_github_repository
34
+ value = current.github_repository
35
+
36
+ return value if value
37
+
38
+ if value.nil?
39
+ if guess = Brief::Git.current_github_repository
40
+ set "github_repository", guess
41
+ return guess
42
+ end
43
+ end
44
+
45
+ current.github_repository
46
+ end
47
+
48
+ def current
49
+ @current ||= begin
50
+ home_config.merge(cwd_config)
51
+ end
52
+ end
53
+
54
+ def current_config
55
+ cwd_config_path.exist? ? cwd_config : home_config
56
+ end
57
+
58
+ def set setting, value, persist=true
59
+ current_config[setting] = value
60
+ save! if persist == true
61
+ value
62
+ end
63
+
64
+ def unset setting, persist=true
65
+ current_config.delete(setting)
66
+ save! if persist == true
67
+ end
68
+
69
+ def current
70
+ Hashie::Mash.new(home_config.merge(cwd_config).merge(applied_config))
71
+ end
72
+
73
+ def apply_config_from_path path
74
+ path = Pathname(path)
75
+ parsed = JSON.parse(path.read) rescue {}
76
+ applied_config.merge!(parsed)
77
+ nil
78
+ end
79
+
80
+ def save!
81
+ save_home_config
82
+ save_cwd_config
83
+ end
84
+
85
+ def save_cwd_config
86
+ return nil unless cwd_config_path.exist?
87
+
88
+ File.open(cwd_config_path,'w+') do |fh|
89
+ fh.write JSON.generate(cwd_config.to_hash)
90
+ end
91
+ end
92
+
93
+ def save_home_config
94
+ File.open(home_config_path,'w+') do |fh|
95
+ fh.write JSON.generate(home_config.to_hash)
96
+ end
97
+ end
98
+
99
+ # Applied config is configuration values passed in context
100
+ # usually from the cli, but also in the unit tests
101
+ def applied_config
102
+ @applied_config ||= {}
103
+ end
104
+
105
+ def cwd_config
106
+ @cwd_config ||= begin
107
+ (cwd_config_path.exist? rescue false) ? JSON.parse(cwd_config_path.read) : {}
108
+ rescue
109
+ {}
110
+ end
111
+ end
112
+
113
+ def home_config
114
+ @home_config ||= begin
115
+ (home_config_path.exist? rescue false) ? JSON.parse(home_config_path.read) : {}
116
+ rescue
117
+ {}
118
+ end
119
+ end
120
+
121
+ def home_folder
122
+ Pathname(ENV['HOME']).join('.brief')
123
+ end
124
+
125
+ def home_config_path
126
+ Pathname(ENV['HOME']).join('.brief','config.json')
127
+ end
128
+
129
+ def cwd_config_path
130
+ Pathname(Dir.pwd).join('.briefrc')
131
+ end
132
+ end
133
+ end
134
+
@@ -0,0 +1,68 @@
1
+
2
+ module Brief
3
+ class Document
4
+ attr_reader :content, :options
5
+
6
+ def initialize(options)
7
+ @options = options
8
+
9
+ case
10
+ when options.is_a?(String)
11
+ @content = options
12
+ when options.is_a?(Pathname)
13
+ @content = options.read
14
+ when options.is_a?(Hash)
15
+ @content = options[:path].read
16
+ end
17
+ end
18
+
19
+ def write using
20
+ using.run_before_hooks(:write) do
21
+ write
22
+ end
23
+ end
24
+
25
+ def publish using=nil
26
+ using ||= publisher
27
+
28
+ document = self
29
+ using.run_before_hooks(:publish) do
30
+ process(document)
31
+ end
32
+ end
33
+
34
+ def publisher
35
+ @publisher ||= Brief::Publisher.find(options[:publisher] || "default")
36
+ end
37
+
38
+ def method_missing meth, *args, &block
39
+ if parser.respond_to?(meth)
40
+ return parser.send(meth, *args, &block)
41
+ end
42
+
43
+ super
44
+ end
45
+
46
+ def checksum
47
+ @checksum ||= Digest::MD5.hexdigest(content)
48
+ end
49
+
50
+ def parser
51
+ @parser ||= Brief::Parser.new(content, checksum: checksum)
52
+ end
53
+
54
+
55
+ def settings
56
+ parser.front_matter
57
+ end
58
+
59
+ def elements
60
+ parser.send(:elements)
61
+ end
62
+
63
+ def tree
64
+ parser.send(:tree)
65
+ end
66
+
67
+ end
68
+ end
data/lib/brief/dsl.rb ADDED
File without changes
@@ -0,0 +1,12 @@
1
+ module Brief
2
+ module Formatters
3
+ class Base
4
+
5
+ attr_accessor :element
6
+
7
+ def initialize(element)
8
+ @element = element
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,52 @@
1
+ # The GithubMilestoneRollup formatter takes the raw input markdown
2
+ # which specifies a relationship between the milestone and its child
3
+ # issues with all of the necessary detail, and replaces it with a
4
+ # bulleted list of links to the issues on github, with their titles,
5
+ # assignee relationship, and current status
6
+ #
7
+ # So for example, given the raw input:
8
+ #
9
+ # --- BEGIN RAW INPUT
10
+ #
11
+ # ## Milestone Heading
12
+ #
13
+ # Content for the milestone description.
14
+ #
15
+ # ### Nested Issue One
16
+ #
17
+ # Detail for nested issue one.
18
+ # Blah blah blah
19
+ #
20
+ # ### Nested Issue Two
21
+ #
22
+ # Detail for nested issue two
23
+ #
24
+ # --- END RAW INPUT ---
25
+ #
26
+ # We should get:
27
+ #
28
+ # --- BEGIN FORMATTED OUTPUT ---
29
+ #
30
+ # ## (Milestone Heading)[https://github.com/datapimp/brief/milestones/1]
31
+ #
32
+ # Content for milestone description
33
+ #
34
+ # ### (Nested Issue One)[https://github.com/datapimp/brief/issues/1]
35
+ # Assigned To|Last Updated|Status
36
+ # ---|---|---
37
+ # datapimp|July 4, 2014|open
38
+ #
39
+ # ### (Nested Issue Two)[https://github.com/datapimp/brief/issues/2]
40
+ # Assigned To|Last Updated|Status
41
+ # ---|---|---
42
+ # datapimp|July 4, 2014|open
43
+ #
44
+ # --- END FORMATTED OUTPUT ---
45
+ #
46
+ module Brief
47
+ module Formatters
48
+ class GithubMilestoneRollup < Base
49
+
50
+ end
51
+ end
52
+ end