├── var ├── name ├── title ├── version ├── created ├── organizations ├── authors ├── summary ├── copyrights ├── repositories ├── requirements ├── description └── resources ├── lib ├── clik.yml ├── clik │ └── ask.rb └── clik.rb ├── Gemfile ├── demo ├── applique │ └── req.rb └── clik.md ├── .gitignore ├── .travis.yml ├── HISTORY.md ├── NOTICE.txt ├── LICENSE.txt ├── .index ├── README.md └── .gemspec /var/name: -------------------------------------------------------------------------------- 1 | clik 2 | -------------------------------------------------------------------------------- /lib/clik.yml: -------------------------------------------------------------------------------- 1 | ../.index -------------------------------------------------------------------------------- /var/title: -------------------------------------------------------------------------------- 1 | CLI.K 2 | -------------------------------------------------------------------------------- /var/version: -------------------------------------------------------------------------------- 1 | 0.1.0 2 | -------------------------------------------------------------------------------- /var/created: -------------------------------------------------------------------------------- 1 | 2013-01-01 2 | -------------------------------------------------------------------------------- /var/organizations: -------------------------------------------------------------------------------- 1 | --- 2 | - Rubyworks 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | gemspec 3 | -------------------------------------------------------------------------------- /var/authors: -------------------------------------------------------------------------------- 1 | --- 2 | - Trans 3 | -------------------------------------------------------------------------------- /var/summary: -------------------------------------------------------------------------------- 1 | Command-line Interface in the Kernel 2 | -------------------------------------------------------------------------------- /demo/applique/req.rb: -------------------------------------------------------------------------------- 1 | require 'ae' 2 | require 'clik' 3 | -------------------------------------------------------------------------------- /var/copyrights: -------------------------------------------------------------------------------- 1 | --- 2 | - (c) 2013 Rubyworks (BSD-2-Clause) 3 | 4 | -------------------------------------------------------------------------------- /var/repositories: -------------------------------------------------------------------------------- 1 | --- 2 | upstream: git://github.com/rubyworks/clik.git 3 | -------------------------------------------------------------------------------- /var/requirements: -------------------------------------------------------------------------------- 1 | --- 2 | - detroit (build) 3 | - ergo (build) 4 | - qed (test) 5 | - ae (test) 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .ergo/digest 2 | .yardoc 3 | doc/ 4 | log/ 5 | pkg/ 6 | tmp/ 7 | web/ 8 | /QED.md 9 | *.lock 10 | *.gem 11 | -------------------------------------------------------------------------------- /var/description: -------------------------------------------------------------------------------- 1 | CLI.K stands for Command Line Interface in the Kernel. It provides a very 2 | simple `cli` method for parsing command line options. 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: ruby 3 | script: "bundle exec qed" 4 | rvm: 5 | - 1.9.2 6 | - 1.9.3 7 | - rbx-19mode 8 | - jruby-19mode 9 | 10 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | # RELEASE HISTORY 2 | 3 | ## 0.1.0 / 2013-02-10 4 | 5 | This is this is the first release of CLI.K. Happy releaseday! 6 | 7 | Changes: 8 | 9 | * All of them ;) 10 | -------------------------------------------------------------------------------- /var/resources: -------------------------------------------------------------------------------- 1 | --- 2 | home: http://rubyworks.github.com/clik 3 | code: http://github.com/rubyworks/clik 4 | docs: http://rubydoc.info/gems/clik 5 | wiki: http://wiki.github.com/rubyworks/clik 6 | bugs: http://github.com/rubyworks/clik/issues 7 | mail: http://groups.google.com/group/rubyworks-mailinglist 8 | -------------------------------------------------------------------------------- /demo/clik.md: -------------------------------------------------------------------------------- 1 | # CLI.K 2 | 3 | CLI.K provides a kernel method. 4 | 5 | opts = {} 6 | argv = ['-x'] 7 | 8 | cli argv, 9 | '-x' => lambda{ opts[:x] = true } 10 | 11 | opts[:x].assert === true 12 | 13 | Another example, 14 | 15 | opts = {} 16 | argv = ['-w', '-f', 'hello'] 17 | 18 | cli argv, 19 | '-w --whatever' => ->{ opts[:w] = true }, 20 | '-f --file' => ->(f){ opts[:f] = f }, 21 | '-h --help' => ->{ puts "help" } 22 | 23 | opts[:w].assert == true 24 | opts[:f].assert == 'hello' 25 | 26 | -------------------------------------------------------------------------------- /lib/clik/ask.rb: -------------------------------------------------------------------------------- 1 | module Kernel 2 | 3 | module_function 4 | 5 | # Very simple convenience method to get user input 6 | # via the console. A prompt will be sent to $stdout, 7 | # if given, and the input taken from $stdin... 8 | # 9 | # ask "Are you happy? [Yn]", "Y" 10 | # 11 | # On the command line one would see... 12 | # 13 | # Are you happy? [Yn] 14 | # 15 | # Responding... 16 | # 17 | # Are you happy? [Yn] Y 18 | # 19 | # The ask method would return "Y". 20 | # 21 | # Returns [String] 22 | def ask(prompt=nil, default_answer=nil) 23 | $stdout << "#{prompt}" 24 | $stdout.flush 25 | ans = $stdin.gets.chomp! 26 | if ans == '' 27 | default_answer 28 | else 29 | ans 30 | end 31 | end 32 | end 33 | 34 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | CLI.K is based on Clap by Michel Martens 2 | 3 | Copyright (c) 2010 Michel Martens 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | (BSD-2-Clause License) 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 14 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 15 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 16 | COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 22 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | -------------------------------------------------------------------------------- /lib/clik.rb: -------------------------------------------------------------------------------- 1 | module Kernel 2 | private 3 | # 4 | # CLI is based on Clap library 5 | # Copyright (c) 2010 Michel Martens 6 | # 7 | def cli(*args) 8 | opts = args.pop 9 | argv = (args.first || ARGV).dup 10 | args = [] 11 | 12 | # Split option aliases. 13 | opts = opts.inject({}) do |h,(k,v)| 14 | k.to_s.split(/\s+/).each{|o| h[o]=v}; h 15 | end 16 | 17 | # Convert single dash flags into multiple flags. 18 | argv = argv.inject([]) do |a, v| 19 | if v[0,1] == '-' && v[1,1] != '-' 20 | a.concat(v[1..-1].chars.map{|c| "-#{c}"}) 21 | else 22 | a << v 23 | end 24 | a 25 | end 26 | 27 | while argv.any? 28 | item = argv.shift 29 | flag = opts[item] 30 | 31 | if flag 32 | # Work around lambda semantics in 1.8.7. 33 | arity = [flag.arity, 0].max 34 | 35 | # Raise if there are not enough parameters 36 | # available for the flag. 37 | if argv.size < arity 38 | raise ArgumentError 39 | end 40 | 41 | # Call the lambda with N items from argv, 42 | # where N is the lambda's arity. 43 | flag.call(*argv.shift(arity)) 44 | else 45 | 46 | # Collect the items that don't correspond to 47 | # flags. 48 | args << item 49 | end 50 | end 51 | 52 | # TODO: should we replace the argv given with args? 53 | 54 | args 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /.index: -------------------------------------------------------------------------------- 1 | --- 2 | revision: 2013 3 | type: ruby 4 | sources: 5 | - var 6 | authors: 7 | - name: Trans 8 | email: transfire@gmail.com 9 | organizations: 10 | - name: Rubyworks 11 | requirements: 12 | - groups: 13 | - build 14 | development: true 15 | name: detroit 16 | - groups: 17 | - build 18 | development: true 19 | name: ergo 20 | - groups: 21 | - test 22 | development: true 23 | name: qed 24 | - groups: 25 | - test 26 | development: true 27 | name: ae 28 | conflicts: [] 29 | alternatives: [] 30 | resources: 31 | - type: home 32 | uri: http://rubyworks.github.com/clik 33 | label: Homepage 34 | - type: code 35 | uri: http://github.com/rubyworks/clik 36 | label: Source Code 37 | - type: docs 38 | uri: http://rubydoc.info/gems/clik 39 | label: Documentation 40 | - type: wiki 41 | uri: http://wiki.github.com/rubyworks/clik 42 | label: User Guide 43 | - type: bugs 44 | uri: http://github.com/rubyworks/clik/issues 45 | label: Issue Tracker 46 | - type: mail 47 | uri: http://groups.google.com/group/rubyworks-mailinglist 48 | label: Mailing List 49 | repositories: 50 | - name: upstream 51 | scm: git 52 | uri: git://github.com/rubyworks/clik.git 53 | categories: [] 54 | copyrights: 55 | - holder: Rubyworks 56 | year: '2013' 57 | license: BSD-2-Clause 58 | customs: [] 59 | paths: 60 | lib: 61 | - lib 62 | created: '2013-01-01' 63 | summary: Command-line Interface in the Kernel 64 | title: CLI.K 65 | version: 0.1.0 66 | name: clik 67 | description: ! "CLI.K stands for Command Line Interface in the Kernel. It provides 68 | a very \nsimple `cli` method for parsing command line options." 69 | date: '2013-03-07' 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CLI.K 2 | 3 | [Website](http://github.com/rubyworks/clik) / 4 | [Documentation](http://rubydoc.info/gems/clik/frames) / 5 | [Report Issue](http://github.com/rubyworks/clik/issues) / 6 | [Source Code](http://github.com/rubyworks/clik)     7 | [![Flattr Me](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund) 8 | 9 | 10 | ## About 11 | 12 | CLI.K stands for Command Line Interface in the Kernel. It provides a very 13 | simple `cli` method for parsing command line options. 14 | 15 | 16 | ## Status 17 | 18 | [![Gem Version](https://badge.fury.io/rb/clik.png)](http://badge.fury.io/rb/clik) 19 | [![Build Status](https://travis-ci.org/rubyworks/clik.png)](https://travis-ci.org/rubyworks/clik) 20 | 21 | 22 | ## Usage 23 | 24 | ### They call it "K.I.S.S." 25 | 26 | Usage is very straightforward, although it might look a little odd at first 27 | glance: 28 | 29 | ```ruby 30 | require 'clik' 31 | 32 | cli '-f --file' => lambda{ |f| @file = f }, 33 | '-d --debug' => lambda{ $DEBUG = true }, 34 | '-h --help' => lambda{ show_help } 35 | ``` 36 | 37 | There's very little to it really. The `cli` command simply maps command 38 | line options to procedures which are used to process them. That's it. 39 | 40 | In our example, notice that `-f` and `--file` are easily defined as 41 | synonymous options. Simple. Then notice that the `-f/--file` option's 42 | procedure takes an argument, so the command line option takes an argument 43 | as well. Again simple. 44 | 45 | The cli method has a few additional niceties. It can handle run-on flags, 46 | i.e. `-abc` is the same as `-a -b -c`. And you can pass it an alternate 47 | set of arguments to parse, as the first argument, to use something other 48 | than the default `ARGV`. 49 | 50 | ```ruby 51 | argv = ['--testing'] 52 | 53 | cli argv, 54 | ... 55 | ``` 56 | 57 | ### You need help, no you really don't 58 | 59 | At this point, you might be wondering about help output. Clearly there are 60 | no descriptions given in our example. Well, guess what! It's really easy 61 | to print something out yourself. In fact, if you really want to *do it right*, 62 | create a manpage with [ronn](git://github.com/rtomayko/ronn.git) or 63 | [md2man](https://github.com/sunaku/md2man), and impress your friends. 64 | It's a much better approach then jamming all that verbiage into the command 65 | line options parser code. 66 | 67 | ### Ask and you shell receive 68 | 69 | In addition to #cli, CLI.K provides the #ask method. This is a very simple 70 | command line query method. 71 | 72 | ans = ask "Are you nice? [Y/n]" 73 | 74 | Other Ruby libraries have their own take on the #ask method, and this very 75 | simple implementation can just as soon be overridden. No biggy. But it's nice 76 | to have for simple use cases. 77 | 78 | 79 | ## Acknowledgments 80 | 81 | We have to give credit where credit is due. This interface is the great 82 | achievement of Michel Martens, who created the original [Clap](https://github.com/soveran/clap) 83 | library from which CLI.K evolved. Mr. Martens deserves high praise for this 84 | design. It's not easy to realize that this level of simplicity is all one 85 | really needs! Thank you, Michel! 86 | 87 | 88 | ## Copyrights & License 89 | 90 | CLI.K is copyrighted open-source software. 91 | 92 | Copyright (c) 2013 Rubyworks 93 | 94 | CLI.K is base on Michel Marten's Clap library. 95 | 96 | Copyright (c) 2010 Michel Martens 97 | 98 | See LICENSE.txt and NOTICE.txt files for details. 99 | -------------------------------------------------------------------------------- /.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'yaml' 4 | require 'pathname' 5 | 6 | module Indexer 7 | 8 | # Convert index data into a gemspec. 9 | # 10 | # Notes: 11 | # * Assumes all executables are in bin/. 12 | # * Does not yet handle default_executable setting. 13 | # * Does not yet handle platform setting. 14 | # * Does not yet handle required_ruby_version. 15 | # * Support for rdoc entries is weak. 16 | # 17 | class GemspecExporter 18 | 19 | # File globs to include in package --unless a manifest file exists. 20 | FILES = ".index .yardopts alt bin data demo ext features lib man spec test try* [A-Z]*.*" unless defined?(FILES) 21 | 22 | # File globs to omit from FILES. 23 | OMIT = "Config.rb" unless defined?(OMIT) 24 | 25 | # Standard file patterns. 26 | PATTERNS = { 27 | :root => '{.index,Gemfile}', 28 | :bin => 'bin/*', 29 | :lib => 'lib/{**/}*', #.rb', 30 | :ext => 'ext/{**/}extconf.rb', 31 | :doc => '*.{txt,rdoc,md,markdown,tt,textile}', 32 | :test => '{test,spec}/{**/}*.rb' 33 | } unless defined?(PATTERNS) 34 | 35 | # For which revision of indexer spec is this converter intended? 36 | REVISION = 2013 unless defined?(REVISION) 37 | 38 | # 39 | def self.gemspec 40 | new.to_gemspec 41 | end 42 | 43 | # 44 | attr :metadata 45 | 46 | # 47 | def initialize(metadata=nil) 48 | @root_check = false 49 | 50 | if metadata 51 | root_dir = metadata.delete(:root) 52 | if root_dir 53 | @root = root_dir 54 | @root_check = true 55 | end 56 | metadata = nil if metadata.empty? 57 | end 58 | 59 | @metadata = metadata || YAML.load_file(root + '.index') 60 | 61 | if @metadata['revision'].to_i != REVISION 62 | warn "This gemspec exporter was not designed for this revision of index metadata." 63 | end 64 | end 65 | 66 | # 67 | def has_root? 68 | root ? true : false 69 | end 70 | 71 | # 72 | def root 73 | return @root if @root || @root_check 74 | @root_check = true 75 | @root = find_root 76 | end 77 | 78 | # 79 | def manifest 80 | return nil unless root 81 | @manifest ||= Dir.glob(root + 'manifest{,.txt}', File::FNM_CASEFOLD).first 82 | end 83 | 84 | # 85 | def scm 86 | return nil unless root 87 | @scm ||= %w{git hg}.find{ |m| (root + ".#{m}").directory? }.to_sym 88 | end 89 | 90 | # 91 | def files 92 | return [] unless root 93 | @files ||= \ 94 | if manifest 95 | File.readlines(manifest). 96 | map{ |line| line.strip }. 97 | reject{ |line| line.empty? || line[0,1] == '#' } 98 | else 99 | list = [] 100 | Dir.chdir(root) do 101 | FILES.split(/\s+/).each do |pattern| 102 | list.concat(glob(pattern)) 103 | end 104 | OMIT.split(/\s+/).each do |pattern| 105 | list = list - glob(pattern) 106 | end 107 | end 108 | list 109 | end.select{ |path| File.file?(path) }.uniq 110 | end 111 | 112 | # 113 | def glob_files(pattern) 114 | return [] unless root 115 | Dir.chdir(root) do 116 | Dir.glob(pattern).select do |path| 117 | File.file?(path) && files.include?(path) 118 | end 119 | end 120 | end 121 | 122 | def patterns 123 | PATTERNS 124 | end 125 | 126 | def executables 127 | @executables ||= \ 128 | glob_files(patterns[:bin]).map do |path| 129 | File.basename(path) 130 | end 131 | end 132 | 133 | def extensions 134 | @extensions ||= \ 135 | glob_files(patterns[:ext]).map do |path| 136 | File.basename(path) 137 | end 138 | end 139 | 140 | def name 141 | metadata['name'] || metadata['title'].downcase.gsub(/\W+/,'_') 142 | end 143 | 144 | def homepage 145 | page = ( 146 | metadata['resources'].find{ |r| r['type'] =~ /^home/i } || 147 | metadata['resources'].find{ |r| r['name'] =~ /^home/i } || 148 | metadata['resources'].find{ |r| r['name'] =~ /^web/i } 149 | ) 150 | page ? page['uri'] : false 151 | end 152 | 153 | def licenses 154 | metadata['copyrights'].map{ |c| c['license'] }.compact 155 | end 156 | 157 | def require_paths 158 | paths = metadata['paths'] || {} 159 | paths['load'] || ['lib'] 160 | end 161 | 162 | # 163 | # Convert to gemnspec. 164 | # 165 | def to_gemspec 166 | if has_root? 167 | Gem::Specification.new do |gemspec| 168 | to_gemspec_data(gemspec) 169 | to_gemspec_paths(gemspec) 170 | end 171 | else 172 | Gem::Specification.new do |gemspec| 173 | to_gemspec_data(gemspec) 174 | to_gemspec_paths(gemspec) 175 | end 176 | end 177 | end 178 | 179 | # 180 | # Convert pure data settings. 181 | # 182 | def to_gemspec_data(gemspec) 183 | gemspec.name = name 184 | gemspec.version = metadata['version'] 185 | gemspec.summary = metadata['summary'] 186 | gemspec.description = metadata['description'] 187 | 188 | metadata['authors'].each do |author| 189 | gemspec.authors << author['name'] 190 | 191 | if author.has_key?('email') 192 | if gemspec.email 193 | gemspec.email << author['email'] 194 | else 195 | gemspec.email = [author['email']] 196 | end 197 | end 198 | end 199 | 200 | gemspec.licenses = licenses 201 | 202 | requirements = metadata['requirements'] || [] 203 | requirements.each do |req| 204 | next if req['optional'] 205 | next if req['external'] 206 | 207 | name = req['name'] 208 | groups = req['groups'] || [] 209 | 210 | version = gemify_version(req['version']) 211 | 212 | if groups.empty? or groups.include?('runtime') 213 | # populate runtime dependencies 214 | if gemspec.respond_to?(:add_runtime_dependency) 215 | gemspec.add_runtime_dependency(name,*version) 216 | else 217 | gemspec.add_dependency(name,*version) 218 | end 219 | else 220 | # populate development dependencies 221 | if gemspec.respond_to?(:add_development_dependency) 222 | gemspec.add_development_dependency(name,*version) 223 | else 224 | gemspec.add_dependency(name,*version) 225 | end 226 | end 227 | end 228 | 229 | # convert external dependencies into gemspec requirements 230 | requirements.each do |req| 231 | next unless req['external'] 232 | gemspec.requirements << ("%s-%s" % req.values_at('name', 'version')) 233 | end 234 | 235 | gemspec.homepage = homepage 236 | gemspec.require_paths = require_paths 237 | gemspec.post_install_message = metadata['install_message'] 238 | end 239 | 240 | # 241 | # Set gemspec settings that require a root directory path. 242 | # 243 | def to_gemspec_paths(gemspec) 244 | gemspec.files = files 245 | gemspec.extensions = extensions 246 | gemspec.executables = executables 247 | 248 | if Gem::VERSION < '1.7.' 249 | gemspec.default_executable = gemspec.executables.first 250 | end 251 | 252 | gemspec.test_files = glob_files(patterns[:test]) 253 | 254 | unless gemspec.files.include?('.document') 255 | gemspec.extra_rdoc_files = glob_files(patterns[:doc]) 256 | end 257 | end 258 | 259 | # 260 | # Return a copy of this file. This is used to generate a local 261 | # .gemspec file that can automatically read the index file. 262 | # 263 | def self.source_code 264 | File.read(__FILE__) 265 | end 266 | 267 | private 268 | 269 | def find_root 270 | root_files = patterns[:root] 271 | if Dir.glob(root_files).first 272 | Pathname.new(Dir.pwd) 273 | elsif Dir.glob("../#{root_files}").first 274 | Pathname.new(Dir.pwd).parent 275 | else 276 | #raise "Can't find root of project containing `#{root_files}'." 277 | warn "Can't find root of project containing `#{root_files}'." 278 | nil 279 | end 280 | end 281 | 282 | def glob(pattern) 283 | if File.directory?(pattern) 284 | Dir.glob(File.join(pattern, '**', '*')) 285 | else 286 | Dir.glob(pattern) 287 | end 288 | end 289 | 290 | def gemify_version(version) 291 | case version 292 | when /^(.*?)\+$/ 293 | ">= #{$1}" 294 | when /^(.*?)\-$/ 295 | "< #{$1}" 296 | when /^(.*?)\~$/ 297 | "~> #{$1}" 298 | else 299 | version 300 | end 301 | end 302 | 303 | end 304 | 305 | end 306 | 307 | Indexer::GemspecExporter.gemspec --------------------------------------------------------------------------------