locomotivecms_common 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b653c8442e005fcdf0e7e49dd0ebf03d93b62af5
4
- data.tar.gz: 94b56771d8759cbbc9eda08476f8823d55a6689d
3
+ metadata.gz: c38419a91faf5987f3d4c79962c46e0ead0de7b6
4
+ data.tar.gz: 7e94cb9cc7289a2dab52dcabbbb7eb4eb22c0512
5
5
  SHA512:
6
- metadata.gz: 16d8e74ceb2fa4d930d992e50afe7db1bf3680b51c8176e4440966a38f3a3f595698ca70c0b2a6e9061ee99243d5c86fa2eddec22c2b5ab456fb9bf9ba6df220
7
- data.tar.gz: f38624d72d1bef8fab06a4a0ad82968004d1e31bd87044c8cc36842acbc127603c128845c61f2760dd8ee87cbb7f62f90941fe4c338c55115d2523436798846a
6
+ metadata.gz: 008e1108130856740226ff72c8715b0c4acb36b459dbec096e062895aae0c480f3d5e8b1079899cf0c5b4d8ea1f2cd41117ec172155f912e93bbcd30aa045c6d
7
+ data.tar.gz: 7e41e88b8844bda2512e1f6044bd6113f338a9dd54bc461a37af41e68d13f289076e26f50db628eac1a8122afa10ac4a24a4f9c35e02702c9eb1013b7a17796f
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  .bundle
2
2
  .ruby-*
3
3
 
4
+ coverage/
5
+
4
6
  *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --backtrace
data/.travis.yml CHANGED
@@ -2,4 +2,3 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1.1
5
- - jruby-19mode
data/Gemfile CHANGED
@@ -2,3 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in locomotivecms_common.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'rspec', '~> 3.2.0'
8
+
9
+ gem 'codeclimate-test-reporter', '~> 0.4.7', require: false
10
+ gem 'coveralls', '~> 0.7.12', require: false
11
+ end
data/Gemfile.lock CHANGED
@@ -1,29 +1,83 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_common (0.0.2)
4
+ locomotivecms_common (0.0.3)
5
+ activesupport (~> 4.2.1)
5
6
  colorize
7
+ stringex (~> 2.5.2)
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
9
11
  specs:
10
- colorize (0.7.3)
12
+ activesupport (4.2.1)
13
+ i18n (~> 0.7)
14
+ json (~> 1.7, >= 1.7.7)
15
+ minitest (~> 5.1)
16
+ thread_safe (~> 0.3, >= 0.3.4)
17
+ tzinfo (~> 1.1)
18
+ codeclimate-test-reporter (0.4.7)
19
+ simplecov (>= 0.7.1, < 1.0.0)
20
+ colorize (0.7.5)
21
+ coveralls (0.7.12)
22
+ multi_json (~> 1.10)
23
+ rest-client (>= 1.6.8, < 2)
24
+ simplecov (~> 0.9.1)
25
+ term-ansicolor (~> 1.3)
26
+ thor (~> 0.19.1)
11
27
  diff-lcs (1.2.5)
28
+ docile (1.1.5)
29
+ domain_name (0.5.23)
30
+ unf (>= 0.0.5, < 1.0.0)
31
+ http-cookie (1.0.2)
32
+ domain_name (~> 0.5)
33
+ i18n (0.7.0)
34
+ json (1.8.2)
35
+ mime-types (2.4.3)
36
+ minitest (5.5.1)
37
+ multi_json (1.11.0)
38
+ netrc (0.10.3)
12
39
  rake (10.2.2)
13
- rspec (2.14.1)
14
- rspec-core (~> 2.14.0)
15
- rspec-expectations (~> 2.14.0)
16
- rspec-mocks (~> 2.14.0)
17
- rspec-core (2.14.8)
18
- rspec-expectations (2.14.5)
19
- diff-lcs (>= 1.1.3, < 2.0)
20
- rspec-mocks (2.14.6)
40
+ rest-client (1.8.0)
41
+ http-cookie (>= 1.0.2, < 2.0)
42
+ mime-types (>= 1.16, < 3.0)
43
+ netrc (~> 0.7)
44
+ rspec (3.2.0)
45
+ rspec-core (~> 3.2.0)
46
+ rspec-expectations (~> 3.2.0)
47
+ rspec-mocks (~> 3.2.0)
48
+ rspec-core (3.2.2)
49
+ rspec-support (~> 3.2.0)
50
+ rspec-expectations (3.2.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.2.0)
53
+ rspec-mocks (3.2.1)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.2.0)
56
+ rspec-support (3.2.2)
57
+ simplecov (0.9.2)
58
+ docile (~> 1.1.0)
59
+ multi_json (~> 1.0)
60
+ simplecov-html (~> 0.9.0)
61
+ simplecov-html (0.9.0)
62
+ stringex (2.5.2)
63
+ term-ansicolor (1.3.0)
64
+ tins (~> 1.0)
65
+ thor (0.19.1)
66
+ thread_safe (0.3.5)
67
+ tins (1.3.5)
68
+ tzinfo (1.2.2)
69
+ thread_safe (~> 0.1)
70
+ unf (0.1.4)
71
+ unf_ext
72
+ unf_ext (0.0.6)
21
73
 
