tarvit-helpers 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd08a34f74744a16787f94fc6672def12d376443
4
- data.tar.gz: d2b3fb239b9ea722eee15c299e5c86a88e83afca
3
+ metadata.gz: aef1d9ca21a50e9d2f9975ea0be449ce3500e3be
4
+ data.tar.gz: 203824340634d89ca93b2a039fa04dc7394a0f84
5
5
  SHA512:
6
- metadata.gz: 9b71a7b7fcb5cc6f418530a9323ece03abf3f3e31258b90480ad980f936b72099e0de1acc7713dff0ff1c75bb2ce07dba01d474c25b29649bd8f7f44bdbaf6eb
7
- data.tar.gz: ced6a3dd027bf260b48026689aa33f5adf42769683b1ad0973f041034168b15e3fcd693f90cbea3ad3644b32068b04dde0d1b980258b7f9de3b97b05a2bd06d0
6
+ metadata.gz: 6dbdd95b07149eced6b46bef06acc41ec0df755242b98729d363f6014d50e6f0a6c579070862a77e55d78327c0d7712708bd0eed1c65e664987dc75f52e73ebc
7
+ data.tar.gz: 083a225650cae0f8338d2176bbd9ec879fb9b27c7021f456b26bdfc73e411a3192deccce3c49f333e53265967dea3940aeddf52ce899d789d91a8304e59ff5b6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.8
@@ -1,6 +1,8 @@
1
1
  module TarvitHelpers
2
2
 
3
- require 'modules/non_shared_accessors'
4
- require 'modules/simple_crypt'
3
+ # modules
4
+ require 'tarvit-helpers/modules/non_shared_accessors'
5
+ require 'tarvit-helpers/modules/simple_crypt'
6
+ require 'tarvit-helpers/modules/conditional_logger'
5
7
 
6
8
  end
@@ -0,0 +1,39 @@
1
+ module TarvitHelpers
2
+
3
+ class ::String
4
+ def colorize(color_code)
5
+ "\e[#{color_code}m#{self}\e[0m"
6
+ end
7
+
8
+ def yellow
9
+ colorize(93)
10
+ end
11
+
12
+ def bg_yellow
13
+ colorize(43)
14
+ end
15
+
16
+ def green
17
+ colorize(32)
18
+ end
19
+
20
+ def blue
21
+ colorize(96)
22
+ end
23
+
24
+ def dark_blue
25
+ colorize(34)
26
+ end
27
+
28
+ def bg_blue
29
+ colorize(44)
30
+ end
31
+
32
+ def red
33
+ colorize(31)
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,37 @@
1
+ module TarvitHelpers
2
+
3
+ class ConditionalLogger
4
+ def initialize(&condition)
5
+ @quiet = !condition.call
6
+ end
7
+
8
+ def puts *message
9
+ return if @quiet
10
+ Kernel::puts *message
11
+ end
12
+
13
+ def print *message
14
+ return if @quiet
15
+ Kernel::print *message
16
+ end
17
+
18
+ def log *message
19
+ puts *message
20
+ end
21
+ end
22
+
23
+ class LogQuiet < ConditionalLogger
24
+
25
+ def self.apply(context, env_var)
26
+ var_set = !!ENV[env_var]
27
+
28
+ unless var_set
29
+ context.instance_eval do
30
+ def puts(*message); end
31
+ def print(*message);end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ end
data/spec/spec_helper.rb CHANGED
@@ -6,8 +6,10 @@ require 'pry'
6
6
 
7
7
  # files
8
8
  require_relative '../lib/tarvit-helpers'
9
- require_relative '../lib/modules/non_shared_accessors'
10
- require_relative '../lib/modules/simple_crypt'
9
+ require_relative '../lib/tarvit-helpers/modules/non_shared_accessors'
10
+ require_relative '../lib/tarvit-helpers/modules/simple_crypt'
11
+ require_relative '../lib/tarvit-helpers/modules/conditional_logger'
12
+
11
13
  include TarvitHelpers
12
14
 
13
15
  RSpec.configure do |config|
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: tarvit-helpers 0.0.6 ruby lib
5
+ # stub: tarvit-helpers 0.0.8 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "tarvit-helpers"
9
- s.version = "0.0.6"
9
+ s.version = "0.0.8"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Vitaly Tarasenko"]
14
- s.date = "2015-06-21"
14
+ s.date = "2015-06-22"
15
15
  s.description = " Simple extensions to standard Ruby classes and useful helpers. "
16
16
  s.email = "vetal.tarasenko@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -25,9 +25,11 @@ Gem::Specification.new do |s|
25
25
  "README.md",
26
26
  "Rakefile",
27
27
  "VERSION",
28
- "lib/modules/non_shared_accessors.rb",
29
- "lib/modules/simple_crypt.rb",
30
28
  "lib/tarvit-helpers.rb",
29
+ "lib/tarvit-helpers/extensions/colored_string.rb",
30
+ "lib/tarvit-helpers/modules/conditional_logger.rb",
31
+ "lib/tarvit-helpers/modules/non_shared_accessors.rb",
32
+ "lib/tarvit-helpers/modules/simple_crypt.rb",
31
33
  "spec/modules/non_shared_accessors_spec.rb",
32
34
  "spec/modules/simple_crypt_spec.rb",
33
35
  "spec/spec_helper.rb",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tarvit-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Tarasenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-21 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,9 +108,11 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - VERSION
111
- - lib/modules/non_shared_accessors.rb
112
- - lib/modules/simple_crypt.rb
113
111
  - lib/tarvit-helpers.rb
112
+ - lib/tarvit-helpers/extensions/colored_string.rb
113
+ - lib/tarvit-helpers/modules/conditional_logger.rb
114
+ - lib/tarvit-helpers/modules/non_shared_accessors.rb
115
+ - lib/tarvit-helpers/modules/simple_crypt.rb
114
116
  - spec/modules/non_shared_accessors_spec.rb
115
117
  - spec/modules/simple_crypt_spec.rb
116
118
  - spec/spec_helper.rb