lowered-expectations 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6fde866d7ef044f992d41ceaec599d76f457ec54
4
+ data.tar.gz: 92dd27194ff2e1d6e8ae93908d711c66b0eb9684
5
+ SHA512:
6
+ metadata.gz: 84a7d7c280607d6c26eedabd8f0d3850a91f0276f79e6a565cbd202563ce7cc5273f7b673bf5eb31ca04915ef3b1c140cc4c79351cfed595f9322cbfc346e683
7
+ data.tar.gz: 3711f07d56a348f6672ec29d2b3ca95b3a0973a2d610ab9b5c4e7c1475006741bed55397138c948d0c9b426f4a570599a8459c0b4637189f908d90df3fcfecb7
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ Gemfile.lock
30
+ .ruby-version
31
+ .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
@@ -0,0 +1,340 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-05-14 11:00:31 -0400 using RuboCop version 0.21.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 6
9
+ AmbiguousOperator:
10
+ Enabled: false
11
+
12
+ # Offense count: 22
13
+ AmbiguousRegexpLiteral:
14
+ Enabled: false
15
+
16
+ # Offense count: 5
17
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
18
+ ClassAndModuleChildren:
19
+ Enabled: false
20
+
21
+ # Turn this on eventually
22
+ ClassLength:
23
+ Enabled: false
24
+
25
+ # Offense count: 57
26
+ # Cop supports --auto-correct.
27
+ DeprecatedClassMethods:
28
+ Enabled: false
29
+
30
+ # Offense count: 19
31
+ # Cop supports --auto-correct.
32
+ DeprecatedHashMethods:
33
+ Enabled: false
34
+
35
+ Documentation:
36
+ Enabled: false
37
+
38
+ # Offense count: 1
39
+ DoubleNegation:
40
+ Enabled: false
41
+
42
+ # Offense count: 8
43
+ # Configuration parameters: Exclude.
44
+ FileName:
45
+ Enabled: false
46
+
47
+ # Offense count: 3
48
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
49
+ FormatString:
50
+ Enabled: false
51
+
52
+ # Offense count: 9
53
+ # Cop supports --auto-correct.
54
+ IndentArray:
55
+ Enabled: false
56
+
57
+ # Offense count: 261
58
+ # Cop supports --auto-correct.
59
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
60
+ IndentHash:
61
+ Enabled: false
62
+
63
+ # Offense count: 3
64
+ # Cop supports --auto-correct.
65
+ IndentationConsistency:
66
+ Enabled: false
67
+
68
+ LeadingCommentSpace:
69
+ Enabled: false
70
+
71
+ # Offense count: 32
72
+ # Cop supports --auto-correct.
73
+ LineEndConcatenation:
74
+ Enabled: false
75
+
76
+ LineLength:
77
+ Enabled: false
78
+
79
+ # We'll turn this on eventually
80
+ MethodLength:
81
+ Enabled: false
82
+
83
+ # Offense count: 9
84
+ # Cop supports --auto-correct.
85
+ NegatedIf:
86
+ Enabled: false
87
+
88
+ # Offense count: 7
89
+ # Cop supports --auto-correct.
90
+ NegatedWhile:
91
+ Enabled: false
92
+
93
+ # Offense count: 11
94
+ # Cop supports --auto-correct.
95
+ NonNilCheck:
96
+ Enabled: false
97
+
98
+ # Offense count: 110
99
+ # Cop supports --auto-correct.
100
+ # Configuration parameters: PreferredDelimiters.
101
+ PercentLiteralDelimiters:
102
+ Enabled: false
103
+
104
+ # Offense count: 3
105
+ SelfAssignment:
106
+ Enabled: false
107
+
108
+ SignalException:
109
+ Enabled: false
110
+
111
+ # Offense count: 53
112
+ # Cop supports --auto-correct.
113
+ SingleSpaceBeforeFirstArg:
114
+ Enabled: false
115
+
116
+ SpaceAroundOperators:
117
+ Enabled: false
118
+
119
+ # Offense count: 382
120
+ # Cop supports --auto-correct.
121
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
122
+ SpaceBeforeBlockBraces:
123
+ Enabled: false
124
+
125
+ # Offense count: 784
126
+ # Cop supports --auto-correct.
127
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
128
+ SpaceInsideBlockBraces:
129
+ Enabled: false
130
+
131
+ # Don't care enough about this one
132
+ SpaceInsideHashLiteralBraces:
133
+ Enabled: false
134
+
135
+ # Using $CHILD_STATUS instead of $?, etc
136
+ SpecialGlobalVars:
137
+ Enabled: false
138
+
139
+ # Offense count: 5
140
+ # Cop supports --auto-correct.
141
+ StringConversionInInterpolation:
142
+ Enabled: false
143
+
144
+ StringLiterals:
145
+ Description: Checks if uses of quotes match the configured preference.
146
+ Enabled: false
147
+ EnforcedStyle: single_quotes
148
+ SupportedStyles:
149
+ - single_quotes
150
+ - double_quotes
151
+
152
+ # disabling a bunch of style linters
153
+ Lint/BlockAlignment:
154
+ Enabled: false
155
+
156
+ Lint/EndAlignment:
157
+ Enabled: false
158
+
159
+ Lint/Loop:
160
+ Enabled: false
161
+
162
+ Lint/Void:
163
+ Exclude:
164
+ - dashboard/spec/**/*
165
+
166
+ Style/AccessModifierIndentation:
167
+ Enabled: false
168
+
169
+ Style/AccessorMethodName:
170
+ Enabled: false
171
+
172
+ Style/AlignArray:
173
+ Enabled: false
174
+
175
+ Style/AlignHash:
176
+ Enabled: false
177
+
178
+ Style/AlignParameters:
179
+ Enabled: false
180
+
181
+ Metrics/BlockNesting:
182
+ Enabled: false
183
+
184
+ Style/BracesAroundHashParameters:
185
+ Enabled: false
186
+
187
+ Style/CaseIndentation:
188
+ Enabled: false
189
+
190
+ Style/CollectionMethods:
191
+ Enabled: false
192
+
193
+ Style/CommentAnnotation:
194
+ Enabled: false
195
+
196
+ Style/CommentIndentation:
197
+ Enabled: false
198
+
199
+ Style/DefWithParentheses:
200
+ Enabled: false
201
+
202
+ Style/DotPosition:
203
+ Enabled: false
204
+
205
+ Style/EachWithObject:
206
+ Enabled: false
207
+
208
+ Style/EmptyLineBetweenDefs:
209
+ Enabled: false
210
+
211
+ Style/EmptyLines:
212
+ Enabled: false
213
+
214
+ Style/EmptyLinesAroundAccessModifier:
215
+ Enabled: false
216
+
217
+ Style/GuardClause:
218
+ Enabled: false
219
+
220
+ Style/HashSyntax:
221
+ Enabled: false
222
+
223
+ Style/IfUnlessModifier:
224
+ Enabled: false
225
+
226
+ Style/IndentationWidth:
227
+ Enabled: false
228
+
229
+ Style/Lambda:
230
+ Enabled: false
231
+
232
+ Style/MultilineBlockChain:
233
+ Enabled: false
234
+
235
+ Style/MethodCallParentheses:
236
+ Enabled: false
237
+
238
+ Style/MultilineIfThen:
239
+ Enabled: false
240
+
241
+ Style/MultilineTernaryOperator:
242
+ Enabled: false
243
+
244
+ Style/MultilineTernaryOperator:
245
+ Enabled: false
246
+
247
+ Style/NilComparison:
248
+ Enabled: false
249
+
250
+ Style/PredicateName:
251
+ Enabled: false
252
+
253
+ Style/RaiseArgs:
254
+ Enabled: false
255
+
256
+ Style/RedundantBegin:
257
+ Enabled: false
258
+
259
+ Style/RedundantSelf:
260
+ Enabled: false
261
+
262
+ Style/RegexpLiteral:
263
+ Enabled: false
264
+
265
+ Style/SingleLineMethods:
266
+ Enabled: false
267
+
268
+ Style/SpaceAfterComma:
269
+ Enabled: false
270
+
271
+ Style/SpaceAfterNot:
272
+ Enabled: false
273
+
274
+ Style/SpaceAroundEqualsInParameterDefault:
275
+ Enabled: false
276
+
277
+ Style/SpaceInsideBrackets:
278
+ Enabled: false
279
+
280
+ Style/SpaceInsideParens:
281
+ Enabled: false
282
+
283
+ Style/TrailingBlankLines:
284
+ Enabled: false
285
+
286
+ Style/TrivialAccessors:
287
+ Enabled: false
288
+
289
+ Style/WhileUntilDo:
290
+ Enabled: false
291
+
292
+ Style/WhileUntilModifier:
293
+ Enabled: false
294
+
295
+
296
+ # Things that are off but we should turn on eventually
297
+
298
+ Style/Next:
299
+ Enabled: false
300
+
301
+ Style/NumericLiterals:
302
+ Enabled: false
303
+
304
+ Metrics/ParameterLists:
305
+ Enabled: false
306
+
307
+ Style/TrailingComma:
308
+ # EnforcedStyleForMultiline: comma
309
+ Enabled: false
310
+
311
+ Metrics/CyclomaticComplexity:
312
+ Enabled: false
313
+
314
+ Metrics/AbcSize:
315
+ Enabled: false
316
+
317
+ ####
318
+
319
+ # Offense count: 1
320
+ UnderscorePrefixedVariableName:
321
+ Enabled: false
322
+
323
+ # Offense count: 108
324
+ UnusedBlockArgument:
325
+ Enabled: false
326
+
327
+ # Offense count: 159
328
+ UnusedMethodArgument:
329
+ Enabled: false
330
+
331
+ # Offense count: 2
332
+ UselessAccessModifier:
333
+ Enabled: false
334
+
335
+ # As of rubocop 0.21, it thinks kwargs are useless assignments
336
+ UselessAssignment:
337
+ Enabled: false
338
+
339
+ WordArray:
340
+ Enabled: false
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.1
5
+ - 2.2.0
6
+ - ruby-head
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # Copyright 2015 Ian Chesal
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ source 'https://rubygems.org'
16
+
17
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,46 @@
1
+ # lowered-expectations
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/lowered-expectations.svg)](http://badge.fury.io/rb/lowered-expectations)
4
+
5
+ [![Build Status](https://travis-ci.org/ianchesal/loweredexpectations.svg?branch=master)](https://travis-ci.org/ianchesal/loweredexpectations)
6
+
7
+ A Ruby gem that lets you test for the presence of command line tools and ensure
8
+ that you have a version of the tool that you know how to work with.
9
+
10
+ It uses the gem system's version matching semantics so you can do things like
11
+ enforce a major version but allow any minor version above a certain value for a
12
+ tool. If you use Gemfile's the syntax should look pretty familiary to you.
13
+
14
+ ## Installation
15
+
16
+ gem install lowered-expectations
17
+
18
+ ## Use
19
+
20
+ require 'lowered/expectations'
21
+ LoweredExpectations.expect('curl', "~> 7.0")
22
+ # If I get to here I know I have a version of curl I can use
23
+
24
+ The following errors can be raised when using this Gem:
25
+
26
+ * `LoweredExpectations::VersionPatternError` - Raised if the version pattern supplied isn't recognized
27
+ * `LoweredExpectations::IncompatibleVersionError` - Raised if the version of the tool does not match the expected version pattern
28
+ * `LoweredExpectations::MissingExecutableError` - Raised if the tool cannot be found on your `PATH`
29
+
30
+ ## Development
31
+
32
+ ### Continuous Integration
33
+
34
+ I'm using Travis CI to build and test on every push to the public github repository. You can find the Travis CI page for this project here: https://travis-ci.org/ianchesal/loweredexpectations/
35
+
36
+ ### Branching in Git
37
+
38
+ I'm using [git-flow](http://nvie.com/posts/a-successful-git-branching-model/) for development in git via github. I've loved the branching model git-flow proposed from day one and the addon to git makes it very intuitive and easy to follow. I generally don't push my `feature/*` branches to the public repository; I do keep `development` and `master` up to date here though.
39
+
40
+ ### TODO Work
41
+
42
+ Please see [TODO.md](TODO.md) for the short list of big things I thought worth writing down.
43
+
44
+ ## Contact Me
45
+
46
+ Questions or comments about `packer-config`? Hit me up at ian.chesal@gmail.com or ianc@squareup.com.
@@ -0,0 +1,7 @@
1
+ # lowered-expectations Release Notes
2
+
3
+ ## 1.0.0
4
+
5
+ * Our first release
6
+ * Supports finding things on `PATH` but not absolute or relative executables
7
+ * Has not been tested in Windows but, hey, it should work, right?
@@ -0,0 +1,38 @@
1
+ # Encoding: utf-8
2
+ # Copyright 2015 Ian Chesal
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'rubocop/rake_task'
17
+ require 'rspec/core/rake_task'
18
+ require 'rake/clean'
19
+
20
+ RuboCop::RakeTask.new(:lint)
21
+
22
+ task :default => [:lint, 'test:spec']
23
+
24
+ task :build => [:lint, 'test:spec', 'test:integration'] do
25
+ sh "gem build --verbose lowered-expectations.gemspec"
26
+ end
27
+
28
+ namespace :test do
29
+ RSpec::Core::RakeTask.new(:spec) do |t|
30
+ t.pattern = Dir['spec/**/*_spec.rb'].reject{ |f| f['/integration'] }
31
+ end
32
+
33
+ RSpec::Core::RakeTask.new(:integration) do |t|
34
+ t.pattern = "spec/integration/**/*_spec.rb"
35
+ end
36
+ end
37
+
38
+ CLEAN.add FileList['lowered-expectations-*.gem']
data/TODO.md ADDED
@@ -0,0 +1,4 @@
1
+ # TODO
2
+
3
+ * Support for absolute and relative paths to executables. Right now it expects executables to be on `PATH`.
4
+ * Test on Windows. Really. This gets zero Windows love because I don't run Windows and TravisCI doesn't support Windows.
@@ -0,0 +1,90 @@
1
+ # Encoding: utf-8
2
+ # Copyright 2015 Ian Chesal
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ require 'rubygems/dependency'
16
+ require 'open3'
17
+ require 'shellwords'
18
+ require 'pty'
19
+
20
+ class LoweredExpectations
21
+ class VersionPatternError < StandardError
22
+ end
23
+
24
+ class IncompatibleVersionError < StandardError
25
+ end
26
+
27
+ class CommandExecutionError < StandardError
28
+ end
29
+
30
+ class MissingExecutableError < StandardError
31
+ end
32
+
33
+ def self.expect(executable, version, vopt: '--version', vpattern: '(\d+\.\d+\.\d+)')
34
+ vstring = run! which(executable), vopt, quiet: true
35
+ vmatch = /#{vpattern}/.match(vstring)
36
+ verify_version(vmatch[0], version) || raise(VersionPatternError.new("unable to match #{vpattern} in version output #{vstring} from #{executable}"))
37
+ end
38
+
39
+ def self.which(cmd)
40
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
41
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
42
+ exts.each do |ext|
43
+ exe = File.join(path, "#{cmd}#{ext}")
44
+ return exe if File.executable?(exe) && !File.directory?(exe)
45
+ end
46
+ end
47
+ raise MissingExecutableError.new("#{executable} not found in #{ENV['PATH']}")
48
+ end
49
+
50
+ def self.verify_version(version, pattern)
51
+ Gem::Dependency.new('', pattern).match?('', version) || raise(IncompatibleVersionError.new("#{version} does not match version pattern #{pattern}"))
52
+ end
53
+
54
+ def self.run!(*args, quiet: false)
55
+ cmd = Shellwords.shelljoin(args.flatten)
56
+ status = 0
57
+ stdout = ''
58
+ stderr = ''
59
+ if quiet
60
+ # Run without streaming std* to any screen
61
+ stdout, stderr, status = Open3.capture3(cmd)
62
+ else
63
+ # Run but stream as well as capture stdout to the screen
64
+ status = pty(cmd) do |r,w,pid|
65
+ while !r.eof?
66
+ c = r.getc
67
+ stdout << c
68
+ $stdout.write "#{c}"
69
+ end
70
+ Process.wait(pid)
71
+ end
72
+ end
73
+ raise CommandExecutionError.new(stderr) unless status == 0
74
+ stdout
75
+ end
76
+ private_class_method :run!
77
+
78
+ def self.exec!(*args)
79
+ cmd = Shellwords.shelljoin(args.flatten)
80
+ logger.debug "Exec'ing: #{cmd}, in: #{Dir.pwd}"
81
+ Kernel.exec cmd
82
+ end
83
+ private_class_method :exec!
84
+
85
+ def self.pty(cmd, &block)
86
+ PTY.spawn(cmd, &block)
87
+ $?.exitstatus
88
+ end
89
+ private_class_method :pty
90
+ end
@@ -0,0 +1,45 @@
1
+ # Encoding: utf-8
2
+ # Copyright 2015 Ian Chesal
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ Gem::Specification.new do |spec|
17
+ spec.name = "lowered-expectations"
18
+ spec.version = "1.0.0"
19
+ # For deploying alpha versions via Travis CI
20
+ spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
21
+ spec.authors = ["Ian Chesal"]
22
+ spec.email = ["ian.chesal@gmail.com"]
23
+ spec.summary = 'A library for testing versions of command line tools.'
24
+ spec.description = <<-END
25
+ A Ruby gem that lets you test for the presence of command line tools and ensure
26
+ that you have a version of the tool that you know how to work with.
27
+
28
+ It uses the gem system's version matching semantics so you can do things like
29
+ enforce a major version but allow any minor version above a certain value for a
30
+ tool. If you use Gemfile's the syntax should look pretty familiary to you.
31
+ END
32
+ spec.homepage = "https://github.com/ianchesal/loweredexpectations"
33
+ spec.license = "Apache 2.0"
34
+
35
+ spec.files = `git ls-files -z`.split("\x0")
36
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
37
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
38
+ spec.require_paths = ["lib"]
39
+
40
+ spec.add_development_dependency "bundler", "~> 1.7"
41
+ spec.add_development_dependency "rake", "~> 10.4"
42
+ spec.add_development_dependency "rspec", "~> 3.0"
43
+ spec.add_development_dependency "rspec-mocks", "~> 3.0"
44
+ spec.add_development_dependency "rubocop", "~> 0.24"
45
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LoweredExpectations do
4
+ let(:tool) { 'curl' }
5
+
6
+ describe '.expect' do
7
+ it 'returns true when the executable exists and the version matches' do
8
+ expect(LoweredExpectations.expect(tool, "~> 7.0")).to be_truthy
9
+ end
10
+
11
+ it 'raises an error when the version pattern cannot be found in executable output' do
12
+ expect{LoweredExpectations.expect(tool, "~> 0.1", vpattern: 'notvalid')}.to raise_error
13
+ end
14
+
15
+ it 'raises an error when the version of the tool does not meet expectations' do
16
+ expect{LoweredExpectations.expect(tool, "~> 1000.0")}.to raise_error
17
+ end
18
+ end
19
+
20
+ describe '.which' do
21
+ it 'returns true when the executable is on the PATH' do
22
+ expect(LoweredExpectations.which tool).to be_truthy
23
+ end
24
+
25
+ it 'raises an error when the executable is not on the PATH' do
26
+ expect{LoweredExpectations.which 'sometoolthatdoesnotexist'}.to raise_error
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe LoweredExpectations do
4
+ let(:tool) { 'curl' }
5
+ let(:version) { '0.1.2' }
6
+ let(:curl_version) do
7
+ "curl 0.1.2 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5
8
+ Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
9
+ Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL lib"
10
+ end
11
+
12
+ describe '.expect' do
13
+ it 'returns true when the executable exists and the version matches' do
14
+ expect(LoweredExpectations).to receive(:which).once.with(tool).and_return(tool)
15
+ expect(LoweredExpectations).to receive(:run!).once.and_return(curl_version)
16
+ expect(LoweredExpectations).to receive(:verify_version).once.with(version, "~> 0.1").and_return(true)
17
+ expect(LoweredExpectations.expect(tool, "~> 0.1")).to be_truthy
18
+ end
19
+
20
+ it 'raises an error when the executable does not exist' do
21
+ expect(LoweredExpectations).to receive(:which).once.with(tool).and_raise(LoweredExpectations::MissingExecutableError)
22
+ expect{LoweredExpectations.expect(tool, "~> 0.1")}.to raise_error
23
+ end
24
+
25
+ it 'raises an error when the version cannot be extracted from executable' do
26
+ expect(LoweredExpectations).to receive(:which).once.with(tool).and_return(tool)
27
+ expect(LoweredExpectations).to receive(:run!).once.and_raise(LoweredExpectations::CommandExecutionError)
28
+ expect{LoweredExpectations.expect(tool, "~> 0.1")}.to raise_error
29
+ end
30
+
31
+ it 'raises an error when the version pattern cannot be found in executable output' do
32
+ expect(LoweredExpectations).to receive(:which).once.with(tool).and_return(tool)
33
+ expect(LoweredExpectations).to receive(:run!).once.and_return(curl_version)
34
+ expect{LoweredExpectations.expect(tool, "~> 0.1", vpattern: 'notvalid')}.to raise_error
35
+ end
36
+
37
+ it 'raises an error when the version of the tool does not meet expectations' do
38
+ expect(LoweredExpectations).to receive(:which).once.with(tool).and_return(tool)
39
+ expect(LoweredExpectations).to receive(:run!).once.and_return(curl_version)
40
+ expect(LoweredExpectations).to receive(:verify_version).once.with(version, "~> 0.1").and_raise(LoweredExpectations::IncompatibleVersionError)
41
+ expect{LoweredExpectations.expect(tool, "~> 0.1")}.to raise_error
42
+ end
43
+ end
44
+
45
+ describe '.which' do
46
+ it 'returns true when the executable is on the PATH' do
47
+ expect(LoweredExpectations.which tool).to be_truthy
48
+ end
49
+
50
+ it 'raises an error when the executable is not on the PATH' do
51
+ expect{LoweredExpectations.which 'sometoolthatdoesnotexist'}.to raise_error
52
+ end
53
+ end
54
+
55
+ describe '.verify_version' do
56
+ it 'returns true when the version string matches the version pattern' do
57
+ expect(LoweredExpectations.verify_version version, '~> 0.1').to be_truthy
58
+ expect(LoweredExpectations.verify_version version, '~> 0').to be_truthy
59
+ expect(LoweredExpectations.verify_version version, '> 0.1.1').to be_truthy
60
+ expect(LoweredExpectations.verify_version version, '< 1').to be_truthy
61
+ expect(LoweredExpectations.verify_version version, '> 0').to be_truthy
62
+ expect(LoweredExpectations.verify_version version, "= #{version}").to be_truthy
63
+ end
64
+
65
+ it 'raise an error when the version string does not match the version pattern' do
66
+ expect{LoweredExpectations.verify_version version, '~> 0.2'}.to raise_error
67
+ expect{LoweredExpectations.verify_version version, '~> 1'}.to raise_error
68
+ expect{LoweredExpectations.verify_version version, '> 0.1.3'}.to raise_error
69
+ expect{LoweredExpectations.verify_version version, '< 0'}.to raise_error
70
+ expect{LoweredExpectations.verify_version version, '> 1'}.to raise_error
71
+ expect{LoweredExpectations.verify_version version, "!= #{version}"}.to raise_error
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,19 @@
1
+ # Encoding: utf-8
2
+ # Copyright 2015 Ian Chesal
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ require 'lowered/expectations'
16
+
17
+ # RSpec.configure do |c|
18
+ # c.treat_symbols_as_metadata_keys_with_true_values = true
19
+ # end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lowered-expectations
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ian Chesal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-mocks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.24'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.24'
83
+ description: |
84
+ A Ruby gem that lets you test for the presence of command line tools and ensure
85
+ that you have a version of the tool that you know how to work with.
86
+
87
+ It uses the gem system's version matching semantics so you can do things like
88
+ enforce a major version but allow any minor version above a certain value for a
89
+ tool. If you use Gemfile's the syntax should look pretty familiary to you.
90
+ email:
91
+ - ian.chesal@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".rubocop.yml"
99
+ - ".travis.yml"
100
+ - Gemfile
101
+ - LICENSE
102
+ - README.md
103
+ - RELEASENOTES.md
104
+ - Rakefile
105
+ - TODO.md
106
+ - lib/lowered/expectations.rb
107
+ - lowered-expectations.gemspec
108
+ - spec/integration/lowered/expectations_integration_spec.rb
109
+ - spec/lowered/expectations_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: https://github.com/ianchesal/loweredexpectations
112
+ licenses:
113
+ - Apache 2.0
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.4.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: A library for testing versions of command line tools.
135
+ test_files:
136
+ - spec/integration/lowered/expectations_integration_spec.rb
137
+ - spec/lowered/expectations_spec.rb
138
+ - spec/spec_helper.rb