itamae-plugin-recipe-highlight 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55a224b40eead43e2019b3a8544b475e34cb396b3a11d4630d6a52ff5cf30428
4
- data.tar.gz: e13931058305a26dfe8f92254b766fd960b097ca44a16b8f4bc21c69889b00b9
3
+ metadata.gz: 2160685314e586f026eaf4e5f082bcb54e6b384f0b137ee7dc141825fe63c2ac
4
+ data.tar.gz: 212ac98b6198685f296f5f73ad047086b39b8e5bca74fc68a9a225dee7f03a95
5
5
  SHA512:
6
- metadata.gz: 92c536b2c5bd7385911105f63033464ff5b105e23703369d01d0ffdb4785b194e79d6c054d32de273fb349ef920b17714e3ad5cfca5c025e4f1dfac848e6d5e9
7
- data.tar.gz: a72add179fedb6db7722f5409dd4fa8d1f00fb24dbf2fe57f147295f4241d34c99a3564213ad86aabaddba9887bd16e1c1054ed0f3b3eed319d9850bfc9d85b7
6
+ metadata.gz: 8ad25864df90cf5ff7c36eb0f02c9e417a4c8ccca1e1d440451c08d2b40ca6e778e1648e13d2cb9e16f8307b38ee4b7c50905ee09e1213e07efcd55de7db592f
7
+ data.tar.gz: e71483e9ab2c9b6396db6e76eb09a42a3d885c0c5d210e353a4dc1a22d38b9c085186219b2d371ad1e1ce15e3def2c367790f92594ea1f627d4b2e7fa02e4fe6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
- ## [Unreleased]
1
+ # Change log for Itamae plugin recipe Highlight
2
2
 
3
- ## [0.1.0] - 2023-09-10
3
+ ## Unreleased
4
+
5
+ ## 0.3.0 - 2023-11-14
6
+
7
+ ### Changed
8
+
9
+ * Update Highlight version to v4.10.
10
+ * The role of `node[:highlight][:tmp]`.
11
+ It is now a prefix for temporary directory path, and the full path is auto generated.
12
+
13
+ ### Added
14
+
15
+ * `highlight` / `commands` / `wget` node attribute.
16
+ [GNU Wget][wget] is used for downloading the archive file.
17
+
18
+ [wget]: https://www.gnu.org/software/wget/
19
+
20
+ ### Fixed
21
+
22
+ * Changed to use GNU Wget instead of the Itamae's HTTP request resource since updating archive files might somehow fail.
23
+
24
+ ## 0.2.0 - 2023-09-11
25
+
26
+ ### Added
27
+
28
+ * Node attributes: `highlight` / `command`, `highlight` / `commands` / `grep`, `highlight` / `commands` / `tar`, and `highlight` / `commands` / `type`.
29
+ * Node attributes validation
30
+
31
+ ### Fixed
32
+
33
+ * Skip some steps when the `makefile` exists.
34
+ * Skip downloading the signature when it exists.
35
+ * Skip fetching the public key when it's already imported.
36
+
37
+ ## 0.1.0 - 2023-09-10
4
38
 
5
39
  - Initial release
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Itamae::Plugin::Recipe::Highlight
2
2
 
3
- itamae-plugin-recipe-highlight gem installs [Highlight][], according to [its download page][dl].
3
+ itamae-plugin-recipe-highlight gem installs [Highlight][].
4
4
 
5
- [dl]: http://www.andre-simon.de/zip/download.php
6
5
  [Highlight]: http://www.andre-simon.de/doku/highlight/en/highlight.php
7
6
 
8
7
  ## Installation
@@ -23,7 +22,10 @@ gem install itamae-plugin-recipe-highlight
23
22
 
24
23
  ## Usage
25
24
 
26
- It installs command line interface by default.
25
+ It installs command line interface `highlight` by default.
26
+ Some configulations can be done by setting [the node attributes][attrs].
27
+
28
+ [attrs]: https://github.com/itamae-kitchen/itamae/wiki/Node-Attributes
27
29
 
