Permalink
Browse files

Clean up file joins/reads

  • Loading branch information...
1 parent 00fb27b commit bd05269ef76146e0c0c77bb8f3233f66ab396d6d @nbibler nbibler committed Jun 17, 2011
Showing with 7 additions and 6 deletions.
  1. +2 −2 app/models/keymaster.rb
  2. +3 −2 lib/tasks/test.rake
  3. +2 −2 test/test_helper.rb
View
@@ -4,15 +4,15 @@ module Keymaster
# Returns the current version number of the application.
#
def self.version
- @@version ||= File.read(File.join(Rails.root, 'VERSION')).strip
+ @@version ||= Rails.root.join('VERSION').read.strip
end
##
# Returns the data (content) for the gatekeeper.rb file to be executed by
# the servers.
#
def self.gatekeeper_data
- @@gatekeeper_data ||= File.read(File.join(Rails.root, 'lib', 'gatekeeper.rb')).
+ @@gatekeeper_data ||= Rails.root.join('lib/gatekeeper.rb').read.
gsub('%CURRENT_KEYMASTER_VERSION%', self.version).
gsub('%CURRENT_PUBLIC_KEY%', ENV['PUBLIC_SIGNING_KEY'])
end
View
@@ -2,8 +2,9 @@ namespace :test do
namespace :ci do
desc "Configure the CI test server"
task :configure do
- root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
- cp File.join(root, 'config/database.ci.yml'), File.join(root, 'config/database.yml')
+ require 'pathname'
+ root = Pathname.new File.expand_path('../../../', __FILE__)
+ cp root.join('config/database.ci.yml'), root.join('config/database.yml')
end
end
end
View
@@ -1,6 +1,6 @@
ENV["RAILS_ENV"] = "test"
-ENV["PUBLIC_SIGNING_KEY"] = File.read(File.join(File.dirname(__FILE__), 'public.key'))
-ENV["PRIVATE_SIGNING_KEY"] = File.read(File.join(File.dirname(__FILE__), 'private.key'))
+ENV["PUBLIC_SIGNING_KEY"] = File.read(File.expand_path('../public.key', __FILE__))
+ENV["PRIVATE_SIGNING_KEY"] = File.read(File.expand_path('../private.key', __FILE__))
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

0 comments on commit bd05269

Please sign in to comment.