-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bbedca7
Showing
13 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: ruby | ||
rvm: | ||
- 2.0.0 | ||
- 2.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in locomotivecms_common.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
locomotivecms_common (0.0.1) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
diff-lcs (1.2.5) | ||
rake (10.2.2) | ||
rspec (2.14.1) | ||
rspec-core (~> 2.14.0) | ||
rspec-expectations (~> 2.14.0) | ||
rspec-mocks (~> 2.14.0) | ||
rspec-core (2.14.8) | ||
rspec-expectations (2.14.5) | ||
diff-lcs (>= 1.1.3, < 2.0) | ||
rspec-mocks (2.14.6) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler (~> 1.5) | ||
locomotivecms_common! | ||
rake (~> 10.1) | ||
rspec (~> 2.14) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2014 Joel AZEMAR | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# LocomotivecmsCommon | ||
|
||
[![Gem Version](https://badge.fury.io/rb/common.png)](http://badge.fury.io/rb/locomotivecms_common) | ||
|
||
[![Code Climate](https://codeclimate.com/github/locomotivecms/common.png)](https://codeclimate.com/github/locomotivecms/common) | ||
|
||
[![Dependency Status](https://gemnasium.com/locomotivecms/common.png)](https://gemnasium.com/locomotivecms/common) | ||
|
||
[![Build Status](https://travis-ci.org/locomotivecms/common.png?branch=master)](https://travis-ci.org/locomotivecms/common) (Travis CI) | ||
|
||
[![Coverage Status](https://coveralls.io/repos/locomotivecms/common/badge.png)](https://coveralls.io/r/locomotivecms/common) | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'locomotivecms_common' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install locomotivecms_common | ||
|
||
## Usage | ||
|
||
TODO: Write usage instructions here | ||
|
||
## Contributing | ||
|
||
1. Fork it ( http://github.com/<my-github-username>/locomotivecms_common/fork ) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'bundler/gem_tasks' | ||
require 'rake' | ||
require 'rspec' | ||
require 'rspec/core/rake_task' | ||
|
||
require_relative 'lib/common' | ||
|
||
RSpec::Core::RakeTask.new('spec:all') do |spec| | ||
spec.pattern = 'spec/**/*_spec.rb' | ||
end | ||
|
||
task spec: ['spec:all'] | ||
task default: :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require_relative 'locomotive/common/version' | ||
require_relative 'locomotive/common/exception' | ||
|
||
# module Locomotive | ||
# module Common | ||
# end | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module Locomotive | ||
module Common | ||
|
||
class Notifier | ||
def method_missing method, *args | ||
nil | ||
end | ||
end | ||
|
||
class DefaultException < ::Exception | ||
attr_accessor :notifier | ||
|
||
def initialize(message = nil, parent_exception = nil) | ||
self.notifier = Locomotive::Common::Notifier.new | ||
self.log_backtrace(parent_exception) if parent_exception | ||
super(message) | ||
init_plugins | ||
end | ||
|
||
def init_plugins | ||
@plugins = [] | ||
Locomotive::Common::Plugins.constants.each do |name| | ||
@plugins << ::Plugins.const_get(name).new(self) | ||
end | ||
end | ||
|
||
protected | ||
|
||
def log_backtrace(parent_exception) | ||
full_error_message = "#{parent_exception.message}\n\t" | ||
full_error_message += parent_exception.backtrace.join("\n\t") | ||
full_error_message += "\n\n" | ||
|
||
notifier.fatal full_error_message | ||
end | ||
end | ||
|
||
class RendererException < DefaultException | ||
attr_accessor :name, :template, :liquid_context | ||
|
||
def initialize(exception, name, template, liquid_context) | ||
self.name, self.template, self.liquid_context = name, template, liquid_context | ||
self.log_page_into_backtrace(exception) | ||
super(exception.message) | ||
self.set_backtrace(exception.backtrace) | ||
end | ||
|
||
def log_page_into_backtrace(exception) | ||
line = self.template.line_offset | ||
line += (exception.respond_to?(:line) ? exception.line || 0 : 0) + 1 | ||
message = "#{self.template.filepath}:#{line}:in `#{self.name}'" | ||
notifier.fatal "[ERROR] #{exception.message} - #{message}\n".red | ||
exception.backtrace.unshift message | ||
end | ||
end | ||
|
||
class MounterException < DefaultException() ; end | ||
class GeneratorException < DefaultException() ; end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Locomotive | ||
module Common | ||
module Plugins | ||
|
||
class Notifier | ||
def initialize(exception) | ||
exception.notifier.extend(UiDevNull) | ||
end | ||
|
||
module UiWithBeep | ||
def fatal(*) | ||
nil # Locomotive::Steam::Logger.fatal args.first | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Locomotive | ||
module Common | ||
VERSION = '0.0.1' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require_relative 'lib/common' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'locomotivecms_common' | ||
spec.version = Locomotive::Common::VERSION | ||
spec.authors = ['Didier Lafforgue', 'Arnaud Sellenet', 'Joel Azemar'] | ||
spec.email = ['[email protected]', '[email protected]', '[email protected]'] | ||
spec.description = %q{The LocomotiveCMS Common is a shared libraries package} | ||
spec.summary = %q{The LocomotiveCMS Common is a shared libraries package for all LocomotiveCMS dependencies} | ||
spec.homepage = 'http://www.locomotivecms.com' | ||
spec.homepage = 'https://github.com/locomotivecms/common' | ||
spec.license = 'MIT' | ||
|
||
spec.files = `git ls-files`.split($/) | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_development_dependency 'bundler', '~> 1.5' | ||
spec.add_development_dependency 'rake', '~> 10.1' | ||
spec.add_development_dependency 'rspec', '~> 2.14' | ||
|
||
spec.required_ruby_version = '~> 2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'spec_helper' | ||
|
||
describe Locomotive::Common::DefaultException do | ||
|
||
specify do | ||
expect do | ||
raise DefaultException.new | ||
end.to raise_error(DefaultException) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'rubygems' | ||
require 'bundler/setup' | ||
|
||
require_relative '../lib/common' | ||
|
||
RSpec.configure do |config| | ||
config.filter_run focused: true | ||
config.run_all_when_everything_filtered = true | ||
end |