itamae-plugin-recipe-highlight 0.1.0 → 0.2.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: b1d2e267ae55d36488f4df5ae57d5c694ec8ce0d278d5d49b89b3c03815ea4d9
4
+ data.tar.gz: '098472c06e01065d04ec2d9a77e3dbdcc73025fc00910aad8a6de97b44fae4ea'
5
5
  SHA512:
6
- metadata.gz: 92c536b2c5bd7385911105f63033464ff5b105e23703369d01d0ffdb4785b194e79d6c054d32de273fb349ef920b17714e3ad5cfca5c025e4f1dfac848e6d5e9
7
- data.tar.gz: a72add179fedb6db7722f5409dd4fa8d1f00fb24dbf2fe57f147295f4241d34c99a3564213ad86aabaddba9887bd16e1c1054ed0f3b3eed319d9850bfc9d85b7
6
+ metadata.gz: c7afc0742d8d19f72904a5d23c2d1cda086a6f83bdaea22d063cc02e1decbf9772bd6029767a62abbef013db428a6d664be19bb29c58ca1096d515bdd2e93d93
7
+ data.tar.gz: 31b7c7c97f3b0877ca0298fb82bee46c5a39ad9a448a92c7761fe865a22822f16e5d38bae0707812f398f8009a0f538b407d222c7ddb2a941ec9f3993270b18e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2023-09-11
4
+
5
+ ### Added
6
+
7
+ * Node attributes: `highlight` / `command`, `highlight` / `commands` / `grep`, `highlight` / `commands` / `tar`, and `highlight` / `commands` / `type`.
8
+ * Node attributes validation
9
+
10
+ ### Fixed
11
+
12
+ * Skip some steps when the `makefile` exists.
13
+ * Skip downloading the signature when it exists.
14
+ * Skip fetching the public key when it's already imported.
15
+
3
16
  ## [0.1.0] - 2023-09-10
4
17
 
5
18
  - 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,27 +1,75 @@
1
1
  require 'shellwords'
2
2
  require 'uri'
3
3
 
4
- node['highlight'] ||= {}
5
- node['highlight']['dependencies'] ||= {}
6
- node['highlight']['commands'] ||= {}
4
+ defaults = {
5
+ highlight: {
6
+ tmp: '/tmp',
7
+ version: '4.8',
8
+ command: 'highlight',
9
+ verify: true,
10
+ dependencies: {
11
+ lua: 'liblua5.4-dev',
12
+ boost: 'libboost-dev'
13
+ },
14
+ commands: {
15
+ gpg: 'gpg',
16
+ grep: 'grep',
17
+ make: 'make',
18
+ tar: 'tar',
19
+ test: 'test',
20
+ type: 'type',
21
+ }
22
+ }
23
+ }
24
+
25
+ node.replace(defaults.merge(node))
26
+
27
+ node.validate! do
28
+ {
29
+ highlight: {
30
+ tmp: string,
31
+ version: string,
32
+ command: string,
33
+ verify: boolean,
34
+ dependencies: {
35
+ lua: string,
36
+ boost: string,
37
+ },
38
+ commands: {
39
+ gpg: string,
40
+ grep: string,
41
+ make: string,
42
+ tar: string,
43
+ type: string,
44
+ }
45
+ }
46
+ }
47
+ end
48
+
49
+ tmp = node.dig(:highlight, :tmp)
50
+
51
+ command = node.dig(:highlight, :command)
52
+
53
+ command_exists = [node.dig(:highlight, :commands, :type), command].shelljoin
54
+
55
+ version = node.dig(:highlight, :version)
56
+
57
+ grep = node.dig(:highlight, :commands, :grep)
7
58
 
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'
59
+ grep_version = [grep, "highlight version #{ version }"].shelljoin
60
+ print_version = [command, '--version'].shelljoin
61
+ updated = "#{ print_version } | #{ grep_version }"
14
62
 
15
- verify = node['highlight']['verify']
16
- verify = true if verify.nil?
17
- verify = false if verify == 'false'
63
+ test = node.dig(:highlight, :commands, :test)
18
64
 
19
- version_grep_command = ['grep', "highlight version #{ version }"].shelljoin
20
- version_check_command = "highlight --version | #{ version_grep_command }"
65
+ source_dir = File.join(tmp, "highlight-#{ version }")
66
+ makefile = File.join(source_dir, 'makefile')
67
+ makefile_exists = [test, '-f', makefile].shelljoin
21
68
 