22
74
  PLATFORMS
23
75
  ruby
24
76
 
25
77
  DEPENDENCIES
26
78
  bundler (~> 1.5)
79
+ codeclimate-test-reporter (~> 0.4.7)
80
+ coveralls (~> 0.7.12)
27
81
  locomotivecms_common!
28
82
  rake (~> 10.1)
29
- rspec (~> 2.14)
83
+ rspec (~> 3.2.0)
data/README.md CHANGED
@@ -1,14 +1,6 @@
1
1
  # LocomotiveCMS Common
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/common.png)](http://badge.fury.io/rb/locomotivecms_common)
4
-
5
- [![Code Climate](https://codeclimate.com/github/locomotivecms/common.png)](https://codeclimate.com/github/locomotivecms/common)
6
-
7
- [![Dependency Status](https://gemnasium.com/locomotivecms/common.png)](https://gemnasium.com/locomotivecms/common)
8
-
9
- [![Build Status](https://travis-ci.org/locomotivecms/common.png?branch=master)](https://travis-ci.org/locomotivecms/common) (Travis CI)
10
-
11
- [![Coverage Status](https://coveralls.io/repos/locomotivecms/common/badge.png)](https://coveralls.io/r/locomotivecms/common)
3
+ [![Gem Version](https://badge.fury.io/rb/locomotivecms_common.svg)](http://badge.fury.io/rb/locomotivecms_common) [![Code Climate](https://codeclimate.com/github/locomotivecms/common/badges/gpa.svg)](https://codeclimate.com/github/locomotivecms/common) [![Dependency Status](https://gemnasium.com/locomotivecms/common.svg)](https://gemnasium.com/locomotivecms/common) [![Build Status](https://travis-ci.org/locomotivecms/common.svg?branch=master)](https://travis-ci.org/locomotivecms/common) [![Coverage Status](https://coveralls.io/repos/locomotivecms/common/badge.svg)](https://coveralls.io/r/locomotivecms/common)
12
4
 
13
5
  # Description
14
6
 
@@ -0,0 +1,3 @@
1
+ class FalseClass
2
+ def to_bool() self ; end
3
+ end
@@ -0,0 +1,3 @@
1
+ class TrueClass
2
+ def to_bool() self ; end
3
+ end
@@ -0,0 +1,39 @@
1
+ # Big thanks to Tim Ruffles (https://github.com/timruffles)
2
+ # https://gist.github.com/timruffles/2780508
3
+ module HashConverter
4
+ class << self
5
+
6
+ def to_underscore(hash)
7
+ convert(hash, :underscore)
8
+ end
9
+
10
+ def to_string(hash)
11
+ convert(hash, :to_s)
12
+ end
13
+
14
+ def to_sym(hash)
15
+ convert(hash, :to_sym)
16
+ end
17
+
18
+ # FIXME: not sure it will be ever needed
19
+ # def to_camel_case hash
20
+ # convert hash, :camelize, :lower
21
+ # end
22
+
23
+ def convert(obj, *method)
24
+ case obj
25
+ when Hash
26
+ obj.inject({}) do |h, (k,v)|
27
+ v = convert(v, *method)
28
+ h[k.send(*method)] = v
29
+ h
30
+ end
31
+ when Array
32
+ obj.map { |m| convert(m, *method) }
33
+ else
34
+ obj
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ module Kernel
2
+
3
+ def require_relative_all(paths, sub = nil)
4
+ main_path = File.dirname(caller.first.sub(/:\d+$/, ''))
5
+ main_path = File.join(main_path, sub) if sub
6
+
7
+ [*paths].each do |path|
8
+ Dir[File.join(main_path, path, '*.rb')].each { |file| require file }
9
+ end
10
+ end
11
+
12
+ end
13
+
14
+
@@ -0,0 +1,37 @@
1
+ unless String.public_instance_methods.include?(:to_bool)
2
+ class String
3
+
4
+ def to_bool
5
+ return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
6
+ return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
7
+
8
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
9
+ end
10
+
11
+ end
12
+ end
13
+
14
+ unless String.public_instance_methods.include?(:permalink)
15
+ require 'stringex'
16
+
17
+ class String
18
+
19
+ def permalink(underscore = false)
20
+ # if the slug includes one "_" at least, we consider that the "_" is used instead of "-".
21
+ _permalink = if !self.index('_').nil?
22
+ self.to_url(replace_whitespace_with: '_')
23
+ else
24
+ self.to_url
25
+ end
26
+
27
+ underscore ? _permalink.underscore : _permalink
28
+ end
29
+
30
+ def permalink!(underscore = false)
31
+ replace(self.permalink(underscore))
32
+ end
33
+
34
+ alias :parameterize! :permalink!
35
+
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'core_ext/hash'
2
+ require_relative 'core_ext/string'
3
+ require_relative 'core_ext/boolean/true'
4
+ require_relative 'core_ext/boolean/false'
5
+ require_relative 'core_ext/kernel'
@@ -51,8 +51,5 @@ module Locomotive
51
51
  end
52
52
  end
53
53
 
54
- class MounterException < DefaultException; end
55
- class GeneratorException < DefaultException; end
56
-
57
54
  end
58
55
  end
@@ -16,7 +16,7 @@ module Locomotive
16
16
  # @param[ optional ] [ String ] path The path to the log file, full path with log file name
17
17
  # Sample /home/locomotivecms/log/server.log (default: nil => Stdout)
18
18
  #
19
- def setup log_file_full_path=nil
19
+ def setup(log_file_full_path = nil)
20
20
  require 'logger'
21
21
 
22
22
  output = begin
@@ -39,7 +39,7 @@ module Locomotive
39
39
  @@instance ||= self.new
40
40
  end
41
41
 
42
- def self.setup *args
42
+ def self.setup(*args)
43
43
  if args.size > 1
44
44
  puts "[DEPRECATION] Logger.setup(path, stdout=false) is deprecated. " \
45
45
  "Please use Logger.setup(log_file_full_path) instead, " \
@@ -48,6 +48,10 @@ module Locomotive
48
48
  self.instance.setup args.first
49
49
  end
50
50
 
51
+ def self.close
52
+ self.instance.logger.close
53
+ end
54
+
51
55
  class << self
52
56
  %w(debug info warn error fatal unknown).each do |name|
53
57
  define_method(name) do |message|
@@ -58,7 +62,7 @@ module Locomotive
58
62
 
59
63
  private
60
64
 
61
- def log_file_path log_file_full_path
65
+ def log_file_path(log_file_full_path)
62
66
  if File.directory? log_file_full_path
63
67
  puts "[DEPRECATION] Please use fully log file path like: /home/locomotivecms/log/server.log"
64
68
  File.expand_path(File.join(log_file_full_path, 'log', 'locomotivecms.log'))
@@ -1,5 +1,5 @@
1
1
  module Locomotive
2
2
  module Common
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
- end
5
+ end
@@ -1,9 +1,15 @@
1
1
  require_relative 'common/version'
2
+ require_relative 'common/core_ext'
2
3
  require_relative 'common/logger'
3
4
  require_relative 'common/exception'
4
5
  require_relative 'common/notifier'
5
6
  require_relative 'common/configuration'
6
7
 
8
+ require 'active_support'
9
+ require 'active_support/concern'
10
+ require 'active_support/deprecation'
11
+ require 'active_support/core_ext'
12
+
7
13
  module Locomotive
8
14
  module Common
9
15
  class << self
@@ -16,10 +16,12 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ['lib']
18
18
 
19
- spec.add_development_dependency 'bundler', '~> 1.5'
20
- spec.add_development_dependency 'rake', '~> 10.1'
21
- spec.add_development_dependency 'rspec', '~> 2.14'
19
+ spec.add_development_dependency 'bundler', '~> 1.5'
20
+ spec.add_development_dependency 'rake', '~> 10.1'
22
21
 
22
+ spec.add_dependency 'activesupport', '~> 4.2.1'
23
+ spec.add_dependency 'stringex', '~> 2.5.2'
23
24
  spec.add_dependency 'colorize'
25
+
24
26
  spec.required_ruby_version = '~> 2.0'
25
27
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,17 @@
1
+ require 'simplecov'
2
+ require 'codeclimate-test-reporter'
3
+ require 'coveralls'
4
+
5
+ SimpleCov.start do
6
+ formatter SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ CodeClimate::TestReporter::Formatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ]
11
+
12
+ add_filter 'spec/'
13
+ end
14
+
1
15
  require 'rubygems'
2
16
  require 'bundler/setup'
3
17
 
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+
5
+ describe '#permalink!' do
6
+
7
+ let(:string) { 'foo bar' }
8
+
9
+ before { string.permalink! }
10
+
11
+ it { expect(string).to eq 'foo-bar' }
12
+
13
+ end
14
+
15
+ describe '#to_bool' do
16
+
17
+ subject { string.to_bool }
18
+
19
+ describe 'true values' do
20
+
21
+ %w(true t yes y 1).each do |val|
22
+ let(:string) { val }
23
+ it { is_expected.to eq true }
24
+ end
25
+
26
+ end
27
+
28
+ describe 'false values' do
29
+
30
+ (%w(false f no n 0) + ['']).each do |val|
31
+ let(:string) { val }
32
+ it { is_expected.to eq false }
33
+ end
34
+
35
+ end
36
+
37
+ describe 'no truthy or falsy' do
38
+ let(:string) { 'foo' }
39
+ it { expect { subject }.to raise_error(%(invalid value for Boolean: "foo")) }
40
+ end
41
+
42
+ end
43
+
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-06-03 00:00:00.000000000 Z
13
+ date: 2015-03-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -41,19 +41,33 @@ dependencies:
41
41
  - !ruby/object:Gem::Version
42
42
  version: '10.1'
43
43
  - !ruby/object:Gem::Dependency
44
- name: rspec
44
+ name: activesupport
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '2.14'
50
- type: :development
49
+ version: 4.2.1
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: 4.2.1
57
+ - !ruby/object:Gem::Dependency
58
+ name: stringex
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 2.5.2
64
+ type: :runtime
51
65
  prerelease: false
52
66
  version_requirements: !ruby/object:Gem::Requirement
53
67
  requirements:
54
68
  - - "~>"
55
69
  - !ruby/object:Gem::Version
56
- version: '2.14'
70
+ version: 2.5.2
57
71
  - !ruby/object:Gem::Dependency
58
72
  name: colorize
59
73
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +92,7 @@ extensions: []
78
92
  extra_rdoc_files: []
79
93
  files:
80
94
  - ".gitignore"
95
+ - ".rspec"
81
96
  - ".travis.yml"
82
97
  - Gemfile
83
98
  - Gemfile.lock
@@ -86,6 +101,12 @@ files:
86
101
  - Rakefile
87
102
  - lib/locomotive/common.rb
88
103
  - lib/locomotive/common/configuration.rb
104
+ - lib/locomotive/common/core_ext.rb
105
+ - lib/locomotive/common/core_ext/boolean/false.rb
106
+ - lib/locomotive/common/core_ext/boolean/true.rb
107
+ - lib/locomotive/common/core_ext/hash.rb
108
+ - lib/locomotive/common/core_ext/kernel.rb
109
+ - lib/locomotive/common/core_ext/string.rb
89
110
  - lib/locomotive/common/exception.rb
90
111
  - lib/locomotive/common/logger.rb
91
112
  - lib/locomotive/common/notifier.rb
@@ -94,6 +115,7 @@ files:
94
115
  - locomotivecms_common.gemspec
95
116
  - spec/locomotive/exception_spec.rb
96
117
  - spec/spec_helper.rb
118
+ - spec/unit/core_ext/string_spec.rb
97
119
  homepage: https://github.com/locomotivecms/common
98
120
  licenses:
99
121
  - MIT
@@ -114,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
136
  version: '0'
115
137
  requirements: []
116
138
  rubyforge_project:
117
- rubygems_version: 2.2.2
139
+ rubygems_version: 2.4.5
118
140
  signing_key:
119
141
  specification_version: 4
120
142
  summary: The LocomotiveCMS Common is a shared libraries package for all LocomotiveCMS
@@ -122,3 +144,4 @@ summary: The LocomotiveCMS Common is a shared libraries package for all Locomoti
122
144
  test_files:
123
145
  - spec/locomotive/exception_spec.rb
124
146
  - spec/spec_helper.rb
147
+ - spec/unit/core_ext/string_spec.rb