Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'LeoTeam-lotus-root'
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed May 21, 2015
2 parents 5f3caf8 + 5559549 commit 6f8b9d1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/lotus.rb
Expand Up @@ -10,6 +10,17 @@
#
# @see http://lotusrb.org
module Lotus
# Return root of the project (top level directory).
#
# @return [Pathname] root path
#
# @since x.x.x
#
# @example
# Lotus.root # => #<Pathname:/Users/luca/Code/bookshelf>
def self.root
environment.root
end

# Return the current environment
#
Expand All @@ -22,7 +33,7 @@ module Lotus
# @example
# Lotus.env => "development"
def self.env
Environment.new.environment
environment.environment
end

# Check to see if specified environment(s) matches the current environment.
Expand Down Expand Up @@ -50,6 +61,16 @@ def self.env
# Lotus.env?(:development, :test) # => true
# Lotus.env?(:production, :staging) # => false
def self.env?(*names)
Environment.new.environment?(*names)
environment.environment?(*names)
end

# Return environment
#
# @return [Lotus::Environment] environment
#
# @api private
# @since x.x.x
def self.environment
Environment.new
end
end
7 changes: 7 additions & 0 deletions lib/lotus/root.rb
@@ -0,0 +1,7 @@
require 'lotus/environment'

module Lotus
def self.root
Lotus::Environment.new.root
end
end
12 changes: 12 additions & 0 deletions test/root_test.rb
@@ -0,0 +1,12 @@
require 'test_helper'
require 'lotus/root'

describe 'Lotus' do
describe '.root' do
let(:pathname) { Lotus.root }
it 'returns root path' do
pwd = Pathname.getwd
pathname.must_equal pwd
end
end
end

0 comments on commit 6f8b9d1

Please sign in to comment.