job_spec 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/example_out/engineer.md +15 -0
- data/example_out/senior_engineer.md +7 -0
- data/job_spec.gemspec +2 -2
- data/lib/job_spec/adhoc_expectations.rb +54 -0
- data/lib/job_spec/cli.rb +1 -0
- data/lib/job_spec/role.rb +16 -3
- data/lib/job_spec/version.rb +1 -1
- data/lib/job_spec.rb +1 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 245a315b2ac01afe6198c8a94ca548d29f3f9ea2bfc75c4fb2ed965dfff25e17
|
4
|
+
data.tar.gz: b80f2205ba9a3b6dcf0cab71fb3253cd5c2629c4afdd43d7c07286d90c5fcd22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69e12a3600e616f3c787beb73d2ca7599fd26ee2f7ae8960b289b9e913583a41a615b77696aedbf75b46bd843f64c355fea1046f1d90b44971a7dac1e324136
|
7
|
+
data.tar.gz: 63fe1f1ea5c04ff1a40c79b5f89ea4cab76cc0e067c863f7aab7df41aab416b97c41a41e61dc213ff9f78f03e8f3fb80d324124f3f24e5e601f0b40d56245a14
|
data/job_spec.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.join(LIB, 'job_spec/version')
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'job_spec'
|
6
6
|
spec.version = JobSpec::VERSION
|
7
|
-
spec.authors = ['Luke Morton']
|
8
|
-
spec.email = ['luke@madetech.com']
|
7
|
+
spec.authors = ['Luke Morton', 'Craig J. Bass']
|
8
|
+
spec.email = ['luke@madetech.com', 'craig@madetech.com']
|
9
9
|
|
10
10
|
spec.summary = %q{Define job specs in ruby and publish to markdown}
|
11
11
|
spec.homepage = 'https://github.com/madetech/job_spec'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module JobSpec
|
2
|
+
class AdhocExpectations
|
3
|
+
def self.clear!
|
4
|
+
@expectations = nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.define(expectation, &block)
|
8
|
+
@expectations ||= []
|
9
|
+
@expectations << new(expectation, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.roles
|
13
|
+
roles = {}
|
14
|
+
@expectations.each do |expectation|
|
15
|
+
expectation.to_a.each do |role_expectation|
|
16
|
+
roles[role_expectation[:role]] ||= {
|
17
|
+
name: role_expectation[:role],
|
18
|
+
expectations: []
|
19
|
+
}
|
20
|
+
|
21
|
+
roles[role_expectation[:role]][:expectations] << {
|
22
|
+
expectation: role_expectation[:expectation],
|
23
|
+
description: role_expectation[:description]
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
roles.values
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(expectation, &block)
|
31
|
+
@expectation = expectation
|
32
|
+
@block = block
|
33
|
+
instance_eval(&block) unless block.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def description(description)
|
37
|
+
@description = description
|
38
|
+
end
|
39
|
+
|
40
|
+
def roles(*roles)
|
41
|
+
@roles = roles
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_a
|
45
|
+
@roles.map do |role|
|
46
|
+
{
|
47
|
+
role: role,
|
48
|
+
expectation: @expectation,
|
49
|
+
description: @description
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/job_spec/cli.rb
CHANGED
@@ -13,6 +13,7 @@ module JobSpec
|
|
13
13
|
end
|
14
14
|
|
15
15
|
FileUtils.mkdir_p(path_relative_to_pwd(options[:out]))
|
16
|
+
JobSpec::Role.add_expectations(JobSpec::AdhocExpectations.roles)
|
16
17
|
Role.definitions.each do |role|
|
17
18
|
puts "Saving #{role.name} to #{safe_role_out_path(role)}..."
|
18
19
|
File.write(safe_role_out_path(role), RenderAsMarkdown.new(role).render)
|
data/lib/job_spec/role.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
module JobSpec
|
2
2
|
class Role
|
3
3
|
def self.definition(name, &block)
|
4
|
-
@definitions ||=
|
5
|
-
@definitions
|
4
|
+
@definitions ||= {}
|
5
|
+
@definitions[name] = new(name, &block)
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.definitions
|
9
|
-
@definitions
|
9
|
+
@definitions.values
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.add_expectations(role_expectations)
|
13
|
+
expectation = role_expectations.first[:expectations].first
|
14
|
+
|
15
|
+
role_expectations.each do |role_expectation|
|
16
|
+
role = @definitions[role_expectation[:name]]
|
17
|
+
role_expectation[:expectations].each do |e|
|
18
|
+
role.expected(e[:expectation], e[:description])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
nil
|
10
23
|
end
|
11
24
|
|
12
25
|
def initialize(name, &block)
|
data/lib/job_spec/version.rb
CHANGED
data/lib/job_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: job_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Morton
|
8
|
+
- Craig J. Bass
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -69,6 +70,7 @@ dependencies:
|
|
69
70
|
description:
|
70
71
|
email:
|
71
72
|
- luke@madetech.com
|
73
|
+
- craig@madetech.com
|
72
74
|
executables:
|
73
75
|
- jobspec
|
74
76
|
extensions: []
|
@@ -80,8 +82,11 @@ files:
|
|
80
82
|
- README.md
|
81
83
|
- Rakefile
|
82
84
|
- bin/jobspec
|
85
|
+
- example_out/engineer.md
|
86
|
+
- example_out/senior_engineer.md
|
83
87
|
- job_spec.gemspec
|
84
88
|
- lib/job_spec.rb
|
89
|
+
- lib/job_spec/adhoc_expectations.rb
|
85
90
|
- lib/job_spec/cli.rb
|
86
91
|
- lib/job_spec/render_as_markdown.rb
|
87
92
|
- lib/job_spec/role.rb
|
@@ -106,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
111
|
version: '0'
|
107
112
|
requirements: []
|
108
113
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.7.3
|
110
115
|
signing_key:
|
111
116
|
specification_version: 4
|
112
117
|
summary: Define job specs in ruby and publish to markdown
|