22
69
  directory tmp do
23
- not_if 'type highlight'
24
- not_if version_check_command
70
+ not_if command_exists
71
+ not_if updated
72
+ not_if makefile_exists
25
73
  end
26
74
 
27
75
  archive_file_name = "highlight-#{ version }.tar.bz2"
@@ -31,66 +79,85 @@ download_root_url = 'http://www.andre-simon.de/zip/'
31
79
  http_request archive_file_path do
32
80
  url URI.join(download_root_url, archive_file_name).to_s
33
81
 
34
- not_if 'type highlight'
35
- not_if version_check_command
82
+ not_if command_exists
83
+ not_if updated
84
+ not_if makefile_exists
36
85
  end
37
86
 
38
- if verify
87
+ if node.dig(:highlight, :verify)
39
88
  signature_name = "highlight-#{ version }.tar.bz2.asc"
40
89
  signature_path = File.join(tmp, signature_name)
41
90
 
42
91
  http_request signature_path do
43
92
  url URI.join(download_root_url, signature_name).to_s
44
93
 
45
- not_if 'type highlight'
46
- not_if version_check_command
94
+ not_if command_exists
95
+ not_if updated
96
+ not_if [test, '-f', signature_path].shelljoin
47
97
  end
48
98
 
99
+ gpg = node.dig(:highlight, :commands, :gpg)
100
+
49
101
  execute 'receive key' do
50
- command [gpg, '--keyserver', 'pgp.mit.edu', '--recv-key', 'D805A7C7'].shelljoin
102
+ key_id = 'D805A7C7'
103
+
104
+ fetch_key = [gpg, '--keyserver', 'pgp.mit.edu', '--recv-key', key_id].shelljoin
105
+ command fetch_key
51
106
 
52
- not_if 'type highlight'
53
- not_if version_check_command
107
+ not_if command_exists
108
+ not_if updated
109
+
110
+ export_public_key = [gpg, '--export', '--armor', key_id].shelljoin
111
+ check_not_yet_imported = [grep, 'nothing exported'].shelljoin
112
+ only_if "#{ export_public_key } | #{ check_not_yet_imported }"
54
113
  end
55
114
 
56
115
  execute 'verify' do
57
- command [gpg, '--verify', signature_path, archive_file_path].shelljoin
116
+ verify_archive = [gpg, '--verify', signature_path, archive_file_path].shelljoin
117
+ command verify_archive
58
118
 
59
- not_if 'type highlight'
60
- not_if version_check_command
119
+ not_if command_exists
120
+ not_if updated
61
121
  end
62
122
  end
63
123
 
64
124
  execute 'extract' do
65
- command ['tar', 'axf', archive_file_path].shelljoin
125
+ extract_archive = [node.dig(:highlight, :commands, :tar), 'axf', archive_file_path].shelljoin
126
+ command extract_archive
66
127
  cwd tmp
67
128
 
68
- not_if 'type highlight'
69
- not_if version_check_command
129
+ not_if command_exists
130
+ not_if updated
131
+ not_if makefile_exists
70
132
  end
71
133
 
134
+ lua = node.dig(:highlight, :dependencies, :lua)
135
+ boost = node.dig(:highlight, :dependencies, :boost)
136
+
72
137
  [lua, boost].each do |pack|
73
138
  package pack do
74
139
 
75
- not_if 'type highlight'
76
- not_if version_check_command
140
+ not_if command_exists
141
+ not_if updated
77
142
  end
78
143
  end
79
144
 
80
- source_dir = File.join(tmp, "highlight-#{ version }")
145
+ make = node.dig(:highlight, :commands, :make)
81
146
 
82
147
  execute 'compile' do
83
- command [make, 'cli'].shelljoin
148
+ compile_cli = [make, 'cli'].shelljoin
149
+ command compile_cli
84
150
  cwd source_dir
85
151
 
86
- not_if 'type highlight'
87
- not_if version_check_command
152
+ not_if command_exists
153
+ not_if updated
88
154
  end
89
155
 
90
156
  execute 'install' do
91
- command [make, 'install'].shelljoin
157
+ install_files = [make, 'install'].shelljoin
158
+ command install_files
92
159
  cwd source_dir
93
160
 
94
- not_if 'type highlight'
95
- not_if version_check_command
161
+ not_if command_exists
162
+ not_if updated
96
163
  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.2.0'
6
6
  end
7
7
  end
8
8
  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.2.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-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae