spine-engines 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a68c6a541f4822ad502bd3671f04f87c714cfaed
4
+ data.tar.gz: d73cb5be9a66de046b4d8c9b8f9b0a76df99062e
5
+ SHA512:
6
+ metadata.gz: 0969f3e6d31390ce4d2773a829f0ec0d37d5514bf1ed09459720295fc0285188dd4e96c52474b57a33bdd97ae6403375801ddffc49e14a0325a23595f05b12ca
7
+ data.tar.gz: 808d637219226d75925478f1b14200674372d4fea30a3867fef7b5a77ec327001bd2a7f295e58f3b3ef1a7083ed076ab897bc179d4b900849c0e00875d941ee7
data/.gitignore ADDED
@@ -0,0 +1,36 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /bin/
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require config/default
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ Changelog
2
+ =========
3
+
4
+ 0.1.0
5
+ -----
6
+ - First public release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in spine-engines.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2015, TOGGL LLC
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ 3. Neither the name of the TOGGL LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # Spine::Engines
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/spine-engines.svg)](http://badge.fury.io/rb/spine-engines)
4
+ [![Dependency Status](https://gemnasium.com/rspine/engines.svg)](https://gemnasium.com/rspine/engines)
5
+ [![Code Climate](https://codeclimate.com/github/rspine/engines/badges/gpa.svg)](https://codeclimate.com/github/rspine/engines)
6
+
7
+ Starting point for your Rack application and its configurations.
8
+
9
+ ## Installation
10
+
11
+ To install it, add the gem to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'spine-engines'
15
+ ```
16
+
17
+ Then run `bundle`. If you're not using Bundler, just `gem install spine-engines`.
18
+
19
+ ## Usage
20
+
21
+ Define your application and configuration:
22
+
23
+ ```ruby
24
+ # lib/my_app/application.rb
25
+
26
+ module MyApp
27
+ module Application
28
+ extend Spine::Engines::Application
29
+ extend self
30
+
31
+ # Add loaders
32
+ loaders << Spine::Engines::Loaders::Initializers
33
+
34
+ # Add extensions
35
+ extension Spine::Routing::Engine
36
+
37
+ # Add your own extra configuration
38
+ def active_record
39
+ ::ActiveRecord::Base
40
+ end
41
+ end
42
+ end
43
+ ```
44
+
45
+ Define your shared configuration between environments. You can define
46
+ environment specific configurations in `config/environments/evironment_name.rb`.
47
+
48
+ ```ruby
49
+ # config/environment.rb
50
+
51
+ require File.expand_path('../boot', __FILE__)
52
+
53
+ environment = ENV['RACK_ENV'] || 'development'
54
+ Bundler.require(:default, environment)
55
+
56
+ require File.expand_path('../../lib/my_app/application', __FILE__)
57
+
58
+ MyApp::Application.configure do |config|
59
+ config.environment = environment
60
+ config.root = File.expand_path('../..', __FILE__)
61
+
62
+ config.load_paths = %w(
63
+ lib/my_app/**/*.rb
64
+ )
65
+
66
+ # Middlewares
67
+ config.middleware.use Rack::Lock
68
+ config.middleware.use Rack::Runtime
69
+ config.middleware.use Rack::MethodOverride
70
+ config.middleware.use Rack::CommonLogger, config.logger
71
+ config.middleware.use Rack::Head
72
+ config.middleware.use Rack::ConditionalGet
73
+ config.middleware.use Rack::ETag
74
+ end
75
+
76
+ MyApp::Application.initialize!
77
+ ```
78
+
79
+ Add Bundler to boot:
80
+
81
+ ```ruby
82
+ # config/boot.rb
83
+
84
+ require 'rubygems'
85
+
86
+ # Set up gems listed in the Gemfile.
87
+ gemfile = File.expand_path('../../Gemfile', __FILE__)
88
+ begin
89
+ ENV['BUNDLE_GEMFILE'] = gemfile
90
+ require 'bundler'
91
+ Bundler.setup
92
+ rescue Bundler::GemNotFound => e
93
+ STDERR.puts e.message
94
+ STDERR.puts "Try running `bundle install`."
95
+ exit!
96
+ end if File.exist?(gemfile)
97
+ ```
98
+
99
+ Configuring Rack to use this application:
100
+
101
+ ```ruby
102
+ # config.ru
103
+
104
+ require ::File.expand_path('../config/environment', __FILE__)
105
+ run MyApp::Application
106
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ module Spine
2
+ module Engines
3
+ module Application
4
+ include Configuration
5
+ include Loaders
6
+ include Extensions
7
+
8
+ def initialize!
9
+ load
10
+ finalize!
11
+ end
12
+
13
+ def call(env)
14
+ finalize!.call(env)
15
+ end
16
+
17
+ private
18
+
19
+ def finalize!
20
+ @finalized_app ||= builder.to_app
21
+ end
22
+
23
+ def load
24
+ loaders.each { |loader| loader.call(self) }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ require 'pathname'
2
+ require 'logger'
3
+
4
+ module Spine
5
+ module Engines
6
+ module Configuration
7
+ attr_accessor :environment, :root, :load_paths
8
+ attr_accessor :builder, :middleware
9
+ attr_accessor :logger, :router
10
+
11
+ def builder
12
+ @builder ||= Rack::Builder.new
13
+ end
14
+
15
+ def middleware
16
+ @middleware || builder
17
+ end
18
+
19
+ def root=(value)
20
+ @root = Pathname.new(value)
21
+ end
22
+
23
+ def logger
24
+ @logger ||= Logger.new(STDOUT)
25
+ end
26
+
27
+ def configure
28
+ yield(self) if block_given?
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module Spine
2
+ module Engines
3
+ module Extensions
4
+ def extension(plugin)
5
+ if plugin.respond_to?(:configuration) && plugin.configuration
6
+ self.extend(plugin.configuration)
7
+ end
8
+
9
+ if plugin.respond_to?(:loader) && plugin.loader
10
+ self.loaders << plugin.loader
11
+ end
12
+
13
+ self
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Spine
2
+ module Engines
3
+ module Loaders
4
+ module Default
5
+ def loaders
6
+ @loaders ||= default_loaders
7
+ end
8
+
9
+ def loaders=(value)
10
+ @loaders = value
11
+ end
12
+
13
+ def default_loaders
14
+ [LoadPaths, EnvironmentConfiguration]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module Spine
2
+ module Engines
3
+ module Loaders
4
+ module EnvironmentConfiguration
5
+ extend self
6
+
7
+ def call(app)
8
+ require app.root.join('config', 'environments', app.environment).to_s
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Spine
2
+ module Engines
3
+ module Loaders
4
+ module Initializers
5
+ extend self
6
+
7
+ def call(app)
8
+ source = app.root.join('config', 'initializers', '*.rb')
9
+ Dir[source].each { |file| require file }
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Spine
2
+ module Engines
3
+ module Loaders
4
+ module LoadPaths
5
+ extend self
6
+
7
+ def call(app)
8
+ app.load_paths.each do |path|
9
+ Dir[app.root.join(path)].each { |file| require file }
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Spine
2
+ module Engines
3
+ module Loaders
4
+ autoload :Default, 'spine/engines/loaders/default'
5
+ autoload :EnvironmentConfiguration, 'spine/engines/loaders/environment_configuration'
6
+ autoload :Initializers, 'spine/engines/loaders/initializers'
7
+ autoload :LoadPaths, 'spine/engines/loaders/load_paths'
8
+
9
+ include Default
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Spine
2
+ module Engines
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Spine
2
+ module Engines
3
+ autoload :Application, 'spine/engines/application'
4
+ autoload :Configuration, 'spine/engines/configuration'
5
+ autoload :Loaders, 'spine/engines/loaders'
6
+ autoload :Extensions, 'spine/engines/extensions'
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'spine/engines/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "spine-engines"
7
+ spec.version = Spine::Engines::VERSION
8
+ spec.authors = ["TOGGL LLC"]
9
+ spec.email = ["support@toggl.com"]
10
+ spec.summary = ''
11
+ spec.description = ''
12
+ spec.homepage = 'https://github.com/rspine/engines'
13
+ spec.license = 'BSD-3-Clause'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'rack', '~> 1.6'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spine-engines
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TOGGL LLC
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: ''
56
+ email:
57
+ - support@toggl.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - CHANGELOG.md
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - lib/spine/engines.rb
70
+ - lib/spine/engines/application.rb
71
+ - lib/spine/engines/configuration.rb
72
+ - lib/spine/engines/extensions.rb
73
+ - lib/spine/engines/loaders.rb
74
+ - lib/spine/engines/loaders/default.rb
75
+ - lib/spine/engines/loaders/environment_configuration.rb
76
+ - lib/spine/engines/loaders/initializers.rb
77
+ - lib/spine/engines/loaders/load_paths.rb
78
+ - lib/spine/engines/version.rb
79
+ - spine-engines.gemspec
80
+ homepage: https://github.com/rspine/engines
81
+ licenses:
82
+ - BSD-3-Clause
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.5
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: ''
104
+ test_files: []