28
30
  ```ruby
29
31
  include_recipe "highlight"
@@ -32,7 +34,6 @@ include_recipe "highlight"
32
34
  ## Development
33
35
 
34
36
  After checking out the repo, run `bin/setup` to install dependencies.
35
- Then, run `rake test-unit` to run the tests.
36
37
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
38
 
38
39
  To install this gem onto your local machine, run `bundle exec rake install`.
@@ -46,6 +47,6 @@ Bug reports and pull requests are welcome on [Codeberg][].
46
47
 
47
48
  ## License
48
49
 
49
- This gem is provided under [the Apache License version 2.0][apache].
50
+ This gem is released under [the Apache License version 2.0][apache].
50
51
 
51
52
  [apache]: https://www.apache.org/licenses/LICENSE-2.0
@@ -1,96 +1,148 @@
1
1
  require 'shellwords'
2
2
  require 'uri'
3
3
 
4
- node['highlight'] ||= {}
5
- node['highlight']['dependencies'] ||= {}
6
- node['highlight']['commands'] ||= {}
7
-
8
- tmp = node['highlight']['tmp'] || '/tmp'
9
- version = node['highlight']['version'] || '4.8'
10
- lua = node['highlight']['dependencies']['lua'] || 'liblua5.4-dev'
11
- boost = node['highlight']['dependencies']['boost'] || 'libboost-dev'
12
- gpg = node['highlight']['commands']['gpg'] || 'gpg'
13
- make = node['highlight']['commands']['make'] || 'make'
14
-
15
- verify = node['highlight']['verify']
16
- verify = true if verify.nil?
17
- verify = false if verify == 'false'
18
-
19
- version_grep_command = ['grep', "highlight version #{ version }"].shelljoin
20
- version_check_command = "highlight --version | #{ version_grep_command }"
21
-
22
- directory tmp do
23
- not_if 'type highlight'
24
- not_if version_check_command
4
+ node.reverse_merge!(
5
+ {
6
+ highlight: {
7
+ tmp: '/tmp',
8
+ version: '4.10',
9
+ command: 'highlight',
10
+ verify: true,
11
+ dependencies: {
12
+ lua: 'liblua5.4-dev',
13
+ boost: 'libboost-dev'
14
+ },
15
+ commands: {
16
+ gpg: 'gpg',
17
+ grep: 'grep',
18
+ make: 'make',
19
+ tar: 'tar',
20
+ test: 'test',
21
+ type: 'type',
22
+ wget: 'wget',
23
+ }
24
+ }
25
+ }
26
+ )
27
+
28
+ node.validate! do
29
+ {
30
+ highlight: {
31
+ tmp: string,
32
+ version: string,
33
+ command: string,
34
+ verify: boolean,
35
+ dependencies: {
36
+ lua: string,
37
+ boost: string,
38
+ },
39
+ commands: {
40
+ gpg: string,
41
+ grep: string,
42
+ make: string,
43
+ tar: string,
44
+ type: string,
45
+ wget: string,
46
+ }
47
+ }
48
+ }
25
49
  end
26
50
 
27
- archive_file_name = "highlight-#{ version }.tar.bz2"
28
- archive_file_path = File.join(tmp, archive_file_name)
29
- download_root_url = 'http://www.andre-simon.de/zip/'
51
+ command_exists = [node[:highlight][:commands][:type], node[:highlight][:command]].shelljoin
30
52
 
31
- http_request archive_file_path do
32
- url URI.join(download_root_url, archive_file_name).to_s
53
+ grep_version = [node[:highlight][:commands][:grep], "highlight version #{ node[:highlight][:version] }"].shelljoin
54
+ print_version = [node[:highlight][:command], '--version'].shelljoin
55
+ updated = "#{ print_version } | #{ grep_version }"
33
56
 
34
- not_if 'type highlight'
35
- not_if version_check_command
36
- end
57
+ Dir.mktmpdir(node[:highlight][:tmp]) do |tmp_dir|
58
+ source_dir = File.join(tmp_dir, "highlight-#{ node[:highlight][:version] }")
59
+ makefile_exists = [node[:highlight][:commands][:test], '-f', File.join(source_dir, 'makefile')].shelljoin
37
60
 
38
- if verify
39
- signature_name = "highlight-#{ version }.tar.bz2.asc"
40
- signature_path = File.join(tmp, signature_name)
61
+ archive_file_name = "highlight-#{ node[:highlight][:version] }.tar.bz2"
62
+ archive_file_path = File.join(tmp_dir, archive_file_name)
63
+ download_root_url = 'http://www.andre-simon.de/zip/'
41
64
 
42
- http_request signature_path do
43
- url URI.join(download_root_url, signature_name).to_s
65
+ directory tmp_dir
44
66
 
45
- not_if 'type highlight'
46
- not_if version_check_command
47
- end
67
+ package 'wget'
48
68
 
49
- execute 'receive key' do
50
- command [gpg, '--keyserver', 'pgp.mit.edu', '--recv-key', 'D805A7C7'].shelljoin
69
+ execute 'download archive file' do
70
+ cwd tmp_dir
71
+ download = [node[:highlight][:commands][:wget], URI.join(download_root_url, archive_file_name).to_s].shelljoin
72
+ command download
51
73
 
52
- not_if 'type highlight'
53
- not_if version_check_command
74
+ not_if command_exists
75
+ not_if updated
76
+ not_if makefile_exists
54
77
  end
55
78
 
56
- execute 'verify' do
57
- command [gpg, '--verify', signature_path, archive_file_path].shelljoin
79
+ if node[:highlight][:verify]
80
+ signature_name = "highlight-#{ node[:highlight][:version] }.tar.bz2.asc"
81
+ signature_path = File.join(tmp_dir, signature_name)
58
82
 
59
- not_if 'type highlight'
60
- not_if version_check_command
61
- end
62
- end
83
+ http_request signature_path do
84
+ url URI.join(download_root_url, signature_name).to_s
63
85
 
64
- execute 'extract' do
65
- command ['tar', 'axf', archive_file_path].shelljoin
66
- cwd tmp
86
+ not_if command_exists
87
+ not_if updated
88
+ not_if [node[:highlight][:commands][:test], '-f', signature_path].shelljoin
89
+ end
67
90
 
68
- not_if 'type highlight'
69
- not_if version_check_command
70
- end
91
+ execute 'receive key' do
92
+ key_id = 'D805A7C7'
93
+
94
+ fetch_key = [node[:highlight][:commands][:gpg], '--keyserver', 'pgp.mit.edu', '--recv-key', key_id].shelljoin
95
+ command fetch_key
96
+
97
+ not_if command_exists
98
+ not_if updated
99
+
100
+ export_public_key = [node[:highlight][:commands][:gpg], '--export', '--armor', key_id].shelljoin
101
+ check_not_yet_imported = [node[:highlight][:commands][:grep], 'nothing exported'].shelljoin
102
+ only_if "#{ export_public_key } | #{ check_not_yet_imported }"
103
+ end
71
104
 
72
- [lua, boost].each do |pack|
73
- package pack do
105
+ execute 'verify' do
106
+ verify_archive = [node[:highlight][:commands][:gpg], '--verify', signature_path, archive_file_path].shelljoin
107
+ command verify_archive
74
108
 
75
- not_if 'type highlight'
76
- not_if version_check_command
109
+ not_if command_exists
110
+ not_if updated
111
+ end
77
112
  end
78
- end
79
113
 
80
- source_dir = File.join(tmp, "highlight-#{ version }")
114
+ execute 'extract' do
115
+ extract_archive = [node[:highlight][:commands][:tar], 'axf', archive_file_path].shelljoin
116
+ command extract_archive
117
+ cwd tmp_dir
81
118
 
82
- execute 'compile' do
83
- command [make, 'cli'].shelljoin
84
- cwd source_dir
119
+ not_if command_exists
120
+ not_if updated
121
+ not_if makefile_exists
122
+ end
85
123
 
86
- not_if 'type highlight'
87
- not_if version_check_command
88
- end
124
+ [node[:highlight][:dependencies][:lua], node[:highlight][:dependencies][:boost]].each do |pack|
125
+ package pack do
126
+ not_if command_exists
127
+ not_if updated
128
+ end
129
+ end
89
130
 
90
- execute 'install' do
91
- command [make, 'install'].shelljoin
92
- cwd source_dir
131
+ execute 'compile' do
132
+ compile_cli = [node[:highlight][:commands][:make], 'cli'].shelljoin
133
+ command compile_cli
134
+ cwd source_dir
93
135
 
94
- not_if 'type highlight'
95
- not_if version_check_command
136
+ not_if command_exists
137
+ not_if updated
138
+ end
139
+
140
+ execute 'install' do
141
+ install_files = [node[:highlight][:commands][:make], 'install'].shelljoin
142
+ command install_files
143
+ cwd source_dir
144
+
145
+ not_if command_exists
146
+ not_if updated
147
+ end
96
148
  end
@@ -2,7 +2,7 @@ module Itamae
2
2
  module Plugin
3
3
  module Recipe
4
4
  module Highlight
5
- VERSION = '0.1.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
8
8
  end
@@ -5,7 +5,6 @@ module Itamae
5
5
  module Recipe
6
6
  module Highlight
7
7
  class Error < StandardError; end
8
- # Your code goes here...
9
8
  end
10
9
  end
11
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-plugin-recipe-highlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gemmaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-10 00:00:00.000000000 Z
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae