simple_rotate 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,111 +1,48 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: simple_rotate
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - nyanko
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-02-26 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: hoe
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 27
29
- segments:
30
- - 2
31
- - 12
32
- version: "2.12"
33
- type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rdoc
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 19
44
- segments:
45
- - 3
46
- - 10
47
- version: "3.10"
48
- type: :development
49
- version_requirements: *id002
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
+ dependencies: []
50
13
  description: simple_rotate is a library that logging & to rotate the ruby's log.
51
- email:
14
+ email:
52
15
  - hotta_1234@yahoo.co.jp
53
16
  executables: []
54
-
55
17
  extensions: []
56
-
57
- extra_rdoc_files:
58
- - History.txt
59
- - Manifest.txt
60
- - PostInstall.txt
61
- files:
62
- - History.txt
63
- - Manifest.txt
64
- - PostInstall.txt
65
- - README.rdoc
66
- - Rakefile
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE.txt
21
+ - README.txt
67
22
  - lib/simple_rotate.rb
68
- - script/console
69
- - script/destroy
70
- - script/generate
71
- - test/test_helper.rb
72
- - test/test_simple_rotate.rb
73
- - lib/simple_rotate/simple_rotate.rb
74
- - .gemtest
75
- homepage:
76
- licenses: []
77
-
78
- post_install_message: PostInstall.txt
79
- rdoc_options:
80
- - --main
81
- - README.rdoc
82
- require_paths:
23
+ homepage: http://khotta.github.io/simple_rotate
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message: "\n\e[5mThank you for installing! (^-^)\e[0m\nSee also \e[31m\e[47m
28
+ \e[4mhttp://khotta.github.io/simple_rotate \e[0m\n\n"
29
+ rdoc_options: []
30
+ require_paths:
83
31
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
- version: "0"
93
- required_rubygems_version: !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
102
42
  requirements: []
103
-
104
- rubyforge_project: simple_rotate
105
- rubygems_version: 1.8.12
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.0
106
45
  signing_key:
107
- specification_version: 3
108
- summary: simple_rotate is a library that logging & to rotate the ruby's log.
109
- test_files:
110
- - test/test_helper.rb
111
- - test/test_simple_rotate.rb
46
+ specification_version: 4
47
+ summary: Logger for Ruby.
48
+ test_files: []
data/.gemtest DELETED
File without changes
@@ -1,4 +0,0 @@
1
- === 0.0.1 2011-12-16
2
-
3
- * 1 major enhancement:
4
- * Initial release
@@ -1,12 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- PostInstall.txt
4
- README.rdoc
5
- Rakefile
6
- lib/simple_rotate.rb
7
- script/console
8
- script/destroy
9
- script/generate
10
- test/test_helper.rb
11
- test/test_simple_rotate.rb
12
- lib/simple_rotate/simple_rotate.rb
@@ -1,7 +0,0 @@
1
-
2
- For more information on simple_rotate, see http://simple_rotate.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
6
-
7
-
@@ -1,44 +0,0 @@
1
- = simple_rotate
2
-
3
- == DESCRIPTION:
4
-
5
- simple_rotate is a library that logging & to rotate the ruby's log.
6
-
7
- == FEATURES/PROBLEMS:
8
-
9
- tested only with Ruby 1.8.7.
10
-
11
- == SYNOPSIS:
12
-
13
- to rotate the ruby's log file.
14
-
15
- == REQUIREMENTS:
16
-
17
- == INSTALL:
18
-
19
- sudo gem install simple_lotate
20
-
21
- == LICENSE:
22
-
23
- (The MIT License)
24
-
25
- Copyright (c) 2011 nyanko
26
-
27
- Permission is hereby granted, free of charge, to any person obtaining
28
- a copy of this software and associated documentation files (the
29
- 'Software'), to deal in the Software without restriction, including
30
- without limitation the rights to use, copy, modify, merge, publish,
31
- distribute, sublicense, and/or sell copies of the Software, and to
32
- permit persons to whom the Software is furnished to do so, subject to
33
- the following conditions:
34
-
35
- The above copyright notice and this permission notice shall be
36
- included in all copies or substantial portions of the Software.
37
-
38
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
39
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
41
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
42
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
43
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,26 +0,0 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/simple_rotate'
6
-
7
- Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
-
11
- # Generate all the Rake tasks
12
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- $hoe = Hoe.spec 'simple_rotate' do
14
- self.developer 'nyanko', 'hotta_1234@yahoo.co.jp'
15
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
- self.rubyforge_name = self.name # TODO this is default value
17
- # self.extra_deps = [['activesupport','>= 2.0.2']]
18
-
19
- end
20
-
21
- require 'newgem/tasks'
22
- Dir['tasks/**/*.rake'].each { |t| load t }
23
-
24
- # TODO - want other tests/tasks run by default? Add them to the list
25
- # remove_task :default
26
- # task :default => [:spec, :features]
@@ -1,120 +0,0 @@
1
- class SimpleRotate
2
- public
3
- def initialize(log_file=$0+".log", max_size='1M', rotate=true, log_format=".", log_mess=true)
4
- @log_file = log_file
5
- @max_size = trim_byte(max_size)
6
- @log_format = log_format
7
- @rotate = rotate
8
- @log_mess = log_mess
9
- @rotate = false if @rotate == 0
10
-
11
- if File.exist?(@log_file)
12
- if over_size(@log_file)
13
- ch_name(@log_file)
14
- @logf = File.open(@log_file, "w+")
15
- else
16
- @logf = File.open(@log_file, "a+")
17
- end
18
- else
19
- @logf = File.open(@log_file, "w+")
20
- end
21
- @size = File.size(@log_file)
22
- w("\n----- Start Logs [Date: #{get_time('milestone')}] [PID: #{$$}] -----\n") if @log_mess
23
- end
24
-
25
- private
26
- def over_size(f)
27
- if File.size(f) > @max_size
28
- return true
29
- else
30
- return false
31
- end
32
- end
33
-
34
- private
35
- def ch_name(f)
36
- cnt = 1
37
- rename_f = "#{@log_file}#{@log_format}#{cnt}"
38
-
39
- if File.exist?(rename_f)
40
- while File.exist?(rename_f)
41
- cnt += 1
42
- rename_f = "#{@log_file}#{@log_format}#{cnt}"
43
- end
44
- wait_rename = Array.new
45
- for nc in 1...cnt
46
- break if @rotate == 1
47
- wait_rename << "File.rename('#{@log_file}#{@log_format}#{nc}', '#{@log_file}#{@log_format}#{nc+1}')"
48
- if @rotate
49
- next if @rotate.class == TrueClass
50
- break if @rotate <= nc+1
51
- end
52
- end
53
-
54
- wait_rename.reverse!
55
- wait_rename.each{ |do_rename|
56
- eval(do_rename)
57
- }
58
- File.rename(f, "#{@log_file}#{@log_format}1") if @rotate
59
-
60
- else
61
- File.rename(f, rename_f) if @rotate
62
- end
63
- end
64
-
65
- private
66
- def get_time(request)
67
- if request == "party"
68
- return Time.now.strftime("[%Y/%m/%d %H:%M:%S] ")
69
- elsif request == "milestone"
70
- return Time.now.strftime("%Y/%m/%d %H:%M:%S")
71
- end
72
- end
73
-
74
- private
75
- def trim_byte(max_size)
76
- kiro = "000"
77
- mega = kiro + "000"
78
- giga = mega + "000"
79
- tera = giga + "000"
80
- max_size = max_size.to_s
81
-
82
- if /K$/ =~ max_size
83
- max_size = max_size.sub(/K$/, "") + kiro
84
- elsif /M$/ =~ max_size
85
- max_size = max_size.sub(/M$/, "") + mega
86
- elsif /G$/ =~ max_size
87
- max_size = max_size.sub(/G$/, "") + giga
88
- elsif /T$/ =~ max_size
89
- max_size = max_size.sub(/T$/, "") + tera
90
- end
91
-
92
- return max_size.to_i
93
- end
94
-
95
- public
96
- def flush
97
- e
98
- ch_name(@log_file)
99
- @logf = File.open(@log_file, "w+")
100
- @size = File.size(@log_file)
101
- w("\n----- Start Logs [Date: #{get_time('milestone')}] [PID: #{$$}] -----\n") if @log_mess
102
- end
103
-
104
- public
105
- def w(str, output=false, rec_time=false)
106
- if rec_time
107
- @logf.puts(get_time('party')+str)
108
- puts get_time('party')+str if output
109
- else
110
- @logf.puts(str)
111
- puts str if output
112
- end
113
- end
114
-
115
- public
116
- def e
117
- w("----- End Logs [Date: #{get_time('milestone')}] [PID: #{$$}] -----\n") if @log_mess
118
- @logf.close
119
- end
120
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/simple_rotate.rb'}"
9
- puts "Loading simple_rotate gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,3 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/simple_rotate'
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestSimpleRotate < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_truth
9
- assert true
10
- end
11
- end