lioooo_utils 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +21 -14
  2. data/lib/logs/lioooo_log.rb +12 -12
  3. data/lib/version.rb +1 -1
  4. metadata +3 -3
data/README.rdoc CHANGED
@@ -1,19 +1,26 @@
1
- = lioooo_utils
1
+ == lioooo_utils
2
2
 
3
- Description goes here.
3
+ #### How to use it
4
4
 
5
- == Contributing to lioooo_utils
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
5
+ `gem install lioooo_utils`
14
6
 
15
- == Copyright
7
+ ```
8
+ require 'lioooo_utils'
16
9
 
17
- Copyright (c) 2014 mrli. See LICENSE.txt for
18
- further details.
10
+ LiooooLogger = LiooooUtilsLogger.new :lioooo,'/tmp' #new instance with log parent directory '/tmp/lioooo_log.log'
19
11
 
12
+ LiooooLogger.info '--> it's ok with lioooo_utils' # will log to /tmp/lioooo_log.log log file
13
+
14
+ ```
15
+
16
+ #### you can call shell command
17
+ like this:
18
+
19
+ ```
20
+ require 'lioooo_utils'
21
+
22
+ LiooooLogger = LiooooUtilsLogger.new :lioooo,'/tmp' #new instance with log parent directory '/tmp/lioooo_log.log'
23
+
24
+ LiooooLogger.shell_exec! 'echo ok' # this will can shell `echo` command
25
+
26
+ ```
@@ -3,11 +3,12 @@ require 'colored'
3
3
  require 'logging'
4
4
  LogRoot = File.expand_path("../../log", __FILE__)
5
5
  class LiooooUtilsLogger
6
- attr_accessor :logger
6
+ attr_accessor :logger, :log_dir
7
7
 
8
- def initialize type
8
+ def initialize type, log_dir=nil
9
+ @log_dir = log_dir.nil? ? LogRoot : log_dir
9
10
  init_log_dir
10
- path = File.expand_path("#{LogRoot}/#{type}_log.log", __FILE__)
11
+ path = File.expand_path("#{log_dir}/#{type}_log.log", __FILE__)
11
12
  @logger = Logging.logger["Lioooo#{type.upcase}Log"]
12
13
  @logger.add_appenders(
13
14
  Logging.appenders.stdout,
@@ -26,8 +27,8 @@ class LiooooUtilsLogger
26
27
 
27
28
  # liooo_link_log_dir require log directory
28
29
  def init_log_dir
29
- cmd = "mkdir -p #{LogRoot}"
30
- system cmd unless File.exist? LogRoot
30
+ cmd = "mkdir -p #{log_dir}"
31
+ system cmd unless File.exist? log_dir
31
32
  end
32
33
 
33
34
  # puts log with error prefix
@@ -62,17 +63,16 @@ class LiooooUtilsLogger
62
63
  @logger.info msg.blue
63
64
  end
64
65
 
65
- end
66
-
67
- #custom call system shell script
68
- class ShellExec
69
- def self.exec! cmd
70
- LiooooLogger.shell cmd
66
+ #---------------------for call shell command----------------
67
+ def shell_exec! cmd
68
+ shell cmd
71
69
  system "source ~/.bash_profile && #{cmd}"
72
70
  end
71
+
73
72
  end
74
73
 
75
- LiooooLogger = LiooooUtilsLogger.new :lioooo
74
+ # need init when use it
75
+ #LiooooLogger = LiooooUtilsLogger.new :lioooo
76
76
 
77
77
 
78
78
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class LiooooUtils
2
- VERSION = '0.1.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lioooo_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-07 00:00:00.000000000 Z
12
+ date: 2014-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  segments:
189
189
  - 0
190
- hash: -1927989948339082945
190
+ hash: 1069938870692798031
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  none: false
193
193
  requirements: