Permalink
Browse files

Converting plugin to Rails3 (and stripping out all asset packaging code)

  • Loading branch information...
1 parent 5fba89d commit 09af868812b69cd1e63e0e29d7d1a9a08af0e6ec @jacquescrocker jacquescrocker committed Mar 21, 2010
View
@@ -1,2 +1,2 @@
.DS_Store
-*.gem
+pkg/*.gem
View
@@ -1,4 +1,4 @@
-Copyright (c) 2008 Jacques Crocker
+Copyright (c) 2010 Jacques Crocker
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
36 README
@@ -6,18 +6,13 @@ Jacques Crocker
Modified from Original Project (AppConfig by Christopher J. Bottaro)
=== Compatibility
-Rails 2.1/2.2 and Merb 1.0
+Rails 3.0
-=== Installing on Merb
-add this to your config: dependencies.rb and run thor merb:gem:install
+=== Installing on Rails 3
- dependency "merb_app_config"
-
-
-=== Installing on Rails
-
-script/plugin install git://github.com/merbjedi/app_config.git
+add this to your Gemfile
+ gem "rails_app_config"
=== Accessing the AppConfig object
After installing this plugin, the AppConfig object will be global available. Entries are accessed via object member notation:
@@ -31,9 +26,6 @@ Config entries are compiled from
config/app_config/settings.yml
config/app_config/#{environment}.yml
config/environments/#{environment}.yml
- config/app_config/assets.yml
- config/app_config/stylesheets.yml
- config/app_config/javascripts.yml
settings defined in files that are lower in the list override settings higher
@@ -79,23 +71,3 @@ Notice that object member notation is maintained even in nested entries.
Notice array notation and object member notation is maintained.
AppConfig.section.servers[0].name -> yahoo.com
AppConfig.section.servers[1].name -> amazon.com
-
-
-==== Managing Asset Files with AppConfig
-Defining stylesheets: and/or javascripts: keys will allow you to easily manage lists of assets via config
-
-javascripts:
- - application.js
- - prototype_scriptaculous:
- - prototype.js
- - scriptaculous/effects.js
- - base:
- - libraries/*.js
-
-All * file paths will be expanded out into a full list of files.
-
-To add these javascripts to your layout just run
-
-<%= javascripts_from_config %>
-
-This will group the assets by key in order to use the built in Bundling
View
@@ -1,54 +1,17 @@
-require 'rubygems'
-require 'rake/gempackagetask'
-
-require 'merb-core'
-require 'merb-core/tasks/merb'
-
-GEM_NAME = "merb_app_config"
-GEM_VERSION = "1.2"
-AUTHOR = "Jacques Crocker"
-EMAIL = "merbjedi@gmail.com"
-HOMEPAGE = "http://www.merbjedi.com/"
-SUMMARY = "Merb plugin that provides easy to use Application Configurations via YAML"
-
-spec = Gem::Specification.new do |s|
- s.rubyforge_project = 'merb'
- s.name = GEM_NAME
- s.version = GEM_VERSION
- s.platform = Gem::Platform::RUBY
- s.has_rdoc = true
- s.extra_rdoc_files = ["README", "LICENSE"]
- s.summary = SUMMARY
- s.description = s.summary
- s.author = AUTHOR
- s.email = EMAIL
- s.homepage = HOMEPAGE
-
- s.add_dependency('merb-assets', '>= 1.0')
-
- s.require_path = 'lib'
- s.files = %w(LICENSE README Rakefile) + Dir.glob("{lib,spec}/**/*")
-end
-
-Rake::GemPackageTask.new(spec) do |pkg|
- pkg.gem_spec = spec
-end
-
-desc "install the plugin as a gem"
-task :install do
- Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
-end
-
-desc "Uninstall the gem"
-task :uninstall do
- Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
-end
-
-desc "Create a gemspec file"
-task :gemspec do
- File.open("#{GEM_NAME}.gemspec", "w") do |file|
- file.puts spec.to_ruby
+require 'rake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |s|
+ s.name = "rails_app_config"
+ s.summary = "provides an AppConfig for rails3 that reads config/app_config.yml"
+ s.email = "railsjedi@gmail.com"
+ s.homepage = "http://github.com/railsjedi/rails_app_config"
+ s.description = "Provides an easy to use Application Configuration object"
+ s.authors = ["Jacques Crocker"]
+ s.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*"]
end
-end
-
-require 'lib/merbtasks'
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ # puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
+end
View
@@ -0,0 +1 @@
+0.0.1
View
@@ -1 +0,0 @@
-require File.dirname(__FILE__) + "/rails/init"
View
@@ -1,52 +0,0 @@
-require 'application_config/deep_merge' unless defined?(DeepMerge)
-require 'application_config/config_builder'
-require 'application_config/view_helpers'
-
-# make sure we're running inside Merb
-if defined?(Merb::Plugins)
- # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
- Merb::Plugins.config[:app_config] = {
- :auto_reload => Merb.env?(:development),
- :view_helpers => true,
- :paths => [
- "#{Merb.root}/config/app_config.yml",
- "#{Merb.root}/config/app_config/settings.yml",
- "#{Merb.root}/config/app_config/#{Merb.env}.yml",
- "#{Merb.root}/config/environments/#{Merb.env}.yml",
- "#{Merb.root}/config/assets.yml",
- "#{Merb.root}/config/javascripts.yml",
- "#{Merb.root}/config/stylesheets.yml"
- ]
- }
-
- Merb::BootLoader.before_app_loads do
- if defined?(::AppConfig)
- AppConfig.reload!
- else
- ::AppConfig = ApplicationConfig::ConfigBuilder.load_files(
- :paths => Merb::Plugins.config[:app_config][:paths].to_a,
- :expand_keys => [:javascripts, :stylesheets],
- :root_path => Merb.root
- )
- end
-
- if Merb::Plugins.config[:app_config][:view_helpers]
- Merb::Controller.send(:include, ApplicationConfig::ViewHelpers)
- end
-
- if Merb::Plugins.config[:app_config][:auto_reload]
- Merb.logger.info "[AppConfig] Auto reloading AppConfig on every request."
- Merb.logger.info "[AppConfig] Set via Merb::Plugins.config[:app_config][:auto_reload]"
-
- # add before filter
- ::Merb::Controller.before do
- AppConfig.reload!
- end
- end
- end
-
- Merb::BootLoader.after_app_loads do
- end
-
- Merb::Plugins.add_rakefiles "merbtasks"
-end
View
@@ -0,0 +1,5 @@
+require 'application_config/deep_merge' unless defined?(DeepMerge)
+require 'application_config/config_builder'
+require 'application_config/view_helpers'
+
+require 'rails_app_config/railtie'
@@ -0,0 +1,17 @@
+if defined?(Rails::Railtie)
+ module RailsAppConfig
+ class Railtie < Rails::Railtie
+ initializer :setup_app_config do
+ ::AppConfig = ApplicationConfig::ConfigBuilder.load_files(
+ :paths => [
+ Rails.root.join("config", "app_config.yml").to_s,
+ Rails.root.join("config", "app_config", "settings.yml").to_s,
+ Rails.root.join("config", "app_config", "#{Rails.env}.yml").to_s,
+ Rails.root.join("config", "environments", "#{Rails.env}.yml").to_s
+ ],
+ :root_path => Rails.root
+ )
+ end
+ end
+ end
+end
File renamed without changes.
View
@@ -1,18 +0,0 @@
-require 'application_config/config_builder'
-require 'application_config/view_helpers'
-
-::AppConfig = ApplicationConfig::ConfigBuilder.load_files(
- :paths => [
- "#{Rails.root}/config/app_config.yml",
- "#{Rails.root}/config/app_config/settings.yml",
- "#{Rails.root}/config/app_config/#{Rails.env}.yml",
- "#{Rails.root}/config/environments/#{Rails.env}.yml",
- "#{Rails.root}/config/assets.yml",
- "#{Rails.root}/config/javascripts.yml",
- "#{Rails.root}/config/stylesheets.yml"
- ],
- :expand_keys => [:javascripts, :stylesheets],
- :root_path => Rails.root
-)
-
-ActionView::Base.send :include, ApplicationConfig::ViewHelpers
View
@@ -0,0 +1,61 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{rails_app_config}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jacques Crocker"]
+ s.date = %q{2010-03-21}
+ s.description = %q{Provides an easy to use Application Configuration object}
+ s.email = %q{railsjedi@gmail.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README"
+ ]
+ s.files = [
+ "LICENSE",
+ "README",
+ "Rakefile",
+ "VERSION",
+ "lib/application_config/config_builder.rb",
+ "lib/application_config/deep_merge.rb",
+ "lib/application_config/view_helpers.rb",
+ "lib/rails_app_config.rb",
+ "lib/rails_app_config/railtie.rb",
+ "lib/tasks/app_config.rake",
+ "test/config_builder_test.rb",
+ "test/test_configs/app_config.yml",
+ "test/test_configs/bool_override/config1.yml",
+ "test/test_configs/bool_override/config2.yml",
+ "test/test_configs/deep_merge/config1.yml",
+ "test/test_configs/deep_merge/config2.yml",
+ "test/test_configs/deep_merge2/config1.yml",
+ "test/test_configs/deep_merge2/config2.yml",
+ "test/test_configs/development.yml",
+ "test/test_configs/empty1.yml",
+ "test/test_configs/empty2.yml"
+ ]
+ s.homepage = %q{http://github.com/railsjedi/rails_app_config}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.6}
+ s.summary = %q{provides an AppConfig for rails3 that reads config/app_config.yml}
+ s.test_files = [
+ "test/config_builder_test.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
@@ -49,30 +49,6 @@ def test_erb
assert_equal 6, config.computed
end
- def test_javascript_expander
- config = ApplicationConfig::ConfigBuilder.load_files(
- :paths => "#{@settings_path}/javascript_expander.yml",
- :root_path => "#{@settings_path}/javascript_expander",
- :expand_keys => :javascripts
- )
-
- # puts "JAVASCRIPTS:"
- # puts config.inspect
- assert_equal 4, config.javascripts.first.base.size
- end
-
- def test_stylesheet_expander
- config = ApplicationConfig::ConfigBuilder.load_files(
- :paths => "#{@settings_path}/stylesheet_expander.yml",
- :root_path => "#{@settings_path}/stylesheet_expander",
- :expand_keys => :stylesheets
- )
-
- # puts "STYLESHEETS:"
- # puts config.inspect
- assert_equal 5, config.stylesheets.first.base.size
- end
-
def test_merge_hashes_from_multiple_configs
config = ApplicationConfig::ConfigBuilder.load_files(:paths => ["#{@settings_path}/deep_merge/config1.yml", "#{@settings_path}/deep_merge/config2.yml"])
@@ -1,5 +0,0 @@
-javascripts:
- - base:
- # include controls
- - application.js
- - controls/*.js
@@ -1,5 +0,0 @@
-stylesheets:
- - base:
- - local.css
- - global.css
- - lib/*

0 comments on commit 09af868

Please sign in to comment.