clerq 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/CHANGELOG.md +14 -2
- data/Gemfile.lock +24 -0
- data/README.md +107 -30
- data/clerq.thor +28 -0
- data/docs/README.md +408 -0
- data/lib/assets/knb/business-case.md +135 -0
- data/lib/assets/knb/requirement-life-cycle.md +47 -0
- data/lib/assets/knb/vision-document.md +191 -0
- data/lib/assets/lib/clerq_doc.thor +119 -0
- data/lib/assets/lib/colonize_repo.rb +82 -0
- data/lib/assets/lib/spec/colonize_repo_spec.rb +85 -0
- data/lib/assets/new/content.md.tt +1 -0
- data/lib/assets/tt/default.md.erb +1 -1
- data/lib/assets/tt/pandoc.md.erb +6 -6
- data/lib/clerq.rb +7 -2
- data/lib/clerq/cli.rb +33 -47
- data/lib/clerq/entities/node.rb +11 -5
- data/lib/clerq/repositories.rb +0 -1
- data/lib/clerq/repositories/file_repository.rb +1 -0
- data/lib/clerq/repositories/node_repository.rb +7 -6
- data/lib/clerq/services.rb +8 -0
- data/lib/clerq/services/check_assembly.rb +108 -0
- data/lib/clerq/{interactors → services}/create_node.rb +4 -5
- data/lib/clerq/services/load_assembly.rb +54 -0
- data/lib/clerq/{interactors/query_assembly.rb → services/query_node.rb} +15 -12
- data/lib/clerq/{interactors → services}/query_template.rb +3 -8
- data/lib/clerq/services/read_node.rb +98 -0
- data/lib/clerq/services/render_erb.rb +29 -0
- data/lib/clerq/{interactors/render_assembly.rb → services/render_node.rb} +8 -12
- data/lib/clerq/services/service.rb +19 -0
- data/lib/clerq/version.rb +1 -1
- metadata +21 -12
- data/TODO.md +0 -7
- data/lib/clerq/interactors.rb +0 -5
- data/lib/clerq/interactors/check_assembly.rb +0 -77
- data/lib/clerq/interactors/interactor.rb +0 -26
- data/lib/clerq/render_erb.rb +0 -33
- data/lib/clerq/repositories/node_reader.rb +0 -107
@@ -0,0 +1,135 @@
|
|
1
|
+
# Business Case
|
2
|
+
|
3
|
+
[source 1](http://whatis.techtarget.com/reference/How-to-write-a-business-case)
|
4
|
+
|
5
|
+
[source 2](https://resources.workfront.com/project-management-blog/how-to-write-a-business-case-4-steps-to-a-perfect-business-case-template)
|
6
|
+
|
7
|
+
## What is a business case?
|
8
|
+
|
9
|
+
The business case is developed during the early stages of a project and outlines the __why, how, and who__ necessary to decide if the project is worth continuing. it's first developed during an initial investigation, has much more detail and should be reviewed by the project sponsor and key stakeholders before being accepted, rejected, canceled, deffered, or revised.
|
10
|
+
|
11
|
+
BC gives your company the chance to access the following for each project:
|
12
|
+
|
13
|
+
* Business problem or opportunity
|
14
|
+
* Benefits
|
15
|
+
* Risk
|
16
|
+
* Costs including investment appraisal
|
17
|
+
* Likely technical solutions
|
18
|
+
* Timescale
|
19
|
+
* Impact on operations
|
20
|
+
* Organizational capability to deliver the project outcome.
|
21
|
+
|
22
|
+
If a project is worth doing you need to answer 5 simple questions:
|
23
|
+
|
24
|
+
* What is your goal?
|
25
|
+
* What's stopping you from reaching the goal?
|
26
|
+
* How much change is needed to overcome the problem?
|
27
|
+
* Are you certain this will solve the problem?
|
28
|
+
* Can you answer these questions quickly? Do you have evidence to support or refute your assumptions?
|
29
|
+
|
30
|
+
# How to Write a Business Case
|
31
|
+
|
32
|
+
The purpose is communication. Therefore, each section should be written in the parlance of the intended audience. Moreover, it should only contain enough information to help decision making.
|
33
|
+
|
34
|
+
As you're writing, keep in mind:
|
35
|
+
|
36
|
+
* The document should be brief and convey only the bare essentials
|
37
|
+
* Make it interesting, clear and concise
|
38
|
+
* Eliminate conjecture and minimize jargon
|
39
|
+
* Describe your vision of the future
|
40
|
+
* Demonstrate the value and benefits to project brings to the Business
|
41
|
+
* Keep the number of authors to a minimum to ensure consistent style and readability.
|
42
|
+
|
43
|
+
# Template
|
44
|
+
|
45
|
+
The perfect BC for your project typically includes the following four section:
|
46
|
+
|
47
|
+
## Executive Summary
|
48
|
+
|
49
|
+
This short summary is the first section of the business case and the last written. It should succinctly convey vital information about the project and communicate the entire story to the reader.
|
50
|
+
|
51
|
+
First impression are important. Get this right!
|
52
|
+
|
53
|
+
## Finance
|
54
|
+
|
55
|
+
This for those who will be approving funding and should include:
|
56
|
+
|
57
|
+
1. __A financial appraisal__ - identify the project's financial implications, compare project costs to forecast benefits, ensure every cost is considered, assess value of money, and predict cash flow.
|
58
|
+
2. __A sensitivity analysis__ - assess project risks, measure the impact of project outcomes or assumptions, and lets project accountants experiment with possible scenarios.
|
59
|
+
|
60
|
+
## Project Definition
|
61
|
+
|
62
|
+
This is the largest part of the business case and is for the project sponsor, stakeholders, and project team. It should address the following...
|
63
|
+
|
64
|
+
### Business Objective
|
65
|
+
|
66
|
+
* What is your goal?
|
67
|
+
* What is needed to overcome the problem?
|
68
|
+
* How will the project support the business strategy?
|
69
|
+
|
70
|
+
### Benefits and Limitations
|
71
|
+
|
72
|
+
This section describes the financial and non-financial benefits in turn. The purpose is to explain why you need a project. For instance, to:
|
73
|
+
|
74
|
+
* Improve quality
|
75
|
+
* Save costs through efficiencies
|
76
|
+
* Reduce working capital - the difference between current assets and current liabilities
|
77
|
+
* Generate revenue
|
78
|
+
* Remain competitive
|
79
|
+
* Improve customer service
|
80
|
+
* To align to corporate strategy
|
81
|
+
|
82
|
+
### Option Identification and Selection
|
83
|
+
|
84
|
+
Identify the potential solutions to the problem and describe them in enough detail for the reader to understand.
|
85
|
+
|
86
|
+
For instance, if the business case and proposed solution makes use of technology, make sure to explain how the technology is used and define the terms used in a glossary.
|
87
|
+
|
88
|
+
The final business case may contain three to five options - the short list - that includes a do nothing or benchmark option.
|
89
|
+
|
90
|
+
### Scope, Impact, and interdependencies
|
91
|
+
|
92
|
+
This section describes the work needed to deliver the business objective and identifies those business functions affected by the project. it should also state the project's scope and boundaries. It describe what is included and what is excluded plus the key interdependencies with other projects.
|
93
|
+
|
94
|
+
Consider the failure of other interrelated projects and show how such dependencies may impact benefits.
|
95
|
+
|
96
|
+
### Outline Plan
|
97
|
+
|
98
|
+
Ideally, the project should be divided into stages with key decisions preceding each stage. Use this section to answer the following questions:
|
99
|
+
|
100
|
+
* What is required?
|
101
|
+
* How is id done?
|
102
|
+
* Who does what?
|
103
|
+
* When will things happen?
|
104
|
+
|
105
|
+
This outline plan should also list the major deliverables and include a brief project.
|
106
|
+
|
107
|
+
### Market Assessment
|
108
|
+
|
109
|
+
Provide a thorough assessment of the business context and make the underlying business interests explicit. Show a complete understanding of the marketplace in which your business operates, considering political, economical, sociological, technological, legal, and environmental factors (or PESTLE, if you like)
|
110
|
+
|
111
|
+
### Risk assessment
|
112
|
+
|
113
|
+
Summarize the significant risks and opportunities and how they are managed. The risks included should cover those that could arise from you projects or the organization's ability to deliver change, including the following questions:
|
114
|
+
|
115
|
+
* What risks are involved?
|
116
|
+
* What are the consequences of a risk happening?
|
117
|
+
* What opportunities may emerge?
|
118
|
+
* What plans are in place to deal with the risks?
|
119
|
+
|
120
|
+
### Project Approach
|
121
|
+
|
122
|
+
The project approach describes how the project is tackled. That is, the way in which work is done do deliver the project. For instance, a project with much of the work contracted out is likely to take a different approach to a project that develops an in-house solution.
|
123
|
+
|
124
|
+
### Purchasing Strategy
|
125
|
+
|
126
|
+
This section describes how a project is to be financed and whether a decision to buy, lease, or outsource should be taken by the organization before purchasing.
|
127
|
+
|
128
|
+
Moreover, the purchasing strategy should describe the purchasing process used. A formal procurement process may save time and money and reduce project risk.
|
129
|
+
|
130
|
+
## Project Organization
|
131
|
+
|
132
|
+
The last section is of most interest to the project manager, project team, and managers responsible for delivering work to the project, and should include:
|
133
|
+
|
134
|
+
1. __Project governance__ - show how the project is structured and the different levels of decision-making.
|
135
|
+
2. __Progress reporting__ - define for project progress will be recorded and reported to the project board.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
% Some pieces from BABOK
|
2
|
+
|
3
|
+
# Requirements life cycle
|
4
|
+
|
5
|
+
The purpose is to ensure that business, stakeholder, and solution requirements and designs are aligned to one another and that the solution implements them.
|
6
|
+
|
7
|
+
## Trace
|
8
|
+
|
9
|
+
Business Needs <-> Business Requirements <-> Stakeholder Requirements <-> Solution Requirements (Design <-> Code <-> Test)
|
10
|
+
|
11
|
+
## Maintain
|
12
|
+
|
13
|
+
The purpose is to retain requirement accuracy and consistency throughout and beyond the change during the entire requirements life cycle, and to support reuse of requirements in other solutions.
|
14
|
+
|
15
|
+
## Prioritize
|
16
|
+
|
17
|
+
Typical factors that influence prioritization include:
|
18
|
+
|
19
|
+
* __Benefit__: the advantage that accrues to stakeholders as a result of requirement implementation, as measured against the goals and objectives for the change. The benefit provided can refer to a specific functionality, desired quality, or strategic goal or business objective. If there are multiple stakeholders, each group may perceive benefits differently. Conflict resolution and negotiation may be employed to come to consensus on overall benefit.
|
20
|
+
* __Penalty__: the consequences that result from not implementing a given requirement. This includes prioritizing requirements in order to meet regulatory or policy demands imposed on the organization, which may take precedence over other stakeholder interests. Penalty may also refer to the negative consequence of not implementing a requirement that improves the experience of a customer.
|
21
|
+
* __Cost__: the effort and resources needed to implement the requirement. Information about cost typically comes from the implementation team or the vendor. Customers may change the priority of a requirement after learning the cost. Cost is often used in conjunction with other criteria, such as cost-benefit analysis.
|
22
|
+
* __Risk__: the chance that the requirement cannot deliver the potential value, or cannot be met at all. This may include many factors such as the difficulty of implementing a requirement, or the chance that stakeholders will not accept a solution component. If there is a risk that the solution is not technically feasible, the requirement that is most difficult to implement may be prioritized to the top of the list in order to minimize the resources that are spent before learning that a proposed solution cannot be delivered. A proof of concept may be developed to establish that high risk options are possible.
|
23
|
+
* __Dependencies__: relationships between requirements where one requirement cannot be fulfilled unless the other requirement is fulfilled. In some situations, it may be possible to achieve efficiencies by implementing related requirements at the same time. Dependencies may also be external to the initiative, including but not limited to other teams’ decisions, funding commitments, and resource availability. Dependencies are identified as part of the task Trace Requirements (p. 79).
|
24
|
+
* __Time Sensitivity__: the 'best before' date of the requirement, after which the implementation of the requirement loses significant value. This includes time-to-market scenarios, in which the benefit derived will be exponentially greater if the functionality is delivered ahead of the competition. It can also refer to seasonal functionality that only has value at a specific time of year.
|
25
|
+
* __Stability__: the likelihood that the requirement will change, either because it requires further analysis or because stakeholders have not reached a consensus about it. If a requirement is not stable, it may have a lower priority in order to minimize unanticipated rework and wasted effort.
|
26
|
+
* __Regulatory or Policy Compliance__: requirements that must be implemented in order to meet regulatory or policy demands imposed on the organization, which may take precedence over other stakeholder interests.
|
27
|
+
|
28
|
+
## Assess changes
|
29
|
+
|
30
|
+
The purpose is to evaluate the implications of proposed changes to requirements and designs. The task is performed as new needs or possible solutions are identified.
|
31
|
+
|
32
|
+
* is it align to the change strategy and/or solution scope?
|
33
|
+
* will increase the value of the solution?
|
34
|
+
* has conflicts with other requirements?
|
35
|
+
* or increase the level of risk?
|
36
|
+
* can be traced back to a need?
|
37
|
+
|
38
|
+
## Approve
|
39
|
+
|
40
|
+
The purpose is to obtain agreement on and approval of requirements and designs for business analysis work to continue and/or solution construction to proceed.
|
41
|
+
|
42
|
+
Business analysts are responsible for ensuring clear communication of
|
43
|
+
requirements, designs, and other business analysis information to the key stakeholders responsible for approving that information.
|
44
|
+
|
45
|
+
Approval of requirements and designs may be formal or informal. Predictive approaches typically perform approvals at the end of the phase or during planned change control meetings. Adaptive approaches typically approve requirements only when construction and implementation of a solution meeting the requirement can begin.
|
46
|
+
|
47
|
+
Business analysts work with key stakeholders to gain consensus on new and changed requirements, communicate the outcome of discussions, and track and manage the approval.
|
@@ -0,0 +1,191 @@
|
|
1
|
+
% Vision Document Template
|
2
|
+
Company Name
|
3
|
+
Vision Document for [Program Name]
|
4
|
+
(r) 20XX [Company Name]
|
5
|
+
|
6
|
+
# Revision History
|
7
|
+
|
8
|
+
Date | Revision | Description | Author
|
9
|
+
:--- | :------- | :---------- | :-----
|
10
|
+
mm/dd/yy | 1.0 | Initial version | Author name
|
11
|
+
|
12
|
+
# Table of Contents
|
13
|
+
|
14
|
+
# 1 Introduction
|
15
|
+
|
16
|
+
This section provides an overview of the Vision document.
|
17
|
+
|
18
|
+
## 1.1 Purpose
|
19
|
+
|
20
|
+
This document defines the strategic intent of the program. It defines high-level user needs, any applicable user personas, key stakeholders, and the general system capabilities needed by the users.
|
21
|
+
|
22
|
+
## 1.2 Solution Overview
|
23
|
+
|
24
|
+
State the general purpose of the product, system, application or service, and any version identification.
|
25
|
+
|
26
|
+
* Identify the product or application to be created or enhanced.
|
27
|
+
* Describe the application of the product, including its benefits, goals, and objectives.
|
28
|
+
* Provide a general description of what the solution will and, where appropriate, will not do.
|
29
|
+
|
30
|
+
## 1.3 References
|
31
|
+
|
32
|
+
List other documents referenced, and specify the sources from which the references can be obtained. If a business case (Chapter 23) was developed to drive the program, refer to it or attach it.
|
33
|
+
|
34
|
+
# 2 User Description
|
35
|
+
To provide products and services that meet users’ needs, it is helpful to understand the challenges they confront when performing their jobs. This section should profile the intended users of the application and the key problems that limit the user’s productivity. This section should not be used to state specific requirements; just provide the background for why the features specified in Section 5 are needed.
|
36
|
+
|
37
|
+
## 2.1 User/Market Demographics
|
38
|
+
|
39
|
+
Summarize the key market demographics that motivate your solution decisions. Describe target-market segments. Estimate the market’s size and growth by the number of potential users or the amount of money your customers spend, trying to meet needs that your product/enhancement would fulfill. Review major industry trends and technologies. Refer to a market analysis, where available.
|
40
|
+
|
41
|
+
## 2.2 User Personas
|
42
|
+
|
43
|
+
Describe the primary and secondary user personas (see Chapter 7). A thorough analysis might cover the following topics for each persona:
|
44
|
+
|
45
|
+
* Technical background and degree of sophistication
|
46
|
+
* Key responsibilities
|
47
|
+
* Deliverables the user produces and for whom
|
48
|
+
* Trends that make the user’s job easier or more difficult
|
49
|
+
* The user’s definition of success and how the user is rewarded
|
50
|
+
* Problems that interfere with success
|
51
|
+
|
52
|
+
## 2.3 User Environment
|
53
|
+
|
54
|
+
Describe the working environment of the target user. Here are some suggestions.
|
55
|
+
|
56
|
+
* How many people are involved in completing the task? Is this changing?
|
57
|
+
* How long is a task cycle? How much time is spent in each activity? Is this changing?
|
58
|
+
* Are there any unique environmental constraints: controlled environment, mobile, outdoors, and so on?
|
59
|
+
* Which system platforms are in use today? Future platforms?
|
60
|
+
* What other applications are in use? Does your application need to integrate with them?
|
61
|
+
|
62
|
+
## 2.4 Key User Needs
|
63
|
+
|
64
|
+
List the key problems or needs as perceived by the user. Clarify the following issues for each problem.
|
65
|
+
|
66
|
+
* What are the reasons for this problem?
|
67
|
+
* How is it solved now?
|
68
|
+
* What solutions does the user envision?
|
69
|
+
|
70
|
+
Ranking and cumulative-voting techniques for these needs indicate problems that must be solved versus issues the user would like to be solved.
|
71
|
+
|
72
|
+
## 2.5 Alternatives and Competition
|
73
|
+
|
74
|
+
Identify any alternatives available to the user. These can include buying a competitor’s product, building a homegrown solution, or simply maintaining the status quo. List any known competitive choices that exist. Include the major strengths and weaknesses of each competitor as perceived by the end user.
|
75
|
+
|
76
|
+
### 2.5.1 Competitor 1
|
77
|
+
|
78
|
+
### 2.5.2 Competitor 2
|
79
|
+
|
80
|
+
# 3 Stakeholders
|
81
|
+
|
82
|
+
Identify the program stakeholders, their needs, and their degree of involvement with the system. A table such as the following can be effective:
|
83
|
+
|
84
|
+
Project<br/>Stakeholder | Degree of<br/> Involvement | Product Needs | Program Needs
|
85
|
+
:---- | :---- | :---- | :----
|
86
|
+
Stakeholder 1 | | |
|
87
|
+
Stakeholder 2 | | |
|
88
|
+
|
89
|
+
# 4 Product Overview
|
90
|
+
|
91
|
+
This section provides a high-level view of the solution capabilities, interfaces to other applications, and systems configurations. This section usually consists of five subsections, as follows.
|
92
|
+
|
93
|
+
## 4.1 Product Perspective
|
94
|
+
|
95
|
+
This subsection should put the product in perspective to other related products and the user’s environment. If the product is independent and totally self-contained, state so. If the product is a component of a larger system, this subsection should relate how these systems interact and should identify the relevant interfaces among the systems. One easy way to display the major components of the larger system, interconnections, and external interfaces is via a system context block diagram.
|
96
|
+
|
97
|
+
## 4.2 Product Position Statement
|
98
|
+
|
99
|
+
Provide an overall statement summarizing, at the highest level, the unique position the product intends to fill in the marketplace. Moore [1991] calls this the product position statement and recommends the following format.
|
100
|
+
|
101
|
+
For | (target customer)
|
102
|
+
:-- | :----------------
|
103
|
+
Who | (statement of the need or opportunity)
|
104
|
+
The (product name) | is a (product category)
|
105
|
+
That | (statement of key benefit, that is, compelling rea
|
106
|
+
son to buy)
|
107
|
+
Unlike | (primary competitive alternative)
|
108
|
+
Our product | (statement of primary differentiation)
|
109
|
+
|
110
|
+
A product position statement communicates the intent of the application and the importance of the program to all stakeholders.
|
111
|
+
|
112
|
+
## 4.3 Summary of Capabilities
|
113
|
+
|
114
|
+
Summarize the major benefits and features the product will provide. Organize the features so that the list is understandable to any stakeholder. A simple table listing the key benefits and their supporting features, as shown below, might suffice.
|
115
|
+
|
116
|
+
Solution Features | Customer Benefit
|
117
|
+
:---------------- | :---------------
|
118
|
+
Feature 1 | Benefit 1
|
119
|
+
Feature 2 | Benefit 2
|
120
|
+
|
121
|
+
## 4.4 Assumptions and Dependencies
|
122
|
+
|
123
|
+
List any assumptions that, if changed, will alter the vision for the product.
|
124
|
+
|
125
|
+
## 4.5 Cost and Pricing
|
126
|
+
|
127
|
+
Describe any relevant cost and pricing constraints, because these can directly impact the solution definition and implementation.
|
128
|
+
|
129
|
+
# 5 Product Features
|
130
|
+
|
131
|
+
This section describes the intended product features. Features provide the system capabilities that are necessary to deliver benefits to the users. Feature descriptions should be short and pithy, a key phrase, perhaps followed by one or two sentences of explanation.
|
132
|
+
|
133
|
+
Use a level of abstraction high enough to be able to describe the system with a maximum of 25 to 50 features. Each feature should be perceivable by users, operators, or other external systems.
|
134
|
+
|
135
|
+
## 5.1 Feature 1
|
136
|
+
|
137
|
+
## 5.2 Feature 2
|
138
|
+
|
139
|
+
# 6 Exemplary Use Cases
|
140
|
+
|
141
|
+
[Optional] You may want to describe a few exemplary use cases, perhaps those that are architecturally significant or those that will most readily help the reader understand how the system is intended to be used.
|
142
|
+
|
143
|
+
# 7 Nonfunctional Requirements
|
144
|
+
|
145
|
+
This section records other system requirements including nonfunctional requirements (constraints) imposed on the system (see Chapter 17).
|
146
|
+
|
147
|
+
## 7.1 Usability
|
148
|
+
|
149
|
+
## 7.2 Reliability
|
150
|
+
|
151
|
+
## 7.3 Performance
|
152
|
+
|
153
|
+
## 7.4 Supportability
|
154
|
+
|
155
|
+
## 7.5 Other Requirements
|
156
|
+
|
157
|
+
### 7.5.1 Applicable Standards
|
158
|
+
|
159
|
+
List all standards the product must comply with, such as legal and regulatory, communications standards, platform compliance standards, and quality and safety standards.
|
160
|
+
|
161
|
+
### 7.5.2 System Requirements
|
162
|
+
|
163
|
+
Define any system requirements necessary to support the application. These may include the host operating systems and network platforms, configurations, communication, peripherals, and companion software.
|
164
|
+
|
165
|
+
### 7.5.3 Licensing, Security, and Installation
|
166
|
+
|
167
|
+
Licensing, security, and installation issues can also directly impact the development effort. Installation requirements may affect coding or create the need for separate installation software.
|
168
|
+
|
169
|
+
# 8 Documentation Requirements
|
170
|
+
|
171
|
+
This section describes the documentation that must be developed to support successful deployment and use.
|
172
|
+
|
173
|
+
## 8.1 User Manual
|
174
|
+
|
175
|
+
Describe the intent of the user manual. Discuss desired length, level of detail, need for index and glossary, tutorial versus reference manual strategy, and so on. Formatting, electronic distribution, and printing constraints should also be identified.
|
176
|
+
|
177
|
+
## 8.2 Online Help
|
178
|
+
|
179
|
+
The nature of these systems is unique to application development since they combine aspects of programming and hosting, such as hyperlinks and web services, with aspects of technical writing, such as organization, style, and presentation.
|
180
|
+
|
181
|
+
## 8.3 Installation Guides, Configuration, “Read Me” File
|
182
|
+
|
183
|
+
A document that includes installation instructions and configuration guidelines is typically necessary. Also, a “read me” file is often included as a standard component. The “read me” file may include a “What’s New with This Release” section and a discussion of compatibility issues with earlier releases. Most users also appreciate publication of any known defects and workarounds.
|
184
|
+
|
185
|
+
## 8.4 Labeling and Packaging
|
186
|
+
|
187
|
+
Defines the requirements for labeling to be incorporated into the code. Examples include copyright and patent notices, corporate logos, standardized icons, and other graphic elements.
|
188
|
+
|
189
|
+
## 9 Glossary
|
190
|
+
|
191
|
+
The glossary defines terms that are unique to the program. Include any acronyms or abbreviations that need to be understood by users or other readers.
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'clerq'
|
2
|
+
require 'thor'
|
3
|
+
require 'tmpdir'
|
4
|
+
require_relative 'lib/colonize_repo'
|
5
|
+
include Clerq::Repositories
|
6
|
+
include Clerq::Entities
|
7
|
+
include Clerq::Services
|
8
|
+
|
9
|
+
# This thor file sample was created with purpose to show some examples
|
10
|
+
# of using Pandoc for clerq reposiory publishing and even import souce
|
11
|
+
# documents into a clerq repository ... `thor clerq:doc:grab`, `thor clerq:doc:publish`
|
12
|
+
class ClerqDoc < Thor
|
13
|
+
include Thor::Actions
|
14
|
+
namespace 'clerq:doc'.to_sym
|
15
|
+
|
16
|
+
no_commands {
|
17
|
+
def eqid!(node)
|
18
|
+
counter = {}
|
19
|
+
node.to_a.drop(1).each do |n|
|
20
|
+
index = counter[n.parent] || 1
|
21
|
+
counter[n.parent] = index + 1
|
22
|
+
id = index.to_s.rjust(2, '0')
|
23
|
+
id = '.' + id unless n.parent == node
|
24
|
+
n.id = id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
}
|
28
|
+
|
29
|
+
# Why does one need to grab the document?
|
30
|
+
# it started in MS Word but the author decieded to pкoceed in Clerq
|
31
|
+
# it is the source for the clerq project, SRS based on Vision?
|
32
|
+
# something else?
|
33
|
+
# TODO provide -q/--query QUERY_STRING parameter
|
34
|
+
# TODO how about importing images?
|
35
|
+
desc 'grab FILENAME', 'Grab document and populate the clerq repository'
|
36
|
+
def grab(filename)
|
37
|
+
mdown = File.join(Dir.tmpdir, 'clerq.grab.md')
|
38
|
+
optns = [].tap{|o|
|
39
|
+
o << '--wrap=none'
|
40
|
+
o << '--atx-headers'
|
41
|
+
o << "#{filename}"
|
42
|
+
o << "-o #{mdown}"
|
43
|
+
}.join(' ')
|
44
|
+
|
45
|
+
`pandoc #{optns}`
|
46
|
+
|
47
|
+
on_error_callback = lambda {|err| puts err}
|
48
|
+
puts "Reading '#{mdown}'..."
|
49
|
+
|
50
|
+
# TODO handle query parameter
|
51
|
+
arry = ReadNode.(mdown, on_error_callback)
|
52
|
+
node = Node.new(id: '00', title: File.basename(mdown, '.md'))
|
53
|
+
arry.each{|n| node << n}
|
54
|
+
eqid!(node)
|
55
|
+
|
56
|
+
puts "Colonizing this repository..."
|
57
|
+
dir_counter = 0
|
58
|
+
src_counter = 0
|
59
|
+
on_create_dir = lambda {|dir| puts "Created '#{dir}' directory"; dir_counter += 1 }
|
60
|
+
on_create_src = lambda {|src| puts "Created '#{src}' file"; src_counter += 1 }
|
61
|
+
|
62
|
+
Dir.chdir(Clerq.src) { ColonizeRepo.(node, on_create_dir, on_create_src) }
|
63
|
+
|
64
|
+
msg = [].tap do |memo|
|
65
|
+
memo << "#{dir_counter} #{dir_counter == 1 ? 'directory' : 'directories'}" if dir_counter > 0
|
66
|
+
memo << "#{src_counter} #{src_counter == 1 ? 'file' : 'files'}" if src_counter > 0
|
67
|
+
end.join(' and ')
|
68
|
+
|
69
|
+
say "#{node.to_a.size} nodes from '#{filename}' imported to the repositroy. #{msg} created in the repository."
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'publish', 'Publishing final deliverables'
|
73
|
+
def publish
|
74
|
+
invoke :docx
|
75
|
+
invoke :html
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'html', 'Publish final deliverable in Html'
|
79
|
+
def html
|
80
|
+
source = File.join(Clerq.bin, Clerq.document + ".md")
|
81
|
+
target = File.join(Clerq.bin, Clerq.document + ".html")
|
82
|
+
optns = [].tap{|o|
|
83
|
+
o << '-s --toc --toc-depth 3'
|
84
|
+
o << "--resource-path #{Clerq.bin}"
|
85
|
+
o << "\"#{source}\""
|
86
|
+
o << "-o \"#{target}\""
|
87
|
+
}.join(" ")
|
88
|
+
|
89
|
+
`clerq build -t pandoc.md.erb`
|
90
|
+
`pandoc #{optns}`
|
91
|
+
say "\"#{target}\" created!"
|
92
|
+
end
|
93
|
+
|
94
|
+
desc 'docx', 'Publish final deliverable in Docx'
|
95
|
+
def docx
|
96
|
+
source = File.join(Clerq.bin, Clerq.document + ".md")
|
97
|
+
target = File.join(Clerq.bin, Clerq.document + ".docx")
|
98
|
+
sample = File.join(Clerq.bin, 'custom-reference.docx')
|
99
|
+
|
100
|
+
unless File.exist?(sample)
|
101
|
+
# produce a custom reference.docx
|
102
|
+
`pandoc -o #{sample} --print-default-data-file reference.docx`
|
103
|
+
end
|
104
|
+
|
105
|
+
optns = [].tap{|o|
|
106
|
+
o << '-s --toc --toc-depth 3'
|
107
|
+
o << '--from markdown+table_captions+implicit_figures'
|
108
|
+
o << "--reference-doc #{sample}"
|
109
|
+
o << "--resource-path #{Clerq.bin}"
|
110
|
+
o << "\"#{source}\""
|
111
|
+
o << "-o \"#{target}\""
|
112
|
+
}.join(" ")
|
113
|
+
|
114
|
+
`clerq build -t pandoc.md.erb`
|
115
|
+
`pandoc #{optns}`
|
116
|
+
say "\"#{target}\" created!"
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|