diff --git a/CHANGELOG.md b/CHANGELOG.md index 745358c3..8bb7492e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * Nested layouts using `wrap_layout` helper * Support for placekitten.com * Added MM_ROOT environmental variable +* activating extensions can now take an options hash 2.0.14 ==== diff --git a/features/asset_host.feature b/features/asset_host.feature index 3736643b..71117ba3 100644 --- a/features/asset_host.feature +++ b/features/asset_host.feature @@ -2,13 +2,11 @@ Feature: Alternate between multiple asset hosts In order to speed up page loading Scenario: Rendering css with the feature enabled - Given I am using an asset host - And the Server is running at "test-app" + Given the Server is running at "asset-host-app" When I go to "/stylesheets/asset_host.css" Then I should see "http://assets" Scenario: Rendering html with the feature enabled - Given I am using an asset host - And the Server is running at "test-app" + Given the Server is running at "asset-host-app" When I go to "/asset_host.html" Then I should see "http://assets" \ No newline at end of file diff --git a/features/feature_params.feature b/features/feature_params.feature new file mode 100644 index 00000000..14eb0fa6 --- /dev/null +++ b/features/feature_params.feature @@ -0,0 +1,6 @@ +Feature: Be able to pass params to extensions + Scenario: Read some simple variables + Given the Server is running at "feature-params-app" + When I go to "/index.html" + Then I should see "hello: world" + And I should see "hola: mundo" \ No newline at end of file diff --git a/features/step_definitions/asset_host_steps.rb b/features/step_definitions/asset_host_steps.rb deleted file mode 100644 index 4bc752ae..00000000 --- a/features/step_definitions/asset_host_steps.rb +++ /dev/null @@ -1,9 +0,0 @@ -Given /^I am using an asset host$/ do - @initialize_commands ||= [] - @initialize_commands << lambda { - activate :asset_host - set :asset_host do |asset| - "http://assets%d.example.com" % (asset.hash % 4) - end - } -end \ No newline at end of file diff --git a/fixtures/asset-host-app/config.rb b/fixtures/asset-host-app/config.rb new file mode 100644 index 00000000..3338c450 --- /dev/null +++ b/fixtures/asset-host-app/config.rb @@ -0,0 +1,6 @@ +set :layout, false + +activate :asset_host +set :asset_host do |asset| + "http://assets%d.example.com" % (asset.hash % 4) +end \ No newline at end of file diff --git a/fixtures/asset-host-app/source/.htaccess b/fixtures/asset-host-app/source/.htaccess new file mode 100644 index 00000000..875bc5c4 --- /dev/null +++ b/fixtures/asset-host-app/source/.htaccess @@ -0,0 +1 @@ +# I'm an htaccess file! \ No newline at end of file diff --git a/fixtures/asset-host-app/source/asset_host.html.haml b/fixtures/asset-host-app/source/asset_host.html.haml new file mode 100755 index 00000000..7588118c --- /dev/null +++ b/fixtures/asset-host-app/source/asset_host.html.haml @@ -0,0 +1 @@ += image_tag "blank.gif" \ No newline at end of file diff --git a/fixtures/asset-host-app/source/images/blank.gif b/fixtures/asset-host-app/source/images/blank.gif new file mode 100755 index 00000000..2498f1aa Binary files /dev/null and b/fixtures/asset-host-app/source/images/blank.gif differ diff --git a/fixtures/asset-host-app/source/stylesheets/asset_host.css.sass b/fixtures/asset-host-app/source/stylesheets/asset_host.css.sass new file mode 100755 index 00000000..5a67f373 --- /dev/null +++ b/fixtures/asset-host-app/source/stylesheets/asset_host.css.sass @@ -0,0 +1,3 @@ +@import "compass" +h1 + background: image-url("blank.gif") \ No newline at end of file diff --git a/fixtures/feature-params-app/config.rb b/fixtures/feature-params-app/config.rb new file mode 100644 index 00000000..26eeec55 --- /dev/null +++ b/fixtures/feature-params-app/config.rb @@ -0,0 +1,12 @@ +set :layout, false + +module ExtensionA + class << self + def registered(app, options={}) + app.set :a_options, options + end + alias :included :registered + end +end + +activate ExtensionA, :hello => "world", :hola => "mundo" \ No newline at end of file diff --git a/fixtures/feature-params-app/source/index.html.erb b/fixtures/feature-params-app/source/index.html.erb new file mode 100644 index 00000000..0435545e --- /dev/null +++ b/fixtures/feature-params-app/source/index.html.erb @@ -0,0 +1,3 @@ +<% a_options.each do |k, v| %> + <%= k %>: <%= v%> +<% end %> \ No newline at end of file diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index c50e7aac..b062d88d 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -54,6 +54,15 @@ class Middleman::Base end end + # Set the shared instance + # + # @private + # @param [Middleman::Base] inst + # @return [void] + def inst=(inst) + @inst = inst + end + # Return built Rack app # # @private @@ -128,9 +137,11 @@ class Middleman::Base # @param [Symbol] Unique key name # @param Default value # @return [void] - def set(key, value) + def set(key, value=nil, &block) @defaults ||= {} @defaults[key] = value + + @inst.set(key, value, &block) if @inst end end diff --git a/lib/middleman/core_extensions/extensions.rb b/lib/middleman/core_extensions/extensions.rb index 204a7eab..d7543b19 100644 --- a/lib/middleman/core_extensions/extensions.rb +++ b/lib/middleman/core_extensions/extensions.rb @@ -71,12 +71,17 @@ module Middleman::CoreExtensions::Extensions # # @param [Array] new_extensions Extension modules to register # @return [Array