asciidoctor-jenkins-extensions 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bb1de6bbfef89d0eca8d18655598ad6b506579e4
4
+ data.tar.gz: 048acf1c7f174f52868c244abdc4956e4c36df5c
5
+ SHA512:
6
+ metadata.gz: d3a2f33d658a5b66bc8de2d39cd47de3d82b5fb99572417fa1f08e9e9e229b2b5076ab00c5f4b86c061e968b4a15b75406a96c2f031cb0899aa9ab8a92afb5f2
7
+ data.tar.gz: 4dab70e2a1c188b719910b5b2a754e3ce68392b2ca372e0c18ec2a108a83ea34d01ff7289277197cae9b0e2148339e33a29cbf8e63ef683b0d860a22af01422d
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'asciidoctor/jenkins/extensions/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "asciidoctor-jenkins-extensions"
8
+ spec.version = Asciidoctor::Jenkins::Extensions::VERSION
9
+ spec.authors = ["R. Tyler Croy"]
10
+ spec.email = ["tyler@monkeypox.org"]
11
+
12
+ spec.summary = "a collection of Asciidoctor extensions which enable more advanced
13
+ formatting in Jenkins-related content.
14
+ "
15
+ spec.description = "a collection of Asciidoctor extensions which enable more advanced
16
+ formatting in Jenkins-related content.
17
+ "
18
+ spec.homepage = 'https://github.com/jenkins-infra/asciidoctor-jenkins-extensions'
19
+
20
+
21
+ root = File.dirname(__FILE__)
22
+ spec.files = Dir.glob("#{root}/lib/**/*.rb").map { |f| f.gsub("#{root}/", '') }
23
+ spec.files << File.basename(__FILE__)
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+
29
+ spec.add_dependency 'asciidoctor', '~> 1.5.5'
30
+ spec.add_dependency 'coderay', '~> 1.1.1'
31
+ spec.add_dependency 'colorize', '~> 0.8.1'
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.11"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ spec.add_development_dependency "rspec-its"
37
+ spec.add_development_dependency 'pry'
38
+ spec.add_development_dependency 'ci_reporter', '~> 2.0'
39
+ spec.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
40
+ end
@@ -0,0 +1,10 @@
1
+ module Asciidoctor
2
+ module Jenkins
3
+ module Extensions
4
+ end
5
+ end
6
+ end
7
+
8
+ Dir.glob("#{File.dirname(__FILE__)}/extensions/**/*.rb").each do |f|
9
+ require f
10
+ end
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'colorize'
4
+ require 'asciidoctor/extensions'
5
+ require 'coderay'
6
+
7
+ Asciidoctor::Extensions.register do
8
+ block do
9
+ named :pipeline
10
+ on_context :listing
11
+ name_positional_attributes 'format'
12
+
13
+ process do |parent, reader, attrs|
14
+ format = (attrs.delete('format') || '')
15
+ codelines = reader.lines()
16
+ script = nil
17
+ declarative = nil
18
+
19
+ # Find where our "// Script" comment is for highlighting the Pipeline
20
+ # Script syntax
21
+ script_index = codelines.find_index { |c| c.match(/\/\/ (script)(.*)?\/\//i) } || -1
22
+ decl_index = codelines.find_index { |c| c.match(/\/\/ (declarative)(.*)?\/\//i) } || -1
23
+
24
+ # It would be great to re-use the [source] block styling, but it turns
25
+ # out that our parser is going to delete WHATEVER style attribute we
26
+ # would give the block if we used #create_listing_block()
27
+ #
28
+ # Ouch: <https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/parser.rb#L1086-L1087>
29
+ snippet = ['<div class="pipeline-block">']
30
+
31
+ if decl_index >= 0
32
+ # Default to reading until the end of codelines
33
+ last_line = -1
34
+
35
+ if script_index > decl_index
36
+ last_line = script_index - 1
37
+ end
38
+ declarative = codelines[(decl_index + 1) .. last_line].join("\n").chomp
39
+
40
+ # If the declarative block is empty, we should just pretend it doesn't
41
+ # exist. This is helpful for making notes/todos where Declarative isn't
42
+ # applicable
43
+ if declarative.empty?
44
+ declarative = nil
45
+ else
46
+ declarative = CodeRay::Duo[:groovy, :html, {:css => :style}].highlight(declarative)
47
+ declarative = declarative.gsub(/\/\/ +&lt;(\d+)&gt;/) {
48
+ m = $~
49
+ parent.document.callouts.register(m[1])
50
+ create_inline(parent, :callout, m[1], :id => parent.document.callouts.read_next_id).convert
51
+ }
52
+
53
+ snippet << <<-EOF
54
+ <div class="listingblock pipeline-declarative">
55
+ <div class="title">Jenkinsfile (Declarative Pipeline)</div>
56
+ <div class="content">
57
+ EOF
58
+ snippet << <<-EOF
59
+ <pre class="CodeRay highlight nowrap"><code class="language-groovy" data-lang="groovy">#{declarative}</code></pre>
60
+ EOF
61
+ snippet << '</div></div>'
62
+ end
63
+ end
64
+
65
+ if script_index >= 0
66
+ # Default to reading until the end of codelines
67
+ last_line = -1
68
+
69
+ # If our decl_index is lower than script_index, that means Declarative
70
+ # was listed first, so we need to stop short of it
71
+ if decl_index > script_index
72
+ last_line = decl_index - 1
73
+ end
74
+
75
+ script = codelines[(script_index + 1) .. last_line].join("\n").chomp
76
+
77
+ # If the script block is empty, we should just pretend it doesn't
78
+ # exist. This is helpful for highlighting blocks where a script example
79
+ # is yet to be written
80
+ unless script.empty?
81
+ # Since we have a declarative block, let's show that by default and
82
+ # hide this but leave a bread-crumb
83
+ unless declarative.nil?
84
+ snippet << <<-EOF
85
+ <div class="pipeline-script-expand">
86
+ <a href="#" onclick="javascript:$(this).parent().siblings('.pipeline-script').toggle(); return false;">Toggle Scripted Pipeline</a>
87
+ <em>(Advanced)</em>
88
+ </div>
89
+ EOF
90
+ end
91
+
92
+ script = CodeRay::Duo[:groovy, :html, {:css => :style}].highlight(script)
93
+ script = script.gsub(/\/\/ +&lt;(\d+)&gt;/) {
94
+ m = $~
95
+ parent.document.callouts.register(m[1])
96
+ create_inline(parent, :callout, m[1], :id => parent.document.callouts.read_next_id).convert
97
+ }
98
+
99
+ snippet << <<-EOF
100
+ <div class="listingblock pipeline-script"
101
+ style="display: #{(declarative.nil? or 'none') or 'inherit'}">
102
+ <div class="title">Jenkinsfile (Scripted Pipeline)</div>
103
+ <div class="content">
104
+ EOF
105
+ snippet << <<-EOF
106
+ <pre class="CodeRay highlight nowrap"><code class="language-groovy" data-lang="groovy">#{script}</code></pre>
107
+ EOF
108
+ snippet << '</div></div>'
109
+ end
110
+ end
111
+
112
+ snippet << '</div>'
113
+
114
+ # Fortunately Awestruct sets a handy docfile attribute so we can print a
115
+ # useful warning
116
+ docfile = parent.document.attributes['docfile']
117
+
118
+ if script_index < 0
119
+ $stderr.puts "WARNING: [pipeline] block lacks `// Script //` section in #{docfile}".red
120
+ end
121
+
122
+ if decl_index < 0
123
+ $stderr.puts "WARNING: [pipeline] block lacks `// Declarative //` section in #{docfile}".red
124
+ end
125
+
126
+ create_pass_block(parent, snippet.join(''), attrs)
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,7 @@
1
+ module Asciidoctor
2
+ module Jenkins
3
+ module Extensions
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asciidoctor-jenkins-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - R. Tyler Croy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asciidoctor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.5.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: coderay
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-its
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: ci_reporter
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: ci_reporter_rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.0'
153
+ description: |
154
+ a collection of Asciidoctor extensions which enable more advanced
155
+ formatting in Jenkins-related content.
156
+ email:
157
+ - tyler@monkeypox.org
158
+ executables: []
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - asciidoctor-jenkins-extensions.gemspec
163
+ - lib/asciidoctor/jenkins/extensions.rb
164
+ - lib/asciidoctor/jenkins/extensions/pipeline-block.rb
165
+ - lib/asciidoctor/jenkins/extensions/version.rb
166
+ homepage: https://github.com/jenkins-infra/asciidoctor-jenkins-extensions
167
+ licenses: []
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.5.1
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: a collection of Asciidoctor extensions which enable more advanced formatting
189
+ in Jenkins-related content.
190
+ test_files: []