utilio 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.bundle/config +2 -0
- data/.bundle/environment.rb +259 -0
- data/.document +5 -0
- data/.gitignore +21 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +20 -0
- data/README.md +17 -0
- data/Rakefile +43 -0
- data/VERSION +1 -0
- data/lib/utilio/database.rb +15 -0
- data/lib/utilio/path.rb +35 -0
- data/lib/utilio.rb +9 -0
- data/spec/data/database.yml +1 -0
- data/spec/data/path.yml +1 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/utilio_database_spec.rb +15 -0
- data/spec/utilio_path_spec.rb +45 -0
- metadata +98 -0
data/.bundle/config
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
# DO NOT MODIFY THIS FILE
|
2
|
+
# Generated by Bundler 0.9.26
|
3
|
+
|
4
|
+
require 'digest/sha1'
|
5
|
+
require 'yaml'
|
6
|
+
require 'pathname'
|
7
|
+
require 'rubygems'
|
8
|
+
Gem.source_index # ensure Rubygems is fully loaded in Ruby 1.9
|
9
|
+
|
10
|
+
module Gem
|
11
|
+
class Dependency
|
12
|
+
if !instance_methods.map { |m| m.to_s }.include?("requirement")
|
13
|
+
def requirement
|
14
|
+
version_requirements
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Bundler
|
21
|
+
class Specification < Gem::Specification
|
22
|
+
attr_accessor :relative_loaded_from
|
23
|
+
|
24
|
+
def self.from_gemspec(gemspec)
|
25
|
+
spec = allocate
|
26
|
+
gemspec.instance_variables.each do |ivar|
|
27
|
+
spec.instance_variable_set(ivar, gemspec.instance_variable_get(ivar))
|
28
|
+
end
|
29
|
+
spec
|
30
|
+
end
|
31
|
+
|
32
|
+
def loaded_from
|
33
|
+
return super unless relative_loaded_from
|
34
|
+
source.path.join(relative_loaded_from).to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def full_gem_path
|
38
|
+
Pathname.new(loaded_from).dirname.expand_path.to_s
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module SharedHelpers
|
43
|
+
attr_accessor :gem_loaded
|
44
|
+
|
45
|
+
def default_gemfile
|
46
|
+
gemfile = find_gemfile
|
47
|
+
gemfile or raise GemfileNotFound, "Could not locate Gemfile"
|
48
|
+
Pathname.new(gemfile)
|
49
|
+
end
|
50
|
+
|
51
|
+
def in_bundle?
|
52
|
+
find_gemfile
|
53
|
+
end
|
54
|
+
|
55
|
+
def env_file
|
56
|
+
default_gemfile.dirname.join(".bundle/environment.rb")
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def find_gemfile
|
62
|
+
return ENV['BUNDLE_GEMFILE'] if ENV['BUNDLE_GEMFILE']
|
63
|
+
|
64
|
+
previous = nil
|
65
|
+
current = File.expand_path(Dir.pwd)
|
66
|
+
|
67
|
+
until !File.directory?(current) || current == previous
|
68
|
+
filename = File.join(current, 'Gemfile')
|
69
|
+
return filename if File.file?(filename)
|
70
|
+
current, previous = File.expand_path("..", current), current
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def clean_load_path
|
75
|
+
# handle 1.9 where system gems are always on the load path
|
76
|
+
if defined?(::Gem)
|
77
|
+
me = File.expand_path("../../", __FILE__)
|
78
|
+
$LOAD_PATH.reject! do |p|
|
79
|
+
next if File.expand_path(p).include?(me)
|
80
|
+
p != File.dirname(__FILE__) &&
|
81
|
+
Gem.path.any? { |gp| p.include?(gp) }
|
82
|
+
end
|
83
|
+
$LOAD_PATH.uniq!
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def reverse_rubygems_kernel_mixin
|
88
|
+
# Disable rubygems' gem activation system
|
89
|
+
::Kernel.class_eval do
|
90
|
+
if private_method_defined?(:gem_original_require)
|
91
|
+
alias rubygems_require require
|
92
|
+
alias require gem_original_require
|
93
|
+
end
|
94
|
+
|
95
|
+
undef gem
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def cripple_rubygems(specs)
|
100
|
+
reverse_rubygems_kernel_mixin
|
101
|
+
|
102
|
+
executables = specs.map { |s| s.executables }.flatten
|
103
|
+
Gem.source_index # ensure RubyGems is fully loaded
|
104
|
+
|
105
|
+
::Kernel.class_eval do
|
106
|
+
private
|
107
|
+
def gem(*) ; end
|
108
|
+
end
|
109
|
+
|
110
|
+
::Kernel.send(:define_method, :gem) do |dep, *reqs|
|
111
|
+
if executables.include? File.basename(caller.first.split(':').first)
|
112
|
+
return
|
113
|
+
end
|
114
|
+
opts = reqs.last.is_a?(Hash) ? reqs.pop : {}
|
115
|
+
|
116
|
+
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
117
|
+
dep = Gem::Dependency.new(dep, reqs)
|
118
|
+
end
|
119
|
+
|
120
|
+
spec = specs.find { |s| s.name == dep.name }
|
121
|
+
|
122
|
+
if spec.nil?
|
123
|
+
e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
|
124
|
+
e.name = dep.name
|
125
|
+
e.version_requirement = dep.requirement
|
126
|
+
raise e
|
127
|
+
elsif dep !~ spec
|
128
|
+
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
|
129
|
+
"Make sure all dependencies are added to Gemfile."
|
130
|
+
e.name = dep.name
|
131
|
+
e.version_requirement = dep.requirement
|
132
|
+
raise e
|
133
|
+
end
|
134
|
+
|
135
|
+
true
|
136
|
+
end
|
137
|
+
|
138
|
+
# === Following hacks are to improve on the generated bin wrappers ===
|
139
|
+
|
140
|
+
# Yeah, talk about a hack
|
141
|
+
source_index_class = (class << Gem::SourceIndex ; self ; end)
|
142
|
+
source_index_class.send(:define_method, :from_gems_in) do |*args|
|
143
|
+
source_index = Gem::SourceIndex.new
|
144
|
+
source_index.spec_dirs = *args
|
145
|
+
source_index.add_specs(*specs)
|
146
|
+
source_index
|
147
|
+
end
|
148
|
+
|
149
|
+
# OMG more hacks
|
150
|
+
gem_class = (class << Gem ; self ; end)
|
151
|
+
gem_class.send(:define_method, :bin_path) do |name, *args|
|
152
|
+
exec_name, *reqs = args
|
153
|
+
|
154
|
+
spec = nil
|
155
|
+
|
156
|
+
if exec_name
|
157
|
+
spec = specs.find { |s| s.executables.include?(exec_name) }
|
158
|
+
spec or raise Gem::Exception, "can't find executable #{exec_name}"
|
159
|
+
else
|
160
|
+
spec = specs.find { |s| s.name == name }
|
161
|
+
exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
|
162
|
+
end
|
163
|
+
|
164
|
+
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
165
|
+
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
166
|
+
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
extend self
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
module Bundler
|
175
|
+
ENV_LOADED = true
|
176
|
+
LOCKED_BY = '0.9.26'
|
177
|
+
FINGERPRINT = "79020667ba715c035ff652102ae489830ed4e6f9"
|
178
|
+
HOME = '/Users/bj/.rvm/gems/ruby-1.9.2-rc2/bundler'
|
179
|
+
AUTOREQUIRES = {:development=>[["rspec", false]], :test=>[["rspec", false]]}
|
180
|
+
SPECS = [
|
181
|
+
{:name=>"diff-lcs", :load_paths=>["/Users/bj/.rvm/gems/ruby-1.9.2-rc2/gems/diff-lcs-1.1.2/lib"], :loaded_from=>"/Users/bj/.rvm/gems/ruby-1.9.2-rc2/specifications/diff-lcs-1.1.2.gemspec"},
|
182
|
+
{:name=>"rspec-core", :load_paths=>["/Users/bj/.rvm/gems/ruby-1.9.2-rc2/gems/rspec-core-2.0.0.beta.19/lib"], :loaded_from=>"/Users/bj/.rvm/gems/ruby-1.9.2-rc2/specifications/rspec-core-2.0.0.beta.19.gemspec"},
|
183
|
+
{:name=>"rspec-expectations", :load_paths=>["/Users/bj/.rvm/gems/ruby-1.9.2-rc2/gems/rspec-expectations-2.0.0.beta.19/lib"], :loaded_from=>"/Users/bj/.rvm/gems/ruby-1.9.2-rc2/specifications/rspec-expectations-2.0.0.beta.19.gemspec"},
|
184
|
+
{:name=>"rspec-mocks", :load_paths=>["/Users/bj/.rvm/gems/ruby-1.9.2-rc2/gems/rspec-mocks-2.0.0.beta.19/lib"], :loaded_from=>"/Users/bj/.rvm/gems/ruby-1.9.2-rc2/specifications/rspec-mocks-2.0.0.beta.19.gemspec"},
|
185
|
+
{:name=>"rspec", :load_paths=>["/Users/bj/.rvm/gems/ruby-1.9.2-rc2/gems/rspec-2.0.0.beta.19/lib"], :loaded_from=>"/Users/bj/.rvm/gems/ruby-1.9.2-rc2/specifications/rspec-2.0.0.beta.19.gemspec"},
|
186
|
+
].map do |hash|
|
187
|
+
if hash[:virtual_spec]
|
188
|
+
spec = eval(hash[:virtual_spec], TOPLEVEL_BINDING, "<virtual spec for '#{hash[:name]}'>")
|
189
|
+
else
|
190
|
+
dir = File.dirname(hash[:loaded_from])
|
191
|
+
spec = Dir.chdir(dir){ eval(File.read(hash[:loaded_from]), TOPLEVEL_BINDING, hash[:loaded_from]) }
|
192
|
+
end
|
193
|
+
spec.loaded_from = hash[:loaded_from]
|
194
|
+
spec.require_paths = hash[:load_paths]
|
195
|
+
if spec.loaded_from.include?(HOME)
|
196
|
+
Bundler::Specification.from_gemspec(spec)
|
197
|
+
else
|
198
|
+
spec
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
extend SharedHelpers
|
203
|
+
|
204
|
+
def self.configure_gem_path_and_home(specs)
|
205
|
+
# Fix paths, so that Gem.source_index and such will work
|
206
|
+
paths = specs.map{|s| s.installation_path }
|
207
|
+
paths.flatten!; paths.compact!; paths.uniq!; paths.reject!{|p| p.empty? }
|
208
|
+
ENV['GEM_PATH'] = paths.join(File::PATH_SEPARATOR)
|
209
|
+
ENV['GEM_HOME'] = paths.first
|
210
|
+
Gem.clear_paths
|
211
|
+
end
|
212
|
+
|
213
|
+
def self.match_fingerprint
|
214
|
+
lockfile = File.expand_path('../../Gemfile.lock', __FILE__)
|
215
|
+
lock_print = YAML.load(File.read(lockfile))["hash"] if File.exist?(lockfile)
|
216
|
+
gem_print = Digest::SHA1.hexdigest(File.read(File.expand_path('../../Gemfile', __FILE__)))
|
217
|
+
|
218
|
+
unless gem_print == lock_print
|
219
|
+
abort 'Gemfile changed since you last locked. Please run `bundle lock` to relock.'
|
220
|
+
end
|
221
|
+
|
222
|
+
unless gem_print == FINGERPRINT
|
223
|
+
abort 'Your bundled environment is out of date. Run `bundle install` to regenerate it.'
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def self.setup(*groups)
|
228
|
+
match_fingerprint
|
229
|
+
clean_load_path
|
230
|
+
cripple_rubygems(SPECS)
|
231
|
+
configure_gem_path_and_home(SPECS)
|
232
|
+
SPECS.each do |spec|
|
233
|
+
Gem.loaded_specs[spec.name] = spec
|
234
|
+
spec.require_paths.each do |path|
|
235
|
+
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
self
|
239
|
+
end
|
240
|
+
|
241
|
+
def self.require(*groups)
|
242
|
+
groups = [:default] if groups.empty?
|
243
|
+
groups.each do |group|
|
244
|
+
(AUTOREQUIRES[group.to_sym] || []).each do |file, explicit|
|
245
|
+
if explicit
|
246
|
+
Kernel.require file
|
247
|
+
else
|
248
|
+
begin
|
249
|
+
Kernel.require file
|
250
|
+
rescue LoadError
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
# Set up load paths unless this file is being loaded after the Bundler gem
|
258
|
+
setup unless defined?(Bundler::GEM_LOADED)
|
259
|
+
end
|
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
hash: 79020667ba715c035ff652102ae489830ed4e6f9
|
3
|
+
sources:
|
4
|
+
- Rubygems:
|
5
|
+
uri: http://gemcutter.org
|
6
|
+
specs:
|
7
|
+
- diff-lcs:
|
8
|
+
version: 1.1.2
|
9
|
+
- rspec-core:
|
10
|
+
version: 2.0.0.beta.19
|
11
|
+
- rspec-expectations:
|
12
|
+
version: 2.0.0.beta.19
|
13
|
+
- rspec-mocks:
|
14
|
+
version: 2.0.0.beta.19
|
15
|
+
- rspec:
|
16
|
+
version: 2.0.0.beta.19
|
17
|
+
dependencies:
|
18
|
+
rspec:
|
19
|
+
version: ">= 2.0.0.beta.18"
|
20
|
+
group:
|
21
|
+
- :development
|
22
|
+
- :test
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 BJ Neilsen
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= utilio
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 BJ Neilsen. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "utilio"
|
8
|
+
gem.summary = %Q{A general collection of application utilities for dealing with paths and active_record}
|
9
|
+
gem.description = %Q{}
|
10
|
+
gem.email = "bj.neilsen@gmail.com"
|
11
|
+
gem.homepage = "http://www.rand9.com"
|
12
|
+
gem.authors = ["BJ Neilsen"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rspec/core/rake_task'
|
22
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
23
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
27
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
28
|
+
spec.rcov = true
|
29
|
+
end
|
30
|
+
|
31
|
+
task :spec => :check_dependencies
|
32
|
+
|
33
|
+
task :default => :spec
|
34
|
+
|
35
|
+
require 'rake/rdoctask'
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
38
|
+
|
39
|
+
rdoc.rdoc_dir = 'rdoc'
|
40
|
+
rdoc.title = "utilio #{version}"
|
41
|
+
rdoc.rdoc_files.include('README*')
|
42
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'utilio/path'
|
2
|
+
|
3
|
+
module Utilio
|
4
|
+
class Database
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# Load the configuration file from your application root
|
8
|
+
def config options={environment: nil, file: 'config/database.yml'}
|
9
|
+
config = Path.yaml_file(options[:file])
|
10
|
+
options[:environment].nil? ? config : config[options[:environment]]
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/utilio/path.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Utilio
|
4
|
+
class Path
|
5
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def root= new_root
|
10
|
+
@app_root = new_root
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get the root path of the application, optionally passing in additional folders to be joined and expanded
|
14
|
+
# e.g. PathUtils.root 'db', 'migrate' # => /path/to/loudmouth/db/migrate
|
15
|
+
def root *folders
|
16
|
+
File.expand_path(File.join(*([app_root, folders].flatten)))
|
17
|
+
end
|
18
|
+
|
19
|
+
def app *folders
|
20
|
+
root(*['app', folders].flatten)
|
21
|
+
end
|
22
|
+
|
23
|
+
def yaml_file *path_to_file
|
24
|
+
YAML.load_file(root(*path_to_file))
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def app_root
|
30
|
+
@app_root || File.expand_path(File.dirname($0))
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/utilio.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
database: 'test'
|
data/spec/data/path.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
path: 'test'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.setup :default, :test
|
7
|
+
require 'utilio'
|
8
|
+
require 'rspec'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Utilio::Database do
|
4
|
+
|
5
|
+
let(:config_file) { 'data/database.yml' }
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
Utilio::Path.root = File.dirname(__FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should allow you to load a db configuration" do
|
12
|
+
Utilio::Database.config(file: config_file).should_not be_nil
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Utilio::Path do
|
4
|
+
|
5
|
+
let(:fake_root) { "/my/fake/root" }
|
6
|
+
let(:fake_app) { File.join(fake_root, 'app') }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
Utilio::Path.root = fake_root
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should assume the root path without any settings" do
|
13
|
+
Utilio::Path.root = nil
|
14
|
+
Utilio::Path.root.should == File.expand_path(File.dirname($0))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should allow you to set the root path" do
|
18
|
+
Utilio::Path.root.should == fake_root
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should allow path joining with the root path" do
|
22
|
+
Utilio::Path.root('another', 'folder').should == File.join(fake_root, 'another', 'folder')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be able to set a root path relatively" do
|
26
|
+
abs_path = File.expand_path(File.dirname(__FILE__))
|
27
|
+
Utilio::Path.root = File.dirname(__FILE__)
|
28
|
+
Utilio::Path.root.should == abs_path
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should shortcut paths to an application's app folder" do
|
32
|
+
Utilio::Path.app.should == fake_app
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should allow path joining with the app path" do
|
36
|
+
Utilio::Path.app('another', 'folder').should == File.join(fake_app, 'another', 'folder')
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to load yaml files from the root" do
|
40
|
+
# pending 'need to test something else'
|
41
|
+
Utilio::Path.root = File.dirname(__FILE__)
|
42
|
+
Utilio::Path.yaml_file('data', 'path.yml').should have_key('path')
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: utilio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- BJ Neilsen
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-06 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 2
|
31
|
+
- 9
|
32
|
+
version: 1.2.9
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: ""
|
36
|
+
email: bj.neilsen@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
files:
|
45
|
+
- .bundle/config
|
46
|
+
- .bundle/environment.rb
|
47
|
+
- .document
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- VERSION
|
55
|
+
- lib/utilio.rb
|
56
|
+
- lib/utilio/database.rb
|
57
|
+
- lib/utilio/path.rb
|
58
|
+
- spec/data/database.yml
|
59
|
+
- spec/data/path.yml
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- spec/utilio_database_spec.rb
|
62
|
+
- spec/utilio_path_spec.rb
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: http://www.rand9.com
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --charset=UTF-8
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: A general collection of application utilities for dealing with paths and active_record
|
95
|
+
test_files:
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/utilio_database_spec.rb
|
98
|
+
- spec/utilio_path_spec.rb
|