user-choices-pathname 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
Binary file
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ # Project metadata
2
+ nbproject
3
+ .idea
4
+
5
+ Gemfile.lock
6
+
7
+ doc/lib
8
+ coverage
9
+ pkg
10
+ .yardoc
11
+ .rbx
12
+ *.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format d --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0-preview1
5
+ - rbx-19mode
6
+ - jruby-19mode
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --output-dir=doc/lib
2
+ --embed-mixins
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ source "http://rubygems.org"
21
+
22
+ # Specify your gem's dependencies in user-choice-pathname.gemspec
23
+ gemspec
24
+
25
+ gem 'coveralls', require: false
data/HISTORY.md ADDED
@@ -0,0 +1,6 @@
1
+ 1.0.0 / 2013-10-16
2
+ ==================
3
+
4
+ * 1 major enhancement
5
+
6
+ * Birthday!
data/LICENSE.md ADDED
@@ -0,0 +1,16 @@
1
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
2
+
3
+ Pathname for user-choices is licensed under the following ISC-style license:
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+
data/README.md ADDED
@@ -0,0 +1,241 @@
1
+ Pathname for user-choices
2
+ =========================
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/user-choices-pathname.png)](https://badge.fury.io/rb/user-choices-pathname)
5
+ [![Build Status](https://secure.travis-ci.org/godobject/user-choices-pathname.png)](https://travis-ci.org/godobject/user-choices-pathname)
6
+ [![Dependency Status](https://gemnasium.com/godobject/user-choices-pathname.png)](https://gemnasium.com/godobject/user-choices-pathname)
7
+ [![Code Climate](https://codeclimate.com/github/godobject/user-choices-pathname.png)](https://codeclimate.com/github/godobject/user-choices-pathname)
8
+ [![Coverage Status](https://coveralls.io/repos/godobject/user-choices-pathname/badge.png?branch=master)](https://coveralls.io/r/godobject/user-choices-pathname)
9
+
10
+ * [Documentation][docs]
11
+ * [Project][project]
12
+
13
+ [docs]: http://rdoc.info/github/godobject/user-choices-pathname/
14
+ [project]: https://github.com/godobject/user-choices-pathname/
15
+
16
+ Description
17
+ -----------
18
+
19
+ Pathname for the user-choices command-line argument parser allows choices to be
20
+ automatically converted to Pathname objects.
21
+
22
+ Features / Problems
23
+ -------------------
24
+
25
+ This project tries to conform to:
26
+
27
+ * [Semantic Versioning (2.0.0)][semver]
28
+ * [Ruby Packaging Standard (0.5-draft)][rps]
29
+ * [Ruby Style Guide][style]
30
+ * [Gem Packaging: Best Practices][gem]
31
+
32
+ [semver]: http://semver.org/
33
+ [rps]: http://chneukirchen.github.com/rps/
34
+ [style]: https://github.com/bbatsov/ruby-style-guide
35
+ [gem]: http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
36
+
37
+ Additional facts:
38
+
39
+ * Written purely in Ruby.
40
+ * Documented with YARD.
41
+ * Automatically testable through RSpec.
42
+ * Intended to be used with Ruby 1.9.3 or higher.
43
+ * Cryptographically signed gem and git tags.
44
+ * This library was developed as part of the Spaces project.
45
+
46
+ Synopsis
47
+ --------
48
+
49
+ This documentation defines the public interface of the software. Don't rely
50
+ on elements marked as private. Those should be hidden in the documentation
51
+ by default.
52
+
53
+ ### Loading
54
+
55
+ In most cases you want to load the library by the following command:
56
+
57
+ ~~~~~ ruby
58
+ require 'user-choices-pathname'
59
+ ~~~~~
60
+
61
+ In a bundler Gemfile you should use the following:
62
+
63
+ ~~~~~ ruby
64
+ gem 'user-choices-pathname'
65
+ ~~~~~
66
+
67
+ ### Usage
68
+
69
+ Just like the other types that are supported by user-choices by default you can
70
+ define a choice to be of the type pathname like the following:
71
+
72
+ ~~~~~ ruby
73
+ class SomeCommand < UserChoices::Command
74
+
75
+
76
+
77
+ def add_choices(builder)
78
+
79
+ builder.add_choice(:somepath, :type => :pathname)
80
+
81
+ end
82
+
83
+
84
+
85
+ end
86
+ ~~~~~
87
+
88
+ When the command is run, arguments given for the choice 'somepath' are then
89
+ automatically made into Pathname objects and are accessible through the
90
+ arguments hash stored in the @user_choices instance variable.
91
+
92
+ The conversion is also able to convert argument lists to Arrays of Pathnames.
93
+
94
+ Requirements
95
+ ------------
96
+
97
+ * Ruby 1.9.3 or higher
98
+ * [user-choices](https://rubygems.org/gems/user-choices)
99
+
100
+ Installation
101
+ ------------
102
+
103
+ On *nix systems you may need to prefix the command with sudo to get root
104
+ privileges.
105
+
106
+ ### High security (recommended)
107
+
108
+ There is a high security installation option available through rubygems. It is
109
+ highly recommended over the normal installation, although it may be a bit less
110
+ comfortable. To use the installation method, you will need my [gem signing
111
+ public key][gemkey], which I use for cryptographic signatures on all my gems.
112
+
113
+ Add the key to your rubygems' trusted certificates by the following command:
114
+
115
+ gem cert --add aef-gem.pem
116
+
117
+ Now you can install the gem while automatically verifying its signature by the
118
+ following command:
119
+
120
+ gem install user-choices-pathname -P HighSecurity
121
+
122
+ Please notice that you may need other keys for dependent libraries, so you may
123
+ have to install dependencies manually.
124
+
125
+ [gemkey]: https://aef.name/crypto/aef-gem.pem
126
+
127
+ ### Normal
128
+
129
+ gem install user-choices-pathname
130
+
131
+ ### Automated testing
132
+
133
+ Go into the root directory of the installed gem and run the following command
134
+ to fetch all development dependencies:
135
+
136
+ bundle
137
+
138
+ Afterwards start the test runner:
139
+
140
+ rake spec
141
+
142
+ If something goes wrong you should be noticed through failing examples.
143
+
144
+ Development
145
+ -----------
146
+
147
+ ### Bug reports and feature requests
148
+
149
+ Please use the [issue tracker][issues] on github.com to let me know about errors
150
+ or ideas for improvement of this software.
151
+
152
+ [issues]: https://github.com/godobject/user-choices-pathname/issues/
153
+
154
+ ### Source code
155
+
156
+ #### Distribution
157
+
158
+ This software is developed in the source code management system Git. There are
159
+ several synchronized mirror repositories available:
160
+
161
+ * GitHub (located in California, USA)
162
+
163
+ URL: https://github.com/godobject/user-choices-pathname.git
164
+
165
+ * Gitorious (located in Norway)
166
+
167
+ URL: https://git.gitorious.org/user-choices-pathname/user-choices-pathname.git
168
+
169
+ * BitBucket (located in Colorado, USA)
170
+
171
+ URL: https://bitbucket.org/godobject/user-choices-pathname.git
172
+
173
+ * Pikacode (located in France)
174
+
175
+ URL: https://pikacode.com/godobject/user-choices-pathname.git
176
+
177
+ You can get the latest source code with the following command, while
178
+ exchanging the placeholder for one of the mirror URLs:
179
+
180
+ git clone MIRROR_URL
181
+
182
+ #### Tags and cryptographic verification
183
+
184
+ The final commit before each released gem version will be marked by a tag
185
+ named like the version with a prefixed lower-case "v", as required by Semantic
186
+ Versioning. Every tag will be signed by my [OpenPGP public key][openpgp] which
187
+ enables you to verify your copy of the code cryptographically.
188
+
189
+ [openpgp]: https://aef.name/crypto/aef-openpgp.asc
190
+
191
+ Add the key to your GnuPG keyring by the following command:
192
+
193
+ gpg --import aef-openpgp.asc
194
+
195
+ This command will tell you if your code is of integrity and authentic:
196
+
197
+ git tag -v [TAG NAME]
198
+
199
+ #### Building gems
200
+
201
+ To package your state of the source code into a gem package use the following
202
+ command:
203
+
204
+ rake build
205
+
206
+ The gem will be generated according to the .gemspec file in the project root
207
+ directory and will be placed into the pkg/ directory.
208
+
209
+ ### Contribution
210
+
211
+ Help on making this software better is always very appreciated. If you want
212
+ your changes to be included in the official release, please clone the project
213
+ on github.com, create a named branch to commit, push your changes into it and
214
+ send a pull request afterwards.
215
+
216
+ Please make sure to write tests for your changes so that no one else will break
217
+ them when changing other things. Also notice that an inclusion of your changes
218
+ cannot be guaranteed before reviewing them.
219
+
220
+ The following people were involved in development:
221
+
222
+ - Alexander E. Fischer
223
+
224
+ License
225
+ -------
226
+
227
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
228
+
229
+ This file is part of Pathname for user-choices.
230
+
231
+ Permission to use, copy, modify, and/or distribute this software for any
232
+ purpose with or without fee is hereby granted, provided that the above
233
+ copyright notice and this permission notice appear in all copies.
234
+
235
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
236
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
237
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
238
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
239
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
240
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
241
+ PERFORMANCE OF THIS SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ require 'bundler/gem_tasks'
21
+ require 'rake'
22
+ require 'pathname'
23
+ require 'yard'
24
+ require 'rspec/core/rake_task'
25
+
26
+ RSpec::Core::RakeTask.new
27
+
28
+ YARD::Rake::YardocTask.new('doc')
29
+
30
+ desc "Removes temporary project files"
31
+ task :clean do
32
+ %w{doc/lib coverage pkg .yardoc .rbx Gemfile.lock}.map{|name| Pathname.new(name) }.each do |path|
33
+ path.rmtree if path.exist?
34
+ end
35
+
36
+ Pathname.glob('*.gem').each &:delete
37
+ Pathname.glob('**/*.rbc').each &:delete
38
+ end
39
+
40
+ desc "Opens an interactive console with the library loaded"
41
+ task :console do
42
+ Bundler.setup
43
+ require 'pry'
44
+ require 'user-choices-pathname'
45
+ Pry.start(GodObject::PathnameConversion)
46
+ end
47
+
48
+ task :default => :spec
@@ -0,0 +1,41 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ require 'user-choices'
21
+
22
+ # Namespace for projects of the GodObject team <dev@godobject.net>.
23
+ #
24
+ # If you want to be able to simply type Example instead of GodObject::Example
25
+ # to address classes in this namespace simply write the following before using
26
+ # the classes.
27
+ #
28
+ # @example Including the namespace
29
+ # include GodObject
30
+ # @see https://www.godobject.net/
31
+ module GodObject
32
+
33
+ # Namespace for components of the "user-choices-pathname" library
34
+ module PathnameConversion
35
+
36
+ end
37
+
38
+ end
39
+
40
+ require 'god_object/pathname_conversion/version'
41
+ require 'god_object/pathname_conversion/conversion_to_pathname'
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ module GodObject
21
+ module PathnameConversion
22
+
23
+ # This class adds the type :pathname to user-choices.
24
+ class ConversionToPathname < UserChoices::Conversion
25
+
26
+ # Decides through which tag this conversion is triggered.
27
+ #
28
+ # The Pathname conversion is triggered by :pathname.
29
+ #
30
+ # @param [Symbol] conversion_tag a type tag used in a choice definition
31
+ # @return [true, false] true, if the conversion should be triggered by
32
+ # the given tag, false otherwise
33
+ def self.described_by?(conversion_tag)
34
+ conversion_tag == :pathname
35
+ end
36
+
37
+ # Describes the conversion.
38
+ #
39
+ # @return [String] a description
40
+ def description
41
+ "a pathname"
42
+ end
43
+
44
+ # Answers if given value is suitable to be converted.
45
+ #
46
+ # For Pathname conversion it needs to be a String-like or Enumerable.
47
+ #
48
+ # @param [Object] actual
49
+ # @return [true, false] true if the given value is suitable, false
50
+ # otherwise
51
+ def suitable?(actual)
52
+ actual.respond_to?(:to_str) || actual.kind_of?(Enumerable)
53
+ end
54
+
55
+ # Converts the value to Pathname.
56
+ #
57
+ # @param [String, Array] value a path
58
+ # @return [Pathname, Array<Pathname>] the value as Pathname or, if an
59
+ # Enumerable was converted, an Array of Pathnames
60
+ def convert(value)
61
+ case value
62
+ when Array
63
+ pathnames = []
64
+
65
+ value.each {|path| pathnames << Pathname.new(path) }
66
+
67
+ pathnames
68
+ else
69
+ Pathname.new(value)
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ module GodObject
21
+ module PathnameConversion
22
+
23
+ # The currently loaded library version
24
+ #
25
+ # Using Semantic Versioning (2.0.0) rules
26
+ # @see http://semver.org/
27
+ VERSION = '1.0.0'.freeze
28
+
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ # Helper file to allow loading by gem name.
21
+
22
+ require 'god_object/pathname_conversion'
@@ -0,0 +1,93 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ require 'spec_helper'
21
+
22
+ module GodObject
23
+ module PathnameConversion
24
+
25
+ describe ConversionToPathname do
26
+ let(:conversion) { ConversionToPathname.new(:pathname) }
27
+
28
+ describe ".described_by" do
29
+ it "should trigger when given the tag :pathname" do
30
+ described_class.described_by?(:pathname).should be_true
31
+ end
32
+
33
+ it "should not be triggered by others tags" do
34
+ described_class.described_by?(:string).should_not be_true
35
+ described_class.described_by?(:integer).should_not be_true
36
+ end
37
+ end
38
+
39
+ describe "#descrition" do
40
+ it "should describe its conversion result" do
41
+ conversion.description.should eql "a pathname"
42
+ end
43
+ end
44
+
45
+ describe "#suitable?" do
46
+ it "should accept a String" do
47
+ conversion.suitable?('test').should be_true
48
+ end
49
+
50
+ it "should accept a String-like" do
51
+ input = /abc/
52
+
53
+ def input.to_str
54
+ to_s
55
+ end
56
+
57
+ conversion.suitable?(input).should be_true
58
+ end
59
+
60
+ it "should accept an Array" do
61
+ conversion.suitable?(['abc', 'def']).should be_true
62
+ end
63
+
64
+ it "should not accept an other types" do
65
+ conversion.suitable?(123).should_not be_true
66
+ conversion.suitable?(/abc/).should_not be_true
67
+ conversion.suitable?(Object.new).should_not be_true
68
+ end
69
+ end
70
+
71
+ describe "#covert" do
72
+ it "should convert a String to Pathname" do
73
+ input = 'relative/path/to/something'
74
+
75
+ conversion.convert(input).should eql(
76
+ Pathname.new('relative/path/to/something'))
77
+ end
78
+
79
+ it "should convert an Array of Strings to an Array of Pathnames" do
80
+ input = ['/tmp', 'relative/fnord', '/path/to/something']
81
+
82
+ conversion.convert(input).should eql [
83
+ Pathname.new('/tmp'),
84
+ Pathname.new('relative/fnord'),
85
+ Pathname.new('/path/to/something')
86
+ ]
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ require 'bundler'
21
+
22
+ Bundler.setup
23
+
24
+ require 'simplecov'
25
+ require 'coveralls'
26
+
27
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
28
+ SimpleCov::Formatter::HTMLFormatter,
29
+ Coveralls::SimpleCov::Formatter
30
+ ]
31
+
32
+ SimpleCov.start do
33
+ add_filter "/spec/"
34
+ end
35
+
36
+ require 'rspec'
37
+ require 'pry'
38
+ require 'user-choices-pathname'
@@ -0,0 +1,55 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2009-2013
4
+
5
+ This file is part of Pathname for user-choices.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ require File.expand_path('../lib/god_object/pathname_conversion/version', __FILE__)
21
+
22
+ Gem::Specification.new do |gem|
23
+ gem.name = "user-choices-pathname"
24
+ gem.version = GodObject::PathnameConversion::VERSION.dup
25
+ gem.authors = ["Alexander E. Fischer"]
26
+ gem.email = ["aef@godobject.net"]
27
+ gem.description = <<-DESCRIPTION
28
+ Pathname for the user-choices command-line argument parser allows choices to be
29
+ automatically converted to Pathname objects.
30
+ DESCRIPTION
31
+ gem.summary = "Pathname type for choices in user-choices."
32
+ gem.homepage = "https://www.godobject.net/"
33
+ gem.license = "ISC"
34
+ gem.has_rdoc = "yard"
35
+ gem.extra_rdoc_files = ["HISTORY.md", "LICENSE.md"]
36
+ gem.rubyforge_project = nil
37
+
38
+ gem.files = `git ls-files`.split($/)
39
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
40
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
41
+ gem.require_paths = ["lib"]
42
+
43
+ gem.required_ruby_version = '>= 1.9.3'
44
+
45
+ gem.add_development_dependency('rspec', '2.14.1')
46
+ gem.add_development_dependency('pry')
47
+ gem.add_development_dependency('simplecov')
48
+ gem.add_development_dependency('rake')
49
+ gem.add_development_dependency('yard')
50
+
51
+ gem.add_dependency('user-choices')
52
+
53
+ gem.cert_chain = "#{ENV['GEM_CERT_CHAIN']}".split(':')
54
+ gem.signing_key = ENV['GEM_SIGNING_KEY']
55
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: user-choices-pathname
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexander E. Fischer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain:
12
+ - !binary |-
13
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURLRENDQWhDZ0F3SUJB
14
+ Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREE2TVF3d0NnWURWUVFEREFOaFpX
15
+ WXgKRlRBVEJnb0praWFKay9Jc1pBRVpGZ1Z5WVhoNWN6RVRNQkVHQ2dtU0pv
16
+ bVQ4aXhrQVJrV0EyNWxkREFlRncwdwpPVEF5TWpVeU1ETTVNRGhhRncweE1E
17
+ QXlNalV5TURNNU1EaGFNRG94RERBS0JnTlZCQU1NQTJGbFpqRVZNQk1HCkNn
18
+ bVNKb21UOGl4a0FSa1dCWEpoZUhsek1STXdFUVlLQ1pJbWlaUHlMR1FCR1JZ
19
+ RGJtVjBNSUlCSWpBTkJna3EKaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dL
20
+ Q0FRRUFvWXRqMHFhZDUvTXBiZHR0SVR6QkgwaDFTTmU2ZU83Ugo3cVZlcU5Z
21
+ dTZxRFFBUTByWWMwSmh1YkpDV1lyWkVKb3JIRUJoVUZVNmNkUWdRT3M3OHdp
22
+ SmFEZ2tlVTdZZlhCCnEybDEyNWtKOGFIa0ExdWtySzIvRFJ6cDJBSEVtenhI
23
+ SVlwWFY1LzYzaCtOV2pDUCt1S3ZURUxZc290UzJNS3QKM2Q0M0UwUWFqc1Ba
24
+ dTJadU5Gd2tyb3FldWU4NzJnTUhVbGRHT1Z5NVd0U2Q5YWp3MnhJL0NvY2lZ
25
+ Njc0NmRMKwpwWXJpVjNRYVl0Ui9lemVhTHBLQkxzYzVUMVVRMDd0N1hzN21J
26
+ MjgxdGRtUnZwTGRQNWRRaGp6SW5maW8wQ0p2CjFQZjViWlVqR0cwSzlSVzJH
27
+ Yi90R1BTWUVFVGlMTXViakg2MU93Qm9vWEtpV1I1Y3M0LzFCUUlEQVFBQm96
28
+ a3cKTnpBSkJnTlZIUk1FQWpBQU1Bc0dBMVVkRHdRRUF3SUVzREFkQmdOVkhR
29
+ NEVGZ1FVU1l2amhHMkVXblI1a3g1bApEQWV3WENrSk9WRXdEUVlKS29aSWh2
30
+ Y05BUUVGQlFBRGdnRUJBQjJyeURiVTRiUXRudW5Ldi9BWHE0Q3VPM0xTCmtp
31
+ azlYaHllOEUvNWRUY3NnaXRDWkpYQXF4MHJIY0swdTJFSG5qQTVDRGNkRjVK
32
+ QjdYZ1N2UnJRa0ZXb1cvOUsKbENCNGloK3NCMkFJMklVaVlCZW9DR2N0WGRC
33
+ UTAyMHBycW9wL29UUUV1ZHpGay9neVE2ODZscDA2SGRMUnQrTwpIb1FqVElh
34
+ Yjh2bWZnSXVialBkSVJ6b2tNZkhiZWx2aExpK21RZldWZ2hSaHMyanBFZmRY
35
+ YkwwdzVuTncrdHJwCnJPNzBEdzU5aGR1RFVPcGdweGV3K1BMYnM0dlAxdGIx
36
+ UUtQRyszOUMrUFp0b3NiYmYxZmFpMGhxWVYxdHhNQ3gKNTVha0YrTjhOYk82
37
+ dHBWRHk2VE1hZ3FhMTBMZkVwaVFINmR2REhlL3hkQXFZT0NyWEtwbXF6d3Uy
38
+ UEk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
39
+ date: 2013-10-16 00:00:00.000000000 Z
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 2.14.1
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - '='
55
+ - !ruby/object:Gem::Version
56
+ version: 2.14.1
57
+ - !ruby/object:Gem::Dependency
58
+ name: pry
59
+ requirement: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: simplecov
75
+ requirement: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ type: :development
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ - !ruby/object:Gem::Dependency
106
+ name: yard
107
+ requirement: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ - !ruby/object:Gem::Dependency
122
+ name: user-choices
123
+ requirement: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ type: :runtime
130
+ prerelease: false
131
+ version_requirements: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ description: ! 'Pathname for the user-choices command-line argument parser allows
138
+ choices to be
139
+
140
+ automatically converted to Pathname objects.
141
+
142
+ '
143
+ email:
144
+ - aef@godobject.net
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files:
148
+ - HISTORY.md
149
+ - LICENSE.md
150
+ files:
151
+ - .coveralls.yml
152
+ - .gitignore
153
+ - .rspec
154
+ - .travis.yml
155
+ - .yardopts
156
+ - Gemfile
157
+ - HISTORY.md
158
+ - LICENSE.md
159
+ - README.md
160
+ - Rakefile
161
+ - lib/god_object/pathname_conversion.rb
162
+ - lib/god_object/pathname_conversion/.conversion_to_pathname.rb.swp
163
+ - lib/god_object/pathname_conversion/conversion_to_pathname.rb
164
+ - lib/god_object/pathname_conversion/version.rb
165
+ - lib/user-choices-pathname.rb
166
+ - spec/god_object/pathname_conversion/conversion_to_pathname_spec.rb
167
+ - spec/spec_helper.rb
168
+ - user-choices-pathname.gemspec
169
+ homepage: https://www.godobject.net/
170
+ licenses:
171
+ - ISC
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: 1.9.3
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ! '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ requirements: []
189
+ rubyforge_project:
190
+ rubygems_version: 1.8.24
191
+ signing_key:
192
+ specification_version: 3
193
+ summary: Pathname type for choices in user-choices.
194
+ test_files:
195
+ - spec/god_object/pathname_conversion/conversion_to_pathname_spec.rb
196
+ - spec/spec_helper.rb
197
+ has_rdoc: yard
metadata.gz.sig ADDED
Binary file