sinatra-environments 0.0.1 → 0.0.2

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/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
- rel 0.1.0 (2013-07-11)
1
+ rel 0.0.2 (2013-07-11)
2
+
3
+ * Fix accidental loading of all files in config/environments
4
+ * Fix config directory attribute to avoid collision with Sinatra::Initializers
5
+
6
+ rel 0.0.1 (2013-07-11)
2
7
 
3
8
  * intial release of gem / code
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/README.rdoc CHANGED
@@ -1,6 +1,7 @@
1
1
  = Sinatra::Environments
2
2
 
3
- A Sinatra Extension that sets up rails like environments
3
+ A Sinatra Extension that sets up rails like environments base on Chad W Pry's
4
+ work on https://github.com/chadwpry/sinatra-initializers
4
5
 
5
6
  == Installation
6
7
 
@@ -25,7 +26,7 @@ This Gem depends upon the following:
25
26
  To view the settings in your app, just require and register the extension
26
27
  in your sub-classed Sinatra app:
27
28
 
28
- require 'sinatra-environments'
29
+ require "sinatra-environments"
29
30
 
30
31
  class YourApp < Sinatra::Base
31
32
 
@@ -36,9 +37,9 @@ in your sub-classed Sinatra app:
36
37
 
37
38
  In your "classic" Sinatra app, you just require the extension like this:
38
39
 
39
- require 'rubygems'
40
- require 'sinatra'
41
- require 'sinatra-environments'
40
+ require "rubygems"
41
+ require "sinatra"
42
+ require "sinatra-environments"
42
43
 
43
44
 
44
45
  == Configuration Options
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core'
5
- require 'rspec/core/rake_task'
4
+ require "rspec/core"
5
+ require "rspec/core/rake_task"
6
6
  RSpec::Core::RakeTask.new(:spec) do |spec|
7
- spec.pattern = FileList['spec/**/*_spec.rb']
8
- spec.rspec_opts = ['--backtrace']
9
- # spec.ruby_opts = ['-w']
7
+ spec.pattern = FileList["spec/**/*_spec.rb"]
8
+ spec.rspec_opts = ["--backtrace"]
9
+ spec.ruby_opts = ["-w"]
10
10
  end
11
11
 
12
12
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,6 +1,6 @@
1
1
  module Sinatra
2
2
  module Environments
3
- VERSION = '0.0.1' unless const_defined?(:VERSION)
3
+ VERSION = "0.0.2" unless const_defined?(:VERSION)
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -1,28 +1,31 @@
1
- require 'sinatra/base'
2
- require 'sinatra-environments/version'
1
+ require "sinatra/base"
2
+ require "sinatra-environments/version"
3
3
 
4
4
  module Sinatra
5
5
  class Base
6
- set(:config_directory, "config/environments")
6
+ set(:environments_config_directory, "config/environments")
7
7
  end
8
8
 
9
9
  module Environments
10
- def config_directory= path
10
+ def environments_config_directory=(path)
11
11
  super
12
12
  register Sinatra::Environments
13
13
  end
14
14
 
15
- def self.registered app
16
- environment_file = File.join(app.config_directory, "../environment.rb")
15
+ def self.registered(app)
16
+ environment = app.settings.environment.to_s
17
+ config_dir = app.environments_config_directory
18
+ parent_dir = File.expand_path(File.join(config_dir, "../"))
19
+ environment_file = File.join(parent_dir, "environment.rb")
20
+ specific_file = File.expand_path(File.join(config_dir, "#{environment}.rb"))
17
21
 
18
22
  if File.exists?(environment_file)
19
- require File.join(Dir.pwd, environment_file)
23
+ require environment_file
20
24
  end
21
25
 
22
- Dir["#{app.config_directory}/**/*.rb"].each do |file_path|
23
- require File.join(Dir.pwd, file_path)
26
+ if File.exists?(specific_file)
27
+ require specific_file
24
28
  end
25
29
  end
26
30
  end
27
31
  end
28
-
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra-environments}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christopher H. Laco", "Chad W Pry"]
@@ -36,8 +36,8 @@ Gem::Specification.new do |s|
36
36
  s.rubygems_version = %q{1.3.7}
37
37
  s.summary = %q{A Sinatra Extension that follows a pattern of rails environments}
38
38
 
39
- s.add_development_dependency('sinatra')
40
- s.add_development_dependency('rake')
41
- s.add_development_dependency('rspec')
39
+ s.add_development_dependency("sinatra")
40
+ s.add_development_dependency("rake")
41
+ s.add_development_dependency("rspec")
42
42
  end
43
43
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe Sinatra::Environments do
4
4
  class TestSinatraApplication < Sinatra::Base
@@ -7,20 +7,20 @@ describe Sinatra::Environments do
7
7
 
8
8
  describe "using base settings" do
9
9
  it "defaults the setting config_directory to config/environments" do
10
- Sinatra::Base.config_directory.should == "config/environments"
10
+ Sinatra::Base.environments_config_directory.should == "config/environments"
11
11
  end
12
12
  end
13
13
 
14
14
  describe "using an example environment" do
15
15
  it "allows you to override config_directory" do
16
- TestSinatraApplication.config_directory = "spec/config/environments"
17
- TestSinatraApplication.config_directory.should == "spec/config/environments"
16
+ TestSinatraApplication.environments_config_directory = "spec/config/environments"
17
+ TestSinatraApplication.environments_config_directory.should == "spec/config/environments"
18
18
  end
19
19
 
20
20
  it "registers an environment for the test sinatra application" do
21
- TestSinatraApplication.config_directory = "spec/config/environments"
22
- Test::THAT_ENVIRONMENT_EXISTS.should == true
23
- Test::THAT_TEST_ENVIRONMENT_EXISTS.should == true
21
+ TestSinatraApplication.environments_config_directory = "spec/config/environments"
22
+ Test::THAT_ENVIRONMENT_EXISTS.should be_true
23
+ Test::THAT_TEST_ENVIRONMENT_EXISTS.should be_true
24
24
  end
25
25
  end
26
26
  end
@@ -1,8 +1,8 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe Sinatra::Environments do
4
- it 'is the latest version' do
5
- Sinatra::Environments.version.should == '0.0.1'
4
+ it "is the latest version" do
5
+ Sinatra::Environments.version.should == "0.0.2"
6
6
  end
7
7
  end
8
8
 
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
2
 
3
- require 'rspec'
4
- require 'sinatra-environments'
3
+ require "rspec"
4
+ require "sinatra-environments"
5
5
 
6
6
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-environments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -80,7 +80,7 @@ files:
80
80
  - Gemfile
81
81
  - Rakefile
82
82
  - spec/config/environment.rb
83
- - spec/config/environments/test.rb
83
+ - spec/config/environments/development.rb
84
84
  - spec/sinatra-environments/sinatra-environments_spec.rb
85
85
  - spec/sinatra-environments/version_spec.rb
86
86
  - spec/spec_helper.rb
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: -4023376974684312126
102
+ hash: 4573804394064464119
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  none: false
105
105
  requirements:
@@ -114,7 +114,7 @@ specification_version: 3
114
114
  summary: A Sinatra Extension that follows a pattern of rails environments
115
115
  test_files:
116
116
  - spec/config/environment.rb
117
- - spec/config/environments/test.rb
117
+ - spec/config/environments/development.rb
118
118
  - spec/sinatra-environments/sinatra-environments_spec.rb
119
119
  - spec/sinatra-environments/version_spec.rb
120
120
  - spec/spec_helper.rb