middleman-settings 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # If you have OpenSSL installed, we recommend updating
2
+ # the following line to use "https"
3
+ source 'http://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in settings.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'rake'
10
+ gem 'rdoc'
11
+ gem 'yard'
12
+ end
13
+
14
+ group :test do
15
+ gem 'cucumber'
16
+ gem 'fivemat'
17
+ gem 'aruba'
18
+ gem 'rspec'
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Gregory Horion
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Middleman-Settings
2
+ `middleman-settings` is an extension for the [Middleman](https://github.com/middleman/middleman) static site generator that allows you manage your config variables from a config file
3
+
4
+ ## Installation
5
+
6
+ If you're just getting started, install the `middleman` gem and generate a new project:
7
+
8
+ ```bash
9
+ gem install middleman
10
+ middleman init MY_PROJECT
11
+ ```
12
+
13
+ If you already have a Middleman project: Add `gem "middleman-settings"` to your `Gemfile` and run `bundle install`.
14
+
15
+
16
+ ## Configuration
17
+
18
+ ```ruby
19
+ activate :settings #this will load the config files from the config folder from your root app
20
+ ```
21
+
22
+ exemple of config file:
23
+
24
+
25
+ build:
26
+ api_key: <% ENV['FOO_API_KEY'] %>
27
+ development:
28
+ api_key: "foobar"
29
+
30
+ You can also change the defaule directory:
31
+
32
+ ```ruby
33
+ activate :settings, :config_folder => 'my_super_config_folder'
34
+ ```
35
+
36
+ ## Helper
37
+
38
+ The extension adds a new `code` helper to Middleman that you can use from your templates:
39
+
40
+ ```erb
41
+ <% middleman_settings['facebook']['client_token'] %>
42
+ ```
43
+
44
+ You can also use it directly from config.rb
45
+
46
+ ```ruby
47
+ middleman_settings['new_relic']['api_key']
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( http://github.com/gregory/rpx/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task :test => ['cucumber']
13
+
14
+ task :default => :test
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'settings')
@@ -0,0 +1,13 @@
1
+ # Require core library
2
+ require 'middleman-core'
3
+ require 'middleman-settings/version'
4
+
5
+ # Register extensions which can be activated
6
+ # Make sure we have the version of Middleman we expect
7
+ # Name param may be omited, it will default to underscored
8
+ # version of class name
9
+
10
+ ::Middleman::Extensions.register(:settings) do
11
+ require 'middleman-settings/extension'
12
+ ::Middleman::Settings::SettingsExtension
13
+ end
@@ -0,0 +1,38 @@
1
+
2
+ module Middleman
3
+ module Settings
4
+ class SettingsExtension < Extension
5
+ option :config_folder, 'config', 'The config folder relative path'
6
+
7
+ def initialize(app, options_hash={}, &block)
8
+ super
9
+ @app = app
10
+ app.set :config_folder, options.config_folder
11
+ settings_h = Hash.new do |h, key|
12
+ h[key] = raw_settings(key.to_s)[app.environment.to_s]
13
+ end
14
+ app.set :middleman_settings, settings_h
15
+ end
16
+
17
+ private
18
+
19
+ def raw_settings(file_name)
20
+ path = file_path(file_name)
21
+ if File.file?(path)
22
+ YAML::load(ERB.new(File.read(file_path(file_name))).result)
23
+ else
24
+ logger.error "[middleman_settings] Error> #{path} does not exist"
25
+ {}
26
+ end
27
+ end
28
+
29
+ def file_path(file_name)
30
+ File.join(@app.root, @app.config_folder, "#{file_name}.yml")
31
+ end
32
+
33
+ def logger
34
+ @logger ||= Middleman::Logger.singleton
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1 @@
1
+ require 'middleman-settings'
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Settings
3
+ VERSION='0.0.1'
4
+ end
5
+ end
data/settings.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman-settings"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Gregory Horion"]
9
+ s.email = ["greg2502@gmail.com"]
10
+ s.homepage = "http://gregory.io"
11
+ s.summary = %q{Config files management for middleman http://middlemanapp.com}
12
+ s.description = %q{This Gem will let you use settings from config files everywhere}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # The version of middleman-core your extension depends on
20
+ s.add_runtime_dependency("middleman-core", [">= 3.2.2"])
21
+
22
+ # Additional dependencies
23
+ # s.add_runtime_dependency("gem-name", "gem-version")
24
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-settings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gregory Horion
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: middleman-core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.2
30
+ description: This Gem will let you use settings from config files everywhere
31
+ email:
32
+ - greg2502@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - features/support/env.rb
43
+ - lib/middleman-settings.rb
44
+ - lib/middleman-settings/extension.rb
45
+ - lib/middleman-settings/middleman-extension.rb
46
+ - lib/middleman-settings/version.rb
47
+ - settings.gemspec
48
+ homepage: http://gregory.io
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.23
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Config files management for middleman http://middlemanapp.com
72
+ test_files:
73
+ - features/support/env.rb
74
+ has_rdoc: