rspec-pgp_matchers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/pgp_matchers"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../.."
4
+
5
+ gem "codecov", require: false
6
+ gem "simplecov", require: false
@@ -0,0 +1,5 @@
1
+ # rubocop:disable Security/Eval
2
+ eval File.read(File.expand_path("common.gemfile", __dir__))
3
+ # rubocop:enable Security/Eval
4
+
5
+ gem "rspec-expectations", "~> 3.4.0"
@@ -0,0 +1,5 @@
1
+ # rubocop:disable Security/Eval
2
+ eval File.read(File.expand_path("common.gemfile", __dir__))
3
+ # rubocop:enable Security/Eval
4
+
5
+ gem "rspec-expectations", "~> 3.5.0"
@@ -0,0 +1,5 @@
1
+ # rubocop:disable Security/Eval
2
+ eval File.read(File.expand_path("common.gemfile", __dir__))
3
+ # rubocop:enable Security/Eval
4
+
5
+ gem "rspec-expectations", "~> 3.6.0"
@@ -0,0 +1,5 @@
1
+ # rubocop:disable Security/Eval
2
+ eval File.read(File.expand_path("common.gemfile", __dir__))
3
+ # rubocop:enable Security/Eval
4
+
5
+ gem "rspec-expectations", "~> 3.7.0"
@@ -0,0 +1,137 @@
1
+ #!/bin/bash
2
+
3
+ # Popular combinations of GPG software versions.
4
+ #
5
+ # For v2.2: https://gist.github.com/vt0r/a2f8c0bcb1400131ff51
6
+ # For v2.1: https://gist.github.com/mattrude/3883a3801613b048d45b
7
+ #
8
+ # USAGE:
9
+ # ./install_gpg_all.sh <version> [<options>]
10
+ #
11
+ # EXAMPLE
12
+ # ./install_gpg_all.sh 2.2
13
+
14
+ set -e
15
+
16
+ readonly __progname=$(basename $0)
17
+
18
+ errx() {
19
+ echo -e "$__progname: $@" >&2
20
+ exit 1
21
+ }
22
+
23
+ usage() {
24
+ echo "usage: $__progname [-t <TEMP_BUILD_DIR>] [-i <GPG_VERSION>] [-d]"
25
+ echo ""
26
+ echo " Options:"
27
+ echo " -d for dry run, not building GPG components."
28
+ echo " -i to select the GPG version to install [major.minor], defaults to `latest`."
29
+ echo " - `latest`: latest version of GnuPG."
30
+ echo " - `x.y`: specific version x.y of GnuPG, e.g. `2.2`."
31
+ echo " - `master`: build from GnuPG git master branch."
32
+ echo " -h to display this message"
33
+ echo ""
34
+ echo " Arguments can also be set via environment variables: "
35
+ echo " - TEMP_BUILD_DIR"
36
+ echo " - GPG_VERSION"
37
+ exit 1
38
+ }
39
+
40
+ prequisites_yum() {
41
+ yum install -y bzip2 gcc make sudo
42
+ }
43
+
44
+ detect_platform() {
45
+ # Determine OS platform
46
+ DISTRO=$(awk -F= '/^NAME/{print $2}' /etc/os-release | tr -d \")
47
+ echo "$DISTRO"
48
+ }
49
+
50
+ main() {
51
+
52
+ while getopts ":t:idh" o; do
53
+ case "${o}" in
54
+ t)
55
+ readonly local TEMP_BUILD_DIR=1
56
+ ;;
57
+ i)
58
+ readonly local GPG_VERSION=${OPTARG}
59
+ ;;
60
+ d)
61
+ readonly local DRYRUN=1
62
+ ;;
63
+ h)
64
+ usage
65
+ ;;
66
+ *)
67
+ usage
68
+ ;;
69
+ esac
70
+ done
71
+
72
+ if [ "x$GPG_VERSION" == "x" ]; then
73
+ GPG_VERSION="latest"
74
+ fi
75
+
76
+ [[ ! "$TEMP_BUILD_DIR" ]] && \
77
+ TEMP_BUILD_DIR="$(mktemp -d)"
78
+
79
+ DISTRO="$(detect_platform)"
80
+
81
+ case $DISTRO in
82
+ "CentOS Linux")
83
+ echo "Installing CentOS yum dependencies"
84
+ prequisites_yum
85
+ ;;
86
+ esac
87
+
88
+ case "$GPG_VERSION" in
89
+ "2.2")
90
+ ./install_gpg_component.sh --component libgpg-error --version 1.31 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
91
+ ./install_gpg_component.sh --component libgcrypt --version 1.8.2 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
92
+ ./install_gpg_component.sh --component libassuan --version 2.5.1 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
93
+ ./install_gpg_component.sh --component libksba --version 1.3.5 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
94
+ ./install_gpg_component.sh --component npth --version 1.5 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
95
+ ./install_gpg_component.sh --component pinentry --version 1.1.0 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
96
+ ./install_gpg_component.sh --component gnupg --version 2.2.7 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
97
+ ;;
98
+ "2.1")
99
+ ./install_gpg_component.sh --component libgpg-error --version 1.27 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
100
+ ./install_gpg_component.sh --component libgcrypt --version 1.7.6 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
101
+ ./install_gpg_component.sh --component libassuan --version 2.4.3 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
102
+ ./install_gpg_component.sh --component libksba --version 1.3.5 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
103
+ ./install_gpg_component.sh --component npth --version 1.2 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
104
+ ./install_gpg_component.sh --component pinentry --version 0.9.5 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
105
+ ./install_gpg_component.sh --component gnupg --version 2.1.20 --build-dir "$TEMP_BUILD_DIR" "${@:2}"
106
+ ;;
107
+ "latest")
108
+ ./install_gpg_component.sh --component libgpg-error --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
109
+ ./install_gpg_component.sh --component libgcrypt --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
110
+ ./install_gpg_component.sh --component libassuan --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
111
+ ./install_gpg_component.sh --component libksba --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
112
+ ./install_gpg_component.sh --component npth --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
113
+ ./install_gpg_component.sh --component pinentry --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
114
+ ./install_gpg_component.sh --component gnupg --version latest --build-dir "$TEMP_BUILD_DIR" "${@:2}"
115
+ ;;
116
+ "master")
117
+ ./install_gpg_component.sh --component libgpg-error --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
118
+ ./install_gpg_component.sh --component libgcrypt --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
119
+ ./install_gpg_component.sh --component libassuan --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
120
+ ./install_gpg_component.sh --component libksba --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
121
+ ./install_gpg_component.sh --component npth --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
122
+ ./install_gpg_component.sh --component pinentry --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
123
+ ./install_gpg_component.sh --component gnupg --version master --git --build-dir "$TEMP_BUILD_DIR" "${@:2}"
124
+ ;;
125
+ esac
126
+
127
+ cat <<DONE
128
+ +-------------------+
129
+ | INSTALL COMPLETE! |
130
+ +-------------------+
131
+ DONE
132
+
133
+ }
134
+
135
+ main "$@"
136
+
137
+ exit 0
@@ -0,0 +1,301 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+
4
+ ######################
5
+ # ARGUMENTS HANDLING #
6
+ ######################
7
+
8
+ print_help ()
9
+ {
10
+ cat <<HELP
11
+ USAGE
12
+
13
+ install_gpg_component.rb <options>
14
+
15
+ EXAMPLES
16
+
17
+ # Installing latest version of libgpg-error
18
+ install_gpg_component.rb --component libgpg-error --version latest
19
+
20
+ # Installing latest version of libgpg-error with sudo
21
+ install_gpg_component.rb --component libgpg-error --version latest --sudo
22
+
23
+ # Installing latest git revision of libgpg-error
24
+ install_gpg_component.rb --component libgpg-error --version master --git
25
+
26
+ # Passing options to ./configure script
27
+ install_gpg_component.rb --component libgpg-error --version latest --configure-opts "--disable-doc --exec-prefix=/my/bin"
28
+
29
+ OPTIONS
30
+
31
+ --component COMPONENT
32
+ Component to install
33
+
34
+ --version VERSION
35
+ Component version to install (use "latest" for the latest release),
36
+ or git ref (branch, tag, commit hash etc.) when used with "--git"
37
+ option (typically "master").
38
+
39
+ --[no-]git
40
+ Fetch source code from git repository instead of downloading release,
41
+ pass branch or tag name to --version argument. By default it is off.
42
+
43
+ --[no-]sudo
44
+ Whether to do 'sudo make install', or just 'make install'.
45
+ Doesn't affect post install steps, which may require sudo. By default
46
+ it is off.
47
+
48
+ --configure-opts OPTS
49
+ Options to be passed to "./configure" script.
50
+
51
+ --build-dir DIR
52
+ Directory in which the compilation will happen. Content may be
53
+ overwritten during build. Directory will be created if non-existent.
54
+
55
+ --folding-style STYLE
56
+ If set, enables output folding. STYLE defines the folding notation
57
+ used. Following STYLE values are recognized:
58
+
59
+ "none"
60
+ Disable folding. This is default.
61
+
62
+ "travis"
63
+ Fold output for Travis CI builds. See this example Travis job:
64
+ https://api.travis-ci.org/v3/job/15440998/log.txt
65
+
66
+ --help, -h
67
+ Displays this message
68
+
69
+ HELP
70
+ }
71
+
72
+ set_default_options()
73
+ {
74
+ _arg_build_dir=
75
+ _arg_configure_opts=
76
+ _arg_sudo="off"
77
+ _arg_git="off"
78
+ _arg_color="off"
79
+ _arg_folding_style="none"
80
+ }
81
+
82
+ parse_cli_arguments()
83
+ {
84
+ while test $# -gt 0
85
+ do
86
+ case "$1" in
87
+ --component)
88
+ _arg_component="$2"
89
+ shift
90
+ shift
91
+ ;;
92
+ --version)
93
+ _arg_version="$2"
94
+ shift
95
+ shift
96
+ ;;
97
+ --build-dir)
98
+ _arg_build_dir="$2"
99
+ shift
100
+ shift
101
+ ;;
102
+ --configure-opts)
103
+ _arg_configure_opts="$2"
104
+ shift
105
+ shift
106
+ ;;
107
+ --sudo)
108
+ _arg_sudo="on"
109
+ shift
110
+ ;;
111
+ --no-sudo)
112
+ _arg_sudo="off"
113
+ shift
114
+ ;;
115
+ --git)
116
+ _arg_git="on"
117
+ shift
118
+ ;;
119
+ --no-git)
120
+ _arg_git="off"
121
+ shift
122
+ ;;
123
+ --folding-style)
124
+ _arg_folding_style="$2"
125
+ shift
126
+ shift
127
+ ;;
128
+ -h|--help)
129
+ print_help
130
+ exit 0
131
+ ;;
132
+ *)
133
+ echo "Unrecognized option: $1, exiting."
134
+ exit 1
135
+ esac
136
+ done
137
+ }
138
+
139
+ ######################
140
+ # BUILDING #
141
+ ######################
142
+
143
+ display_config()
144
+ {
145
+ cat <<CONFIG
146
+ component: "${_arg_component}"
147
+ version: "${_arg_version}"
148
+ git: "${_arg_git}"
149
+ sudo: "${_arg_sudo}"
150
+ build_dir: "${_arg_build_dir}"
151
+ configure_options: "${_arg_configure_opts}"
152
+
153
+ CONFIG
154
+ }
155
+
156
+ # Consults https://versions.gnupg.org/swdb.lst and assigns the most recent
157
+ # version of component ${_arg_component} to ${_arg_version} variable.
158
+ determine_latest_version()
159
+ {
160
+ fold_start "component.${_arg_component}.detect-latest"
161
+ local _component_underscored=`echo "${_arg_component}" | tr - _`
162
+ _arg_version=`curl "https://versions.gnupg.org/swdb.lst" | grep "_ver" | grep -v "w32" | sort --reverse | grep "${_component_underscored}" | head -n 1 | cut -d " " -f 2`
163
+ echo "The latest version of ${_arg_component} is ${_arg_version}."
164
+ fold_end "component.${_arg_component}.fetch"
165
+ }
166
+
167
+ fetch_source()
168
+ {
169
+ fold_start "component.${_arg_component}.fetch"
170
+ if [[ "${_arg_git}" = "on" ]]; then
171
+ fetch_from_git
172
+ else
173
+ fetch_release
174
+ fi
175
+ fold_end "component.${_arg_component}.fetch"
176
+ }
177
+
178
+ fetch_release()
179
+ {
180
+ local _tarball_file_name="${_arg_component}-${_arg_version}.tar.bz2"
181
+ local _tarball_url="https://gnupg.org/ftp/gcrypt/${_arg_component}/${_tarball_file_name}"
182
+ curl ${_tarball_url} --remote-name --retry 5
183
+ tar -xjf ${_tarball_file_name}
184
+ rm ${_tarball_file_name}
185
+ set_component_build_dir "${_arg_component}-${_arg_version}"
186
+ }
187
+
188
+ fetch_from_git()
189
+ {
190
+ local _git_url="git://git.gnupg.org/${_arg_component}"
191
+ set_component_build_dir "${_arg_component}-git-${_arg_version}"
192
+
193
+ if [ ! -d "${_component_build_dir}" ]; then
194
+ git clone ${_git_url} "${_component_build_dir}"
195
+ else
196
+ pushd "${_component_build_dir}"
197
+ git fetch # need to fetch prior checkout, ref may be nonexistent locally
198
+ popd
199
+ fi
200
+
201
+ pushd "${_component_build_dir}"
202
+ git checkout ${_arg_version}
203
+ git pull # in case of outdated local branch
204
+ popd
205
+ }
206
+
207
+ build_and_install()
208
+ {
209
+ pushd "${_component_build_dir}"
210
+ if [ ! -f configure ]; then
211
+ fold_start "component.${_arg_component}.autogen"
212
+ ./autogen.sh
213
+ fold_end "component.${_arg_component}.autogen"
214
+ fi
215
+ fold_start "component.${_arg_component}.configure"
216
+ ./configure ${_arg_configure_opts}
217
+ fold_end "component.${_arg_component}.configure"
218
+ fold_start "component.${_arg_component}.build"
219
+ make > /dev/null
220
+ fold_end "component.${_arg_component}.build"
221
+ fold_start "component.${_arg_component}.install"
222
+ sudo make install > /dev/null
223
+ fold_end "component.${_arg_component}.install"
224
+ popd
225
+ }
226
+
227
+ set_component_build_dir()
228
+ {
229
+ _component_build_dir=$1
230
+ }
231
+
232
+ header()
233
+ {
234
+ echo ""
235
+ echo ""
236
+ echo "=== $1 ==="
237
+ echo ""
238
+ echo ""
239
+ }
240
+
241
+ ######################
242
+ # PRETTY OUTPUT #
243
+ ######################
244
+
245
+ fold_start()
246
+ {
247
+ case "${_arg_folding_style}" in
248
+ travis)
249
+ echo "travis_fold:start:$1"
250
+ ;;
251
+ *)
252
+ ;;
253
+ esac
254
+ }
255
+
256
+ fold_end()
257
+ {
258
+ case "${_arg_folding_style}" in
259
+ travis)
260
+ echo "travis_fold:end:$1"
261
+ ;;
262
+ *)
263
+ ;;
264
+ esac
265
+ }
266
+
267
+ ######################
268
+ # MAIN #
269
+ ######################
270
+
271
+ set -e # Early exit if any command returns non-zero status code
272
+
273
+ set_default_options
274
+ parse_cli_arguments "$@"
275
+
276
+ fold_start "component.${_arg_component}"
277
+
278
+ header "Installing ${_arg_component} / ${_arg_version}"
279
+
280
+ display_config
281
+
282
+ # set -x # From now, print every command to STDOUT
283
+
284
+ if [[ "${_arg_version}" =~ ^latest ]]; then
285
+ determine_latest_version
286
+ fi
287
+
288
+ mkdir -p ${_arg_build_dir}
289
+ pushd ${_arg_build_dir}
290
+ fetch_source
291
+ build_and_install
292
+ popd # _arg_build_dir
293
+
294
+ if [[ "${_arg_component}" =~ ^gnupg ]]; then
295
+ fold_start "component.${_arg_component}.post-install"
296
+ sudo tee -a /etc/ld.so.conf.d/gpg2.conf <<<"/usr/local/lib"
297
+ sudo ldconfig -v
298
+ fold_end "component.${_arg_component}.post-install"
299
+ fi
300
+
301
+ fold_end "component.${_arg_component}"