Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
initial commit
- Loading branch information
0 parents
commit 07632d7
Showing
19 changed files
with
279 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,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
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 @@ | ||
rvm use --create ruby-1.9.3-p125@madvertise-ext |
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 @@ | ||
language: ruby | ||
rvm: | ||
- 1.8.7 | ||
- 1.9.2 | ||
- 1.9.3 |
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 @@ | ||
--no-private |
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 @@ | ||
source :rubygems | ||
|
||
gemspec | ||
|
||
gem 'rake' | ||
gem 'bundler' | ||
|
||
group :test do | ||
gem 'redcarpet' | ||
gem 'reek' | ||
gem 'rspec' | ||
gem 'ruby2ruby', '=1.3.0' # 1.3.1 is broken :( | ||
gem 'simplecov' | ||
gem 'yard' | ||
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,22 @@ | ||
Copyright (c) 2012 madvertise Mobile Advertising GmbH | ||
|
||
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,31 @@ | ||
# Madvertise::Ext | ||
|
||
The madvertise-ext gem provides a bunch of ruby extensions. | ||
|
||
[![Build Status](https://secure.travis-ci.org/madvertise/ext.png)](http://travis-ci.org/madvertise/ext) | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
gem 'madvertise-ext' | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install madvertise-ext | ||
|
||
## Usage | ||
|
||
Please refer to the [API documentation](http://rubydoc.info/gems/madvertise-ext/frames). | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added 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,8 @@ | ||
#!/usr/bin/env rake | ||
|
||
require "bundler/setup" | ||
require "bundler/gem_tasks" | ||
|
||
Dir['tasks/**/*.rake'].each { |t| load t } | ||
|
||
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,3 @@ | ||
require 'madvertise/ext/version' | ||
require 'madvertise/ext/config' | ||
require 'madvertise/ext/environment' |
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,69 @@ | ||
require 'yaml' | ||
|
||
class Section < Hash | ||
def deep_merge(other_hash) | ||
self.merge(other_hash) do |key, oldval, newval| | ||
oldval = oldval.to_hash if oldval.respond_to?(:to_hash) | ||
newval = newval.to_hash if newval.respond_to?(:to_hash) | ||
oldval.is_a?(Hash) && newval.is_a?(Hash) ? oldval.deep_merge(newval) : newval | ||
end | ||
end | ||
|
||
def deep_merge!(other_hash) | ||
replace(deep_merge(other_hash)) | ||
end | ||
|
||
def method_missing(name, *args) | ||
if name.to_s[-1] == ?= | ||
self[name.to_s[0..-2].to_sym] = args.first | ||
else | ||
value = self[name] | ||
value.is_a?(Proc) ? value.call : value | ||
end | ||
end | ||
end | ||
|
||
class Configuration < Section | ||
def initialize(base_config_path, mode = :development, mixin_path = nil, mixins_to_use = []) | ||
config = build_config(YAML.load(File.read(base_config_path))) | ||
|
||
@mode = mode | ||
|
||
self.update(config.generic) | ||
self.deep_merge!(config[mode]) if config.has_key?(mode) | ||
|
||
@mixin_path = mixin_path | ||
@mixins_to_use = mixins_to_use | ||
|
||
load_mixins if @mixin_path and @mixins_to_use.any? | ||
end | ||
|
||
def mixin_files | ||
@mixins_to_use.map do |mixin_name| | ||
File.join(@mixin_path, "#{mixin_name}.yml") | ||
end | ||
end | ||
|
||
def load_mixins | ||
mixin_files.each do |mixin_file| | ||
mixin = build_config(YAML.load(File.read(mixin_file))) | ||
if mixin.has_key?(@mode) | ||
self.deep_merge!(mixin[@mode]) | ||
else | ||
self.deep_merge!(mixin) | ||
end | ||
end | ||
end | ||
|
||
def build_config(hash) | ||
Section.new.tap do |result| | ||
hash.each do |key, value| | ||
result[key.to_sym] = if value.is_a?(Hash) | ||
build_config(value) | ||
else | ||
value | ||
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,33 @@ | ||
class Environment | ||
attr_accessor :key | ||
|
||
def initialize(key) | ||
@key = key | ||
end | ||
|
||
def mode | ||
ENV[@key] || 'development' | ||
end | ||
|
||
def to_sym | ||
mode.to_sym | ||
end | ||
|
||
def prod? | ||
to_sym == :production | ||
end | ||
|
||
def dev? | ||
to_sym == :development | ||
end | ||
|
||
def test? | ||
to_sym == :test | ||
end | ||
|
||
def set(value) | ||
ENV[@key] = value.to_s | ||
end | ||
end | ||
|
||
Env = Environment.new |
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 @@ | ||
--- | ||
NestedIterators: | ||
exclude: | ||
- Configuration#build_config | ||
FeatureEnvy: | ||
exclude: | ||
- Section#deep_merge |
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,6 @@ | ||
module Madvertise | ||
module Ext | ||
# @private | ||
VERSION = "0.1.0" | ||
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,17 @@ | ||
# -*- encoding: utf-8 -*- | ||
require File.expand_path('../lib/madvertise/ext/version', __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.name = "madvertise-ext" | ||
gem.version = Madvertise::Ext::VERSION | ||
gem.authors = ["Benedikt Böhm"] | ||
gem.email = ["benedikt.boehm@madvertise.com"] | ||
gem.description = %q{Ruby extensions} | ||
gem.summary = %q{Ruby extensions} | ||
gem.homepage = "https://github.com/madvertise/ext" | ||
|
||
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
gem.files = `git ls-files`.split("\n") | ||
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
gem.require_paths = ["lib"] | ||
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 @@ | ||
--colour |
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,26 @@ | ||
require 'rubygems' | ||
require 'rspec' | ||
require 'fileutils' | ||
|
||
require 'simplecov' | ||
SimpleCov.start | ||
|
||
ROOT = "#{File.dirname(__FILE__)}/../tmp" | ||
|
||
$:.unshift(File.dirname(__FILE__) + '/../lib') | ||
require 'madvertise-ext' | ||
|
||
RSpec.configure do |config| | ||
# == Mock Framework | ||
# | ||
# RSpec uses it's own mocking framework by default. If you prefer to | ||
# use mocha, flexmock or RR, uncomment the appropriate line: | ||
# | ||
# config.mock_with :mocha | ||
# config.mock_with :flexmock | ||
# config.mock_with :rr | ||
|
||
# setup a fake root | ||
config.before(:all) { File.directory?(ROOT) ? FileUtils.rm_rf("#{ROOT}/*") : FileUtils.mkdir_p(ROOT) } | ||
config.after(:all) { FileUtils.rm_rf("#{ROOT}/*") } | ||
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 @@ | ||
require 'reek/rake/task' | ||
|
||
Reek::Rake::Task.new do |t| | ||
t.fail_on_error = false | ||
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,7 @@ | ||
require 'rspec' | ||
require 'rspec/core/rake_task' | ||
|
||
desc "Run the specs" | ||
RSpec::Core::RakeTask.new do |t| | ||
t.rspec_opts = ['--options', "spec/spec.opts"] | ||
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 @@ | ||
require 'yard' | ||
|
||
YARD::Rake::YardocTask.new do |t| | ||
t.files = ['lib/**/*.rb', 'README.rdoc'] | ||
end |