upoj-rb 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/.rvmrc ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p180@upoj-rb"
8
+
9
+ #
10
+ # First we attempt to load the desired environment directly from the environment
11
+ # file. This is very fast and efficicent compared to running through the entire
12
+ # CLI and selector. If you want feedback on which environment was used then
13
+ # insert the word 'use' after --create as this triggers verbose mode.
14
+ #
15
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
16
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
17
+ then
18
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
19
+
20
+ if [[ -s ".rvm/hooks/after_use" ]]
21
+ then
22
+ . ".rvm/hooks/after_use"
23
+ fi
24
+ else
25
+ # If the environment file has not yet been created, use the RVM CLI to select.
26
+ if ! rvm --create "$environment_id"
27
+ then
28
+ echo "Failed to create RVM environment ''."
29
+ fi
30
+ fi
31
+
32
+ #
33
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
34
+ # it be automatically loaded. Uncomment the following and adjust the filename if
35
+ # necessary.
36
+ #
37
+ # filename=".gems"
38
+ # if [[ -s "$filename" ]] ; then
39
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
40
+ # fi
41
+
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem 'rspec'
10
+ gem 'shoulda'
11
+ gem 'bundler', "~> 1.0.0"
12
+ gem 'jeweler', "~> 1.6.4"
13
+ gem 'gemcutter'
14
+ gem 'rdoc'
15
+ #gem 'rcov', ">= 0"
16
+ end
@@ -0,0 +1,32 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ gemcutter (0.7.0)
6
+ git (1.2.5)
7
+ jeweler (1.6.4)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rake (0.9.2)
12
+ rdoc (3.9.4)
13
+ rspec (2.6.0)
14
+ rspec-core (~> 2.6.0)
15
+ rspec-expectations (~> 2.6.0)
16
+ rspec-mocks (~> 2.6.0)
17
+ rspec-core (2.6.4)
18
+ rspec-expectations (2.6.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.6.0)
21
+ shoulda (2.11.3)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ bundler (~> 1.0.0)
28
+ gemcutter
29
+ jeweler (~> 1.6.4)
30
+ rdoc
31
+ rspec
32
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 AlphaHydrae
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ = upoj-rb
2
+
3
+ Ruby scripting utilities.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2011 AlphaHydrae. See LICENSE.txt for
8
+ further details.
9
+
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "upoj-rb"
18
+ gem.homepage = "http://github.com/AlphaHydrae/upoj-rb"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby scripting utilities.}
21
+ gem.description = %Q{This contains common ruby extensions mostly taken from Rails, as well as various command-line utilities.}
22
+ gem.email = "hydrae.alpha@gmail.com"
23
+ gem.authors = ["AlphaHydrae"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+
29
+ require 'rspec/core/rake_task'
30
+ desc "Run specs"
31
+ RSpec::Core::RakeTask.new do |t|
32
+ #t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
33
+ # Put spec opts in a file named .rspec in root
34
+ end
35
+
36
+ #require 'rcov/rcovtask'
37
+ #Rcov::RcovTask.new do |test|
38
+ # test.libs << 'test'
39
+ # test.pattern = 'test/**/test_*.rb'
40
+ # test.verbose = true
41
+ # test.rcov_opts << '--exclude "gems/*"'
42
+ #end
43
+
44
+ task :default => :test
45
+
46
+ require 'rdoc/task'
47
+ RDoc::Task.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "upoj-rb #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,5 @@
1
+ module Upoj
2
+
3
+ end
4
+
5
+ %w( ext opts ).each{ |dep| require File.join(File.dirname(__FILE__), 'upoj-rb', dep) }
@@ -0,0 +1,75 @@
1
+ class Object
2
+
3
+ # An object is blank if it's false, empty, or a whitespace string. For
4
+ # example, "", " ", nil, [], and {} are blank.
5
+ #
6
+ # This simplifies:
7
+ #
8
+ # if !address.nil? && !address.empty?
9
+ # ... to:
10
+ #
11
+ # if !address.blank?
12
+ def blank?
13
+ !self or (respond_to?(:empty?) and empty?)
14
+ end
15
+
16
+ # An object is present if it's not blank.
17
+ def present?
18
+ !blank?
19
+ end
20
+
21
+ # Invokes the method identified by the symbol method, passing it any
22
+ # arguments and/or the block specified, just like the regular Ruby Object#send does.
23
+ #
24
+ # Unlike that method however, a NoMethodError exception will not be
25
+ # raised and nil will be returned instead, if the receiving object is
26
+ # a nil object or NilClass.
27
+ #
28
+ # ==== Examples
29
+ # Without try
30
+ # @person && @person.name
31
+ # or
32
+ # @person ? @person.name : nil
33
+ # With try
34
+ # @person.try(:name)
35
+ #
36
+ # try also accepts arguments and/or a block, for the method it is trying
37
+ # hash.try :[], key
38
+ # array.try(:collect){ |e| e.reverse }
39
+ def try method, *args, &block
40
+ nil? ? nil : send(method, *args, &block)
41
+ end
42
+ end
43
+
44
+ class String
45
+
46
+ # Astring is blank if it's empty or a whitespace string.
47
+ # For example, "" and " " are blank.
48
+ def blank?
49
+ self !~ /\S/
50
+ end
51
+ end
52
+
53
+ class Array
54
+
55
+ # Extracts options from a set of arguments. Removes and returns the
56
+ # last element in the array if it's a hash, otherwise returns a blank hash.
57
+ def extract_options!
58
+ if last.kind_of?(Hash) and last.extractable_options?
59
+ pop
60
+ else
61
+ {}
62
+ end
63
+ end
64
+ end
65
+
66
+ class Hash
67
+
68
+ # By default, only instances of Hash itself are extractable. Subclasses
69
+ # of Hash may implement this method and return true to declare themselves
70
+ # as extractable. If a Hash is extractable, Array#extract_options! pops it
71
+ # from the Array when it is the last element of the Array.
72
+ def extractable_options?
73
+ instance_of?(Hash)
74
+ end
75
+ end
@@ -0,0 +1,12 @@
1
+ require 'optparse'
2
+
3
+ module Upoj
4
+
5
+ class Opts < OptionParser
6
+ attr_accessor :funnel
7
+
8
+ def on_funnel name, *args
9
+ super(*args){ |val| (@funnel ||= Hash.new)[name] = val }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ [
4
+ { :object => nil, :description => :nil },
5
+ { :object => [], :description => 'Empty array' },
6
+ { :object => {}, :description => 'Empty hash' },
7
+ { :object => '', :description => 'Empty string' },
8
+ { :object => ' ', :description => 'Whitespace string' },
9
+ { :object => false, :description => :false }
10
+ ].each do |item|
11
+
12
+ describe item[:description] do
13
+ it "should be blank?" do
14
+ item[:object].blank?.should == true
15
+ end
16
+
17
+ it "should not be present?" do
18
+ item[:object].present?.should == false
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+
3
+ describe Object do
4
+ %w( blank? present? try ).each do |method|
5
+ it{ should respond_to(method) }
6
+ end
7
+ end
8
+
9
+ describe Array do
10
+ it{ should respond_to(:extract_options!) }
11
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'rspec'
13
+ require 'shoulda'
14
+
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
17
+ require 'upoj-rb'
18
+
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "upoj-rb"
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["AlphaHydrae"]
12
+ s.date = "2011-09-30"
13
+ s.description = "This contains common ruby extensions mostly taken from Rails, as well as various command-line utilities."
14
+ s.email = "hydrae.alpha@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/upoj-rb.rb",
30
+ "lib/upoj-rb/ext.rb",
31
+ "lib/upoj-rb/opts.rb",
32
+ "spec/blank_spec.rb",
33
+ "spec/ext_spec.rb",
34
+ "spec/helper.rb",
35
+ "upoj-rb.gemspec"
36
+ ]
37
+ s.homepage = "http://github.com/AlphaHydrae/upoj-rb"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.10"
41
+ s.summary = "Ruby scripting utilities."
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<rspec>, [">= 0"])
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
51
+ s.add_development_dependency(%q<gemcutter>, [">= 0"])
52
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<rspec>, [">= 0"])
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
58
+ s.add_dependency(%q<gemcutter>, [">= 0"])
59
+ s.add_dependency(%q<rdoc>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rspec>, [">= 0"])
63
+ s.add_dependency(%q<shoulda>, [">= 0"])
64
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
+ s.add_dependency(%q<gemcutter>, [">= 0"])
67
+ s.add_dependency(%q<rdoc>, [">= 0"])
68
+ end
69
+ end
70
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: upoj-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - AlphaHydrae
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &2154063700 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2154063700
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &2156225260 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2156225260
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &2156838500 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2156838500
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &2156866340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.4
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2156866340
58
+ - !ruby/object:Gem::Dependency
59
+ name: gemcutter
60
+ requirement: &2156867780 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2156867780
69
+ - !ruby/object:Gem::Dependency
70
+ name: rdoc
71
+ requirement: &2156869220 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2156869220
80
+ description: This contains common ruby extensions mostly taken from Rails, as well
81
+ as various command-line utilities.
82
+ email: hydrae.alpha@gmail.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.rdoc
88
+ files:
89
+ - .document
90
+ - .rspec
91
+ - .rvmrc
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.rdoc
96
+ - Rakefile
97
+ - VERSION
98
+ - lib/upoj-rb.rb
99
+ - lib/upoj-rb/ext.rb
100
+ - lib/upoj-rb/opts.rb
101
+ - spec/blank_spec.rb
102
+ - spec/ext_spec.rb
103
+ - spec/helper.rb
104
+ - upoj-rb.gemspec
105
+ homepage: http://github.com/AlphaHydrae/upoj-rb
106
+ licenses:
107
+ - MIT
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ segments:
119
+ - 0
120
+ hash: 1617318451971428399
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 1.8.10
130
+ signing_key:
131
+ specification_version: 3
132
+ summary: Ruby scripting utilities.
133
+ test_files: []