filemanager 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/CHANGELOG +3 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +32 -0
  4. data/Rakefile +30 -0
  5. data/lib/filemanager.rb +59 -0
  6. data/lib/filemanager/controller.rb +197 -0
  7. data/lib/locale.rb +183 -0
  8. data/lib/locale/base.rb +60 -0
  9. data/lib/locale/cgi.rb +103 -0
  10. data/lib/locale/jruby.rb +36 -0
  11. data/lib/locale/object.rb +233 -0
  12. data/lib/locale/posix.rb +22 -0
  13. data/lib/locale/win32.rb +49 -0
  14. data/lib/locale/win32_table.rb +235 -0
  15. data/rails/app/controllers/fm/filemanager_controller.rb +23 -0
  16. data/rails/app/helpers/fm/filemanager_helper.rb +61 -0
  17. data/rails/app/views/fm/filemanager/index.html.erb +509 -0
  18. data/rails/app/views/fm/filemanager/view.html.erb +67 -0
  19. data/rails/config/filemanager.yml +16 -0
  20. data/rails/fm_temp/temp +0 -0
  21. data/rails/public/filemanager/images/avi.gif +0 -0
  22. data/rails/public/filemanager/images/box.gif +0 -0
  23. data/rails/public/filemanager/images/bullet.gif +0 -0
  24. data/rails/public/filemanager/images/close.gif +0 -0
  25. data/rails/public/filemanager/images/closelabel.gif +0 -0
  26. data/rails/public/filemanager/images/doc.gif +0 -0
  27. data/rails/public/filemanager/images/donate-button.gif +0 -0
  28. data/rails/public/filemanager/images/download-icon.gif +0 -0
  29. data/rails/public/filemanager/images/folder.gif +0 -0
  30. data/rails/public/filemanager/images/gif.gif +0 -0
  31. data/rails/public/filemanager/images/htm.gif +0 -0
  32. data/rails/public/filemanager/images/html.gif +0 -0
  33. data/rails/public/filemanager/images/image-1.jpg +0 -0
  34. data/rails/public/filemanager/images/image.gif +0 -0
  35. data/rails/public/filemanager/images/jpg.gif +0 -0
  36. data/rails/public/filemanager/images/loading.gif +0 -0
  37. data/rails/public/filemanager/images/mov.gif +0 -0
  38. data/rails/public/filemanager/images/nextlabel.gif +0 -0
  39. data/rails/public/filemanager/images/pdf.gif +0 -0
  40. data/rails/public/filemanager/images/png.gif +0 -0
  41. data/rails/public/filemanager/images/ppt.gif +0 -0
  42. data/rails/public/filemanager/images/prevlabel.gif +0 -0
  43. data/rails/public/filemanager/images/rar.gif +0 -0
  44. data/rails/public/filemanager/images/rm.gif +0 -0
  45. data/rails/public/filemanager/images/rmvb.gif +0 -0
  46. data/rails/public/filemanager/images/separator.gif +0 -0
  47. data/rails/public/filemanager/images/spacer.gif +0 -0
  48. data/rails/public/filemanager/images/swf.gif +0 -0
  49. data/rails/public/filemanager/images/thumb-1.jpg +0 -0
  50. data/rails/public/filemanager/images/tool_copy.gif +0 -0
  51. data/rails/public/filemanager/images/tool_cut.gif +0 -0
  52. data/rails/public/filemanager/images/tool_del.gif +0 -0
  53. data/rails/public/filemanager/images/tool_folder.gif +0 -0
  54. data/rails/public/filemanager/images/tool_imagemanager.gif +0 -0
  55. data/rails/public/filemanager/images/tool_new.gif +0 -0
  56. data/rails/public/filemanager/images/tool_paste.gif +0 -0
  57. data/rails/public/filemanager/images/tool_props.gif +0 -0
  58. data/rails/public/filemanager/images/tool_refresh.gif +0 -0
  59. data/rails/public/filemanager/images/tool_unzip.gif +0 -0
  60. data/rails/public/filemanager/images/tool_upload.gif +0 -0
  61. data/rails/public/filemanager/images/tool_zip.gif +0 -0
  62. data/rails/public/filemanager/images/txt.gif +0 -0
  63. data/rails/public/filemanager/images/unknown.gif +0 -0
  64. data/rails/public/filemanager/images/wmv.gif +0 -0
  65. data/rails/public/filemanager/images/xls.gif +0 -0
  66. data/rails/public/filemanager/images/zip.gif +0 -0
  67. data/rails/public/filemanager/javascripts/builder.js +136 -0
  68. data/rails/public/filemanager/javascripts/effects.js +1122 -0
  69. data/rails/public/filemanager/javascripts/filemanager.js +6 -0
  70. data/rails/public/filemanager/javascripts/lang/en.js +31 -0
  71. data/rails/public/filemanager/javascripts/lang/zh_CN.js +31 -0
  72. data/rails/public/filemanager/javascripts/lightbox.js +497 -0
  73. data/rails/public/filemanager/javascripts/prototype.js +4221 -0
  74. data/rails/public/filemanager/javascripts/prototype_ext.js +117 -0
  75. data/rails/public/filemanager/javascripts/scriptaculous.js +58 -0
  76. data/rails/public/filemanager/javascripts/translate.js +42 -0
  77. data/rails/public/filemanager/stylesheets/filelist.css +147 -0
  78. data/rails/public/filemanager/stylesheets/general.css +135 -0
  79. data/rails/public/filemanager/stylesheets/lightbox.css +27 -0
  80. data/rails/public/fm_resources/resources.txt +1 -0
  81. metadata +147 -0
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ Changes in version 0.1.0 (2008-05-18)
2
+ -------------------------------------
3
+ initial release
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,32 @@
1
+ Filemanager, release 0.1.0 (May. 2008)
2
+ A online file manager for rails project
3
+
4
+ Feature
5
+ =======
6
+ 1. browse, copy, cut, paste, rename, delete, create funtion for file/folder
7
+ 2. unzip function for zip file
8
+ 3. zip and download files
9
+ 4. upload file
10
+ 5. view file by type (picture, movie, office file, plain file)
11
+ 6. support internationalization of both file path and page description
12
+
13
+ Setup
14
+ =======
15
+ #add the following code at the top of environment.rb
16
+
17
+ $FM_OVERWRITE = true
18
+ require 'filemanager'
19
+
20
+ #note: you can remove $FM_OVERWRITE definition, if you want to keep the change of filemanager's file in your rails project,
21
+ #and meanwhile some updates will be not available if filemanager updated, you can change it according to your need
22
+
23
+ Usage
24
+ =======
25
+ visiting http://localhost:3000/fm/filemanager after rails started
26
+ most functions are listed in the popup menu after right click on different object
27
+
28
+ configuration file at "RAILS_ROOT/confile/filemanager.yml"
29
+ default managed folder is "RAILS_ROOT/public/fm_resources"
30
+ i18n file in "RAILS_ROOT/public/filemanager/javascripts/lang"
31
+
32
+ Copyright (c) 2008 Leon Li, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ PKG_NAME = "filemanager"
4
+ PKG_VERSION = "0.1.0"
5
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
6
+ PKG_FILES = FileList[
7
+ '[A-Z]*',
8
+ 'lib/**/*',
9
+ 'rails/**/*'
10
+ ]
11
+ spec = Gem::Specification.new do |s|
12
+ s.platform = Gem::Platform::RUBY
13
+ s.summary = "A online file manager for rails project"
14
+ s.name = PKG_NAME
15
+ s.version = PKG_VERSION
16
+ s.require_path = 'lib'
17
+ s.homepage = %q{http://filemanager.rubyforge.org/}
18
+ s.rubyforge_project = 'Filemanager'
19
+ s.has_rdoc = false
20
+ s.authors = ["Leon Li"]
21
+ s.email = "scorpio_leon@hotmail.com"
22
+ s.files = PKG_FILES
23
+ s.description = <<-EOF
24
+ A online file manager for rails project��support file/folder actions such as browse, create, rename, remove, copy, move, zip download, upload, unzip, view
25
+ EOF
26
+ end
27
+ Rake::GemPackageTask.new(spec) do |pkg|
28
+ pkg.need_zip = true
29
+ pkg.need_tar = true
30
+ end
@@ -0,0 +1,59 @@
1
+ =begin
2
+ filemanager.rb
3
+ Copyright (C) 2008 Leon Li
4
+
5
+ You may redistribute it and/or modify it under the same
6
+ license terms as Ruby.
7
+ =end
8
+
9
+ require 'action_controller/routing'
10
+ require 'fileutils'
11
+
12
+ fm_config = File.join(RAILS_ROOT, 'config', 'filemanager.yml')
13
+
14
+ if $FM_OVERWRITE || ! File.exist?(fm_config)
15
+ fm_rails_path = File.dirname(File.dirname(__FILE__)) + "/rails/"
16
+ Dir.foreach(fm_rails_path) {|f| FileUtils.cp_r(fm_rails_path + f, RAILS_ROOT)}
17
+ end
18
+
19
+ ActionController::Routing::RouteSet.class_eval do
20
+
21
+ def fm_load_routes!
22
+ fm_old_load_routes!
23
+ map = ActionController::Routing::RouteSet::Mapper.new(self)
24
+ map.namespace :fm do |f|
25
+ f.resources :filemanager
26
+ end
27
+ end
28
+
29
+ alias_method :fm_old_load_routes!, :load_routes!
30
+ alias_method :load_routes!, :fm_load_routes!
31
+
32
+ end
33
+
34
+ require "erb"
35
+ require "yaml"
36
+ $FM_PROPERTIES = YAML::load(ERB.new(IO.read(fm_config)).result)
37
+
38
+ FM_IMAGE_TYPES = $FM_PROPERTIES['image.type'].split(' ')
39
+ FM_FLASH_TYPES = $FM_PROPERTIES['flash.type'].split(' ')
40
+ FM_MOVIE_TYPES = $FM_PROPERTIES['movie.type'].split(' ')
41
+ FM_RM_TYPES = $FM_PROPERTIES['rm.type'].split(' ')
42
+ FM_OFFICE_TYPES = $FM_PROPERTIES['office.type'].split(' ')
43
+ FM_EXCEL_TYPES = $FM_PROPERTIES['excel.type'].split(' ')
44
+ FM_WORD_TYPES = $FM_PROPERTIES['word.type'].split(' ')
45
+ FM_PPT_TYPES = $FM_PROPERTIES['ppt.type'].split(' ')
46
+ FM_HELP_TYPES = $FM_PROPERTIES['help.type'].split(' ')
47
+ FM_PLAIN_TYPES = $FM_PROPERTIES['plain.type'].split(' ')
48
+ FM_NONE_TYPES = $FM_PROPERTIES['none.type'].split(' ')
49
+ FM_SUPPORT_TYPES = FM_IMAGE_TYPES + FM_FLASH_TYPES + FM_MOVIE_TYPES + FM_RM_TYPES + FM_OFFICE_TYPES + FM_HELP_TYPES + FM_PLAIN_TYPES
50
+ FM_UNKNOWN_TYPE = 'unknown'
51
+
52
+ FM_RESOURCES_PATH= $FM_PROPERTIES['resources.path']
53
+ FM_LOCK_PATH = $FM_PROPERTIES['resources.url']
54
+ FM_ENCODING_TO = $FM_PROPERTIES['encoding.to']
55
+ FM_ENCODING_FROM = $FM_PROPERTIES['encoding.from'].nil? ? '' : $FM_PROPERTIES['encoding.from']
56
+
57
+ FM_TEMP_DIR = $FM_PROPERTIES['temp.dir'].nil? ? File.join(RAILS_ROOT, '/fm_temp') : $FM_PROPERTIES['temp.dir']
58
+
59
+ FileUtils.rm_rf(Dir.glob("#{FM_TEMP_DIR}/*"))
@@ -0,0 +1,197 @@
1
+ =begin
2
+ controller.rb
3
+ Copyright (C) 2008 Leon Li
4
+
5
+ You may redistribute it and/or modify it under the same
6
+ license terms as Ruby.
7
+ =end
8
+ module Filemanager
9
+ module Controller
10
+ def set_up
11
+ @lock_path = FM_LOCK_PATH
12
+ @source = params[:source]
13
+ @source = decode(@source) unless @source.nil?
14
+ @path = (params[:path].nil? || ! params[:path].index('..').nil?) ? '' : params[:path]
15
+ @path = '' if @path == '/'
16
+ @path = decode(@path)
17
+ @resource_path = FM_RESOURCES_PATH
18
+ @current_path = @resource_path + @path
19
+ @current_file = (File.directory?(@current_path) ? Dir.new(@current_path) : File.new(@current_path))
20
+ @parent_path = (!@path.blank? && !@path.rindex('/').nil?) ? (@path.rindex('/') == 0 ? '/' : @path[0..(@path.rindex('/')-1)]) : nil
21
+ @path_suffix = @path.index('.').nil? || @path[-1] == '.' ? '' : @path[@path.index('.')+1..-1]
22
+ if File.directory?(@current_path)
23
+ @all_files = Dir.entries(@current_path)
24
+ @directories = @all_files.map{|f| File.directory?(@current_path + File::SEPARATOR + f) ? f : nil}.compact
25
+ @files = @all_files.map{|f| File.directory?(@current_path + File::SEPARATOR + f) ? nil : f}.compact
26
+ @file_total_size = @files.inject(0){|size, f| size + File.size(@current_path + File::SEPARATOR + f)}
27
+ end
28
+ end
29
+
30
+ def tear_off
31
+ @current_file.close unless @current_file.nil?
32
+ end
33
+
34
+ def index
35
+
36
+ end
37
+
38
+ def view
39
+ # respond_to do |wants|
40
+ # wants.js { render :text => File.size(@current_path) > 1000000 ? 'File too big' : File.read(@current_path) }
41
+ # end
42
+ end
43
+
44
+ def file_content
45
+ File.size(@current_path) > 1000000 ? 'File too big' : File.read(@current_path)
46
+ end
47
+
48
+ # def office
49
+ # render :action=>'excel' if is_excel?
50
+ # render :action=>'word' if is_word?
51
+ # render :action=>'ppt' if is_ppt?
52
+ # render :action=>'help' if is_help?
53
+ # end
54
+
55
+ def rename
56
+ old_name = @current_path + File::SEPARATOR + decode(params[:old_name])
57
+ new_name = @current_path + File::SEPARATOR + decode(params[:new_name])
58
+ File.rename(old_name, new_name)
59
+ success
60
+ end
61
+
62
+ def remove
63
+ FileUtils.rm_rf(@source.map{|s| @current_path + File::SEPARATOR + s})
64
+ success
65
+ end
66
+
67
+ def new_file
68
+ File.new(@current_path + File::SEPARATOR + decode(params[:new_name]), 'w')
69
+ success
70
+ end
71
+
72
+ def new_folder
73
+ Dir.mkdir(@current_path + File::SEPARATOR + decode(params[:new_name]))
74
+ success
75
+ end
76
+
77
+ def copy
78
+ session[:source] = @source.map{|s| @current_path + File::SEPARATOR + s}
79
+ session[:remove] = false
80
+ success
81
+ end
82
+
83
+ def cut
84
+ session[:source] = @source.map{|s| @current_path + File::SEPARATOR + s}
85
+ session[:remove] = true
86
+ success
87
+ end
88
+
89
+ def paste
90
+ return error if session[:remove].nil? || session[:source].nil?
91
+ begin
92
+ session[:remove] == true ? FileUtils.mv(session[:source], @current_path) : FileUtils.cp_r(session[:source], @current_path)
93
+ session[:remove] = nil
94
+ session[:source] = nil
95
+ success
96
+ rescue => exception
97
+ result(exception)
98
+ end
99
+
100
+ end
101
+
102
+ def download
103
+ now = Time.new
104
+ now = "#{now.to_i}#{now.usec}"
105
+ temp_file = FM_TEMP_DIR + File::SEPARATOR + now + '.zip'
106
+ FileUtils.cd(@current_path) do |dir|
107
+ system "zip -r #{temp_file} #{@source.map{|s| '"' + s + '"'}.join(' ')}"
108
+ end
109
+ send_file(temp_file)
110
+ end
111
+
112
+
113
+ def upload
114
+ file = params[:upload]
115
+ filename = decode(file.original_filename)
116
+ File.open(@current_path + File::SEPARATOR + filename, "wb") do |f|
117
+ f.write(file.read)
118
+ end
119
+ to_index
120
+ end
121
+
122
+
123
+
124
+ #TODO
125
+ def adjust_size
126
+
127
+ end
128
+
129
+ #TODO
130
+ def rotate
131
+
132
+ end
133
+
134
+ #TODO
135
+ def unzip
136
+ filename = decode(params[:old_name])
137
+ FileUtils.cd(@current_path) do |dir|
138
+ system "unzip -o #{filename}"
139
+ end
140
+ to_index
141
+ end
142
+
143
+ def to_index
144
+ redirect_to :action => 'index', :path => encode(@path)
145
+ end
146
+
147
+ def success
148
+ result("SUCCESS")
149
+ end
150
+
151
+ def error()
152
+ result("ERROR")
153
+ end
154
+
155
+ def result(message)
156
+ respond_to do |wants|
157
+ wants.js { render :text => message }
158
+ end
159
+ end
160
+
161
+ #methods for view
162
+ def method_missing(method_id, *args)
163
+ method_id_s = method_id.to_s
164
+ if method_id_s[0, 3] == 'is_' && method_id_s[-1, 1] == '?'
165
+ instance_eval %{
166
+ def #{method_id}(*args)
167
+ FM_#{method_id_s[3..-2].upcase}_TYPES.include?(@path_suffix)
168
+ end
169
+ }
170
+ send(method_id, *args)
171
+ else
172
+ super
173
+ end
174
+ end
175
+
176
+ def transfer(from, to, target)
177
+ if FM_ENCODING_TO.nil?
178
+ target
179
+ else
180
+ if target.is_a?(Array)
181
+ target.map{|i| to.nil? ? i : Iconv.conv(to, from, i)}
182
+ else
183
+ Iconv.conv(to, from, target)
184
+ end
185
+ end
186
+ end
187
+
188
+ def encode(target)
189
+ transfer(FM_ENCODING_FROM, FM_ENCODING_TO, target);
190
+ end
191
+
192
+ def decode(target)
193
+ transfer(FM_ENCODING_TO, FM_ENCODING_FROM, target);
194
+ end
195
+
196
+ end
197
+ end
data/lib/locale.rb ADDED
@@ -0,0 +1,183 @@
1
+ =begin
2
+ locale.rb - Locale module
3
+
4
+ Copyright (C) 2002-2007 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: locale.rb,v 1.2 2007/11/08 16:44:22 mutoh Exp $
10
+ =end
11
+
12
+ require 'locale/object'
13
+
14
+ if /cygwin|mingw|win32/ =~ RUBY_PLATFORM
15
+ require 'locale/win32'
16
+ elsif /java/ =~ RUBY_PLATFORM
17
+ require 'locale/jruby'
18
+ else
19
+ require 'locale/posix'
20
+ end
21
+
22
+ # Locale module manages the locale informations of the application.
23
+ module Locale
24
+ @@default = nil
25
+ @@current = nil
26
+
27
+ module_function
28
+ # Sets the default locale (Locale::Object or String(such as ja_JP.eucJP)).
29
+ #
30
+ # * locale: the default locale
31
+ # * Returns: self.
32
+ def set_default(locale)
33
+ if locale
34
+ if locale.kind_of? Locale::Object
35
+ @@default = locale
36
+ else
37
+ @@default = Locale::Object.new(locale)
38
+ end
39
+ @@default.charset ||= @@locale_system_module.charset
40
+ else
41
+ @@default = nil
42
+ end
43
+ self
44
+ end
45
+ # Same as Locale.set_default.
46
+ #
47
+ # * locale: the default locale (Locale::Object).
48
+ # * Returns: locale.
49
+ def default=(locale)
50
+ set_default(locale)
51
+ @@default
52
+ end
53
+
54
+ # Gets the system locale.
55
+ # * Returns: the system locale (Locale::Object).
56
+ def system
57
+ @@locale_system_module.system
58
+ end
59
+
60
+ # Gets the default locale.
61
+ #
62
+ # If the default locale not set, this returns system locale.
63
+ # * Returns: the default locale (Locale::Object).
64
+ def default
65
+ @@default ? @@default : system
66
+ end
67
+
68
+ # Gets the current locale (Locale::Object).
69
+ #
70
+ # If the current locale is not set, this returns default locale.
71
+ # * Returns: the current locale (Locale::Object).
72
+ def current
73
+ @@current = default unless @@current
74
+ @@current
75
+ end
76
+
77
+ # Sets a locale as the current locale.
78
+ #
79
+ # This returns the current Locale::Object.
80
+ # * lang: Locale::Object or locale name(String), or language name.
81
+ # * country: the country code(String)
82
+ # * charset: the charset(override the charset even if the locale name has charset).
83
+ # * Returns: self
84
+ #
85
+ # Locale.set_current("ja_JP.eucJP")
86
+ # Locale.set_current("ja", "JP")
87
+ # Locale.set_current("ja", "JP", "eucJP")
88
+ # Locale.set_current("ja", nil, "eucJP")
89
+ # Locale.set_current(Locale::Object.new("ja", "JP", "eucJP"))
90
+ def set_current(lang, country = nil, charset = nil)
91
+ if lang == nil
92
+ @@current = nil
93
+ else
94
+ if lang.kind_of? Locale::Object
95
+ @@current = lang
96
+ else
97
+ @@current = Locale::Object.new(lang, country, charset)
98
+ end
99
+ @@current.charset ||= @@locale_system_module.charset
100
+ end
101
+ self
102
+ end
103
+
104
+ # Sets a current locale. This is a single argument version of Locale.set_current.
105
+ #
106
+ # * lang: the Locale::Object
107
+ # * Returns: the current locale (Locale::Object).
108
+ #
109
+ # Locale.current = "ja_JP.eucJP"
110
+ # Locale.current = Locale::Object.new("ja", "JP", "eucJP")
111
+ def current=(lang)
112
+ set_current(lang)
113
+ @@current
114
+ end
115
+
116
+ # call-seq:
117
+ # set(lang)
118
+ # set(lang, country = nil, charset = nil)
119
+ #
120
+ # * lang: language as String, or Locale::Object
121
+ # * country: country as String or nil
122
+ # * charset: charset as String or nil
123
+ # * Returns: a Locale::Object.
124
+ #
125
+ # Sets a default locale. This function is an alias of Locale.set_default with
126
+ # calling set_current(nil).
127
+ #
128
+ # *Notice*: Locale.set(lctype, locale) is deprecated.
129
+ def set(lang, country = nil, charset = nil)
130
+ set_current(nil)
131
+ if lang.kind_of? String
132
+ set_default(Locale::Object.new(lang, country, charset))
133
+ elsif lang.kind_of? Locale::Object
134
+ set_default(lang)
135
+ else
136
+ set_default(nil)
137
+ end
138
+ @@default
139
+ end
140
+
141
+ # call-seq:
142
+ # current
143
+ # get
144
+ #
145
+ # * Returns: the current locale (Locale::Object).
146
+ #
147
+ # *Notice*: lctype is deprecated. Use this with no parameter instead.
148
+ def get
149
+ @@current = default unless @@current
150
+ @@current
151
+ end
152
+
153
+ # Same as charset. Gets the charset of the current locale.
154
+ # * Returns: the charset of the current locale (String)
155
+ def codeset
156
+ current.charset
157
+ end
158
+
159
+ # Gets the charset of the current locale.
160
+ # * Returns: the charset of the current locale (String)
161
+ def charset
162
+ codeset
163
+ end
164
+ # Same as codeset. Returns the charset of the current locale.
165
+ # * Returns: the charset of the current locale (String)
166
+ def current_charset
167
+ codeset
168
+ end
169
+
170
+ # Clear default/current locale.
171
+ # * Returns: self
172
+ def clear
173
+ set(nil)
174
+ set_current(nil)
175
+ self
176
+ end
177
+
178
+ # Gets the current system module. This is used for debugging.
179
+ # * Returns: the system module.
180
+ def system_module
181
+ @@locale_system_module
182
+ end
183
+ end