move code to the common gem
did
committed Mar 31, 2015
commit b2de77ec12119a7adb923976d7784c68ffb2d1e6
Showing 12
changed files with
7 additions
and 164 deletions
Gemfile
+1
-1
| @@ | @@ -3,7 +3,7 @@ source 'https://rubygems.org' |
| gemspec | |
| group :development do | |
| - | # gem 'locomotivecms_common', '~> 0.0.2', path: '../common' |
| + | # gem 'locomotivecms_common', '~> 0.0.3', path: '../common' |
| # gem 'locomotivecms_models', '~> 0.0.1', path: '../models' | |
| # gem 'locomotivecms_models', '0.0.1.pre.alpha' | |
| # gem 'locomotivecms-liquid', path: '/Users/didier/Documents/LocomotiveCMS/gems/liquid' | |
Gemfile.lock
+5
-5
| @@ | @@ -3,7 +3,6 @@ PATH |
| specs: | |
| locomotivecms_steam (1.0.0.pre.alpha) | |
| RedCloth (~> 4.2.9) | |
| - | activesupport (~> 4.2.1) |
| chronic (~> 0.10.2) | |
| coffee-script (~> 2.3.0) | |
| compass (~> 1.0.3) | |
| @@ | @@ -12,7 +11,7 @@ PATH |
| httparty (~> 0.13.3) | |
| kramdown (~> 1.6.0) | |
| locomotivecms-solid (~> 4.0.0.alpha2) | |
| - | locomotivecms_common (~> 0.0.2) |
| + | locomotivecms_common (~> 0.0.3) |
| mime-types (~> 2.4.3) | |
| mimetype-fu (~> 0.1.2) | |
| moneta (~> 0.8.0) | |
| @@ | @@ -23,7 +22,6 @@ PATH |
| sanitize (~> 3.1.2) | |
| sprockets (~> 2.12.3) | |
| sprockets-sass (~> 1.3.1) | |
| - | stringex (~> 2.5.2) |
| GEM | |
| remote: https://rubygems.org/ | |
| @@ | @@ -35,7 +33,7 @@ GEM |
| minitest (~> 5.1) | |
| thread_safe (~> 0.3, >= 0.3.4) | |
| tzinfo (~> 1.1) | |
| - | addressable (2.3.7) |
| + | addressable (2.3.8) |
| bson (2.3.0) | |
| byebug (4.0.3) | |
| columnize (= 0.9.0) | |
| @@ | @@ -99,8 +97,10 @@ GEM |
| locomotivecms-liquid (4.0.0.alpha2) | |
| locomotivecms-solid (4.0.0.alpha2) | |
| locomotivecms-liquid (~> 4.0.0.alpha2) | |
| - | locomotivecms_common (0.0.2) |
| + | locomotivecms_common (0.0.3) |
| + | activesupport (~> 4.2.1) |
| colorize | |
| + | stringex (~> 2.5.2) |
| method_source (0.8.2) | |
| mime-types (2.4.3) | |
| mimetype-fu (0.1.2) | |
locomotive/steam.rb b/lib/locomotive/steam.rb
+0
-6
| @@ | @@ -1,11 +1,5 @@ |
| require 'locomotive/common' | |
| - | require 'active_support' |
| - | require 'active_support/concern' |
| - | require 'active_support/deprecation' |
| - | require 'active_support/core_ext' |
| - | |
| - | require_relative 'steam/core_ext' |
| require_relative 'steam/configuration' | |
| require_relative_all 'steam/decorators' | |
| require_relative 'steam/liquid' | |
locomotive/steam/core_ext.rb b/lib/locomotive/steam/core_ext.rb
+0
-6
| @@ | @@ -1,6 +0,0 @@ |
| - | require_relative 'core_ext/hash' |
| - | require_relative 'core_ext/string' |
| - | require_relative 'core_ext/array' |
| - | require_relative 'core_ext/boolean/true' |
| - | require_relative 'core_ext/boolean/false' |
| - | require_relative 'core_ext/kernel' |
locomotive/steam/core_ext/array.rb b/lib/locomotive/steam/core_ext/array.rb
+0
-3
| @@ | @@ -1,3 +0,0 @@ |
| - | class Array |
| - | def contains?(other) (self & other) == other ; end |
| - | end |
locomotive/steam/core_ext/boolean/false.rb b/lib/locomotive/steam/core_ext/boolean/false.rb
+0
-3
| @@ | @@ -1,3 +0,0 @@ |
| - | class FalseClass |
| - | def to_bool() self ; end |
| - | end |
locomotive/steam/core_ext/boolean/true.rb b/lib/locomotive/steam/core_ext/boolean/true.rb
+0
-3
| @@ | @@ -1,3 +0,0 @@ |
| - | class TrueClass |
| - | def to_bool() self ; end |
| - | end |
locomotive/steam/core_ext/hash.rb b/lib/locomotive/steam/core_ext/hash.rb
+0
-39
| @@ | @@ -1,39 +0,0 @@ |
| - | # Big thanks to Tim Ruffles (https://github.com/timruffles) |
| - | # https://gist.github.com/timruffles/2780508 |
| - | module HashConverter |
| - | class << self |
| - | |
| - | def to_underscore(hash) |
| - | convert(hash, :underscore) |
| - | end |
| - | |
| - | def to_string(hash) |
| - | convert(hash, :to_s) |
| - | end |
| - | |
| - | def to_sym(hash) |
| - | convert(hash, :to_sym) |
| - | end |
| - | |
| - | # FIXME: not sure it will be ever needed |
| - | # def to_camel_case hash |
| - | # convert hash, :camelize, :lower |
| - | # end |
| - | |
| - | def convert(obj, *method) |
| - | case obj |
| - | when Hash |
| - | obj.inject({}) do |h, (k,v)| |
| - | v = convert(v, *method) |
| - | h[k.send(*method)] = v |
| - | h |
| - | end |
| - | when Array |
| - | obj.map { |m| convert(m, *method) } |
| - | else |
| - | obj |
| - | end |
| - | end |
| - | |
| - | end |
| - | end |
locomotive/steam/core_ext/kernel.rb b/lib/locomotive/steam/core_ext/kernel.rb
+0
-14
| @@ | @@ -1,14 +0,0 @@ |
| - | module Kernel |
| - | |
| - | def require_relative_all(paths, sub = nil) |
| - | main_path = File.dirname(caller.first.sub(/:\d+$/, '')) |
| - | main_path = File.join(main_path, sub) if sub |
| - | |
| - | [*paths].each do |path| |
| - | Dir[File.join(main_path, path, '*.rb')].each { |file| require file } |
| - | end |
| - | end |
| - | |
| - | end |
| - | |
| - | |
locomotive/steam/core_ext/string.rb b/lib/locomotive/steam/core_ext/string.rb
+0
-37
| @@ | @@ -1,37 +0,0 @@ |
| - | unless String.public_instance_methods.include?(:to_bool) |
| - | class String |
| - | |
| - | def to_bool |
| - | return true if self == true || self =~ (/(true|t|yes|y|1)$/i) |
| - | return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i) |
| - | |
| - | raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") |
| - | end |
| - | |
| - | end |
| - | end |
| - | |
| - | unless String.public_instance_methods.include?(:permalink) |
| - | require 'stringex' |
| - | |
| - | class String |
| - | |
| - | def permalink(underscore = false) |
| - | # if the slug includes one "_" at least, we consider that the "_" is used instead of "-". |
| - | _permalink = if !self.index('_').nil? |
| - | self.to_url(replace_whitespace_with: '_') |
| - | else |
| - | self.to_url |
| - | end |
| - | |
| - | underscore ? _permalink.underscore : _permalink |
| - | end |
| - | |
| - | def permalink!(underscore = false) |
| - | replace(self.permalink(underscore)) |
| - | end |
| - | |
| - | alias :parameterize! :permalink! |
| - | |
| - | end |
| - | end |
locomotivecms_steam.gemspec
+1
-3
| @@ | @@ -22,8 +22,6 @@ Gem::Specification.new do |spec| |
| spec.add_development_dependency 'moped', '~> 2.0.4' | |
| spec.add_development_dependency 'origin', '~> 2.1.1' | |
| - | spec.add_dependency 'activesupport', '~> 4.2.1' |
| - | spec.add_dependency 'stringex', '~> 2.5.2' |
| spec.add_dependency 'sanitize', '~> 3.1.2' | |
| spec.add_dependency 'morphine', '~> 0.1.1' | |
| spec.add_dependency 'httparty', '~> 0.13.3' | |
| @@ | @@ -47,7 +45,7 @@ Gem::Specification.new do |spec| |
| spec.add_dependency 'mime-types', '~> 2.4.3' | |
| spec.add_dependency 'locomotivecms-solid', '~> 4.0.0.alpha2' | |
| - | spec.add_dependency 'locomotivecms_common', '~> 0.0.2' |
| + | spec.add_dependency 'locomotivecms_common', '~> 0.0.3' |
| spec.required_ruby_version = '>= 2.0' | |
| end | |
spec/unit/core_ext/string_spec.rb
+0
-44
| @@ | @@ -1,44 +0,0 @@ |
| - | require 'spec_helper' |
| - | |
| - | describe String do |
| - | |
| - | describe '#permalink!' do |
| - | |
| - | let(:string) { 'foo bar' } |
| - | |
| - | before { string.permalink! } |
| - | |
| - | it { expect(string).to eq 'foo-bar' } |
| - | |
| - | end |
| - | |
| - | describe '#to_bool' do |
| - | |
| - | subject { string.to_bool } |
| - | |
| - | describe 'true values' do |
| - | |
| - | %w(true t yes y 1).each do |val| |
| - | let(:string) { val } |
| - | it { is_expected.to eq true } |
| - | end |
| - | |
| - | end |
| - | |
| - | describe 'false values' do |
| - | |
| - | (%w(false f no n 0) + ['']).each do |val| |
| - | let(:string) { val } |
| - | it { is_expected.to eq false } |
| - | end |
| - | |
| - | end |
| - | |
| - | describe 'no truthy or falsy' do |
| - | let(:string) { 'foo' } |
| - | it { expect { subject }.to raise_error(%(invalid value for Boolean: "foo")) } |
| - | end |
| - | |
| - | end |
| - | |
| - | end |