cyclops 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
  SHA1:
3
- metadata.gz: 50d91316768ffce183a6c41be0e4b3b6f89448f2
4
- data.tar.gz: acf66a81fe2d13aadfbe59f3b3f47cd3fca1dd23
3
+ metadata.gz: db466ccb87d28350391ce2adebba44b94dc71e2e
4
+ data.tar.gz: 4f98b24ed4c00d7f6f024504b5d5ec7f7155d914
5
5
  SHA512:
6
- metadata.gz: 019744393582f5df8994bd1e4a2e245b8e9e16b71116e8ebc3fc891ea1cd6f066e0b3ae24f934442a069a277062c753238da37f33392a2de584ef4817d00ba38
7
- data.tar.gz: 5829be83e1a06d225deb1e9bf5385e3ee1e6010c0f85f35a02ad5e51b471f4ec6df0f4b98e0e17b4907b204006662dc56173e6a37b171bd0c255754d3c4152ca
6
+ metadata.gz: d552ed05cde6aadea4249bf1ef6f0a8509266dea4a7307157c597159aba2db0ae6da7ba1b89f9a256418ff52fdb3823239c5a73c4ac940ab7120bd9d8db44b90
7
+ data.tar.gz: d3fad67b9dd9197fba278b4e65961f0b3d4a540cbb9dbceafeeb9dd66a0f28096d23f5c371026ad67b3e7af3fc03cd4b266fd2a7ce084d5655b627627adb7e57
data/ChangeLog CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  = Revision history for cyclops
4
4
 
5
+ == 0.2.0 [2015-10-02]
6
+
7
+ * Extracted Cyclops#open_file and Cyclops#open_std from
8
+ Cyclops#open_file_or_std so they can be overwritten in subclasses.
9
+
5
10
  == 0.1.0 [2014-11-26]
6
11
 
7
12
  * Extracted Cyclops#config_present? from Cyclops#config_opts so it can be
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to cyclops version 0.1.0
5
+ This documentation refers to cyclops version 0.2.0
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -25,7 +25,7 @@ RubyGem:: https://rubygems.org/gems/cyclops
25
25
 
26
26
  == LICENSE AND COPYRIGHT
27
27
 
28
- Copyright (C) 2014 Jens Wille
28
+ Copyright (C) 2014-2015 Jens Wille
29
29
 
30
30
  cyclops is free software: you can redistribute it and/or modify it
31
31
  under the terms of the GNU Affero General Public License as published by
data/lib/cyclops.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # cyclops -- A command-line option parser #
5
5
  # #
6
- # Copyright (C) 2014 Jens Wille #
6
+ # Copyright (C) 2014-2015 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@gmail.com> #
@@ -95,8 +95,8 @@ class Cyclops
95
95
  run(arguments)
96
96
  rescue => err
97
97
  raise if $VERBOSE
98
- abort err.is_a?(OptionParser::ParseError) ?
99
- "#{err}\n#{usage}" : "#{err.backtrace.first}: #{err} (#{err.class})"
98
+ err.is_a?(OptionParser::ParseError) ? quit(err) :
99
+ abort("#{err.backtrace.first}: #{err} (#{err.class})")
100
100
  ensure
101
101
  options.each_value { |value| value.close if value.is_a?(Zlib::GzipWriter) }
102
102
  end
@@ -166,15 +166,29 @@ class Cyclops
166
166
  Kernel.exit(status)
167
167
  end
168
168
 
169
- def open_file_or_std(file, write = false)
170
- file == '-' ? write ? stdout : stdin : begin
171
- gz = file =~ /\.gz\z/i
169
+ def open_file_or_std(file, mode = 'r')
170
+ mode = 'w' if mode == true
171
+ stdio?(file) ? open_std(file, mode) : open_file(file, mode)
172
+ end
172
173
 
173
- write ? gz ? Zlib::GzipWriter.open(file) : File.open(file, 'w') : begin
174
- quit "No such file: #{file}" unless File.readable?(file)
175
- (gz ? Zlib::GzipReader : File).open(file)
176
- end
177
- end
174
+ def open_file(file, mode = 'r')
175
+ write = write?(mode) or
176
+ File.readable?(file) or quit "No such file: #{file}"
177
+
178
+ file =~ /\.gz\z/i ? (write ? Zlib::GzipWriter :
179
+ Zlib::GzipReader).open(file) : File.open(file, mode)
180
+ end
181
+
182
+ def open_std(file, mode = nil)
183
+ write?(mode) ? stdout : stdin
184
+ end
185
+
186
+ def write?(mode)
187
+ mode == true || mode =~ /w/
188
+ end
189
+
190
+ def stdio?(file)
191
+ file == '-'
178
192
  end
179
193
 
180
194
  def config_present?(config)
@@ -3,7 +3,7 @@ class Cyclops
3
3
  module Version
4
4
 
5
5
  MAJOR = 0
6
- MINOR = 1
6
+ MINOR = 2
7
7
  TINY = 0
8
8
 
9
9
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyclops
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
  - Jens Wille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '0.8'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 0.8.0
50
+ version: 0.8.3
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '0.8'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.8.0
60
+ version: 0.8.3
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -94,14 +94,14 @@ licenses:
94
94
  metadata: {}
95
95
  post_install_message: |2+
96
96
 
97
- cyclops-0.1.0 [2014-11-26]:
97
+ cyclops-0.2.0 [2015-10-02]:
98
98
 
99
- * Extracted Cyclops#config_present? from Cyclops#config_opts so it can be
100
- overwritten in subclasses.
99
+ * Extracted Cyclops#open_file and Cyclops#open_std from
100
+ Cyclops#open_file_or_std so they can be overwritten in subclasses.
101
101
 
102
102
  rdoc_options:
103
103
  - "--title"
104
- - cyclops Application documentation (v0.1.0)
104
+ - cyclops Application documentation (v0.2.0)
105
105
  - "--charset"
106
106
  - UTF-8
107
107
  - "--line-numbers"
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.4.4
125
+ rubygems_version: 2.4.8
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: A command-line option parser based on optparse.