Skip to content

Commit

Permalink
Put Locale inside Jcsv namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
rbotafogo committed May 25, 2016
1 parent 1347cd8 commit 45eb06f
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 163 deletions.
294 changes: 149 additions & 145 deletions lib/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,168 +21,172 @@
# OR MODIFICATIONS.
##########################################################################################

class Locale

attr_accessor :locale

class << self
attr_accessor :available_locs
end

Locale.available_locs = []
class Jcsv

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.available_locales

if (@available_locs.size == 0)
java.util.Locale.available_locales.each do |loc|
@available_locs << Locale.new(loc)
class Locale

attr_accessor :locale

class << self
attr_accessor :available_locs
end

Locale.available_locs = []

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.available_locales

if (@available_locs.size == 0)
java.util.Locale.available_locales.each do |loc|
@available_locs << Locale.new(loc)
end
end

@available_locs

end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.default
Locale.new(locale: java.util.Locale.default)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.default=(locale)
java.util.Locale.set_default(locale.locale)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.method_missing(symbol, *args)
java.util.Locale.send(symbol, *args)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def initialize(locale: nil, language: nil, country: nil, variant: nil)

args = [language, country, variant]

if (locale)
@locale = locale
else
@locale = java.util.Locale.new(*(args.compact))
end

end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def method_missing(symbol, *args)
@locale.send(symbol, *args)
end

@available_locs

end

#---------------------------------------------------------------------------------------
#=========================================================================================
#
#---------------------------------------------------------------------------------------

def self.default
Locale.new(locale: java.util.Locale.default)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.default=(locale)
java.util.Locale.set_default(locale.locale)
end
#=========================================================================================

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.method_missing(symbol, *args)
java.util.Locale.send(symbol, *args)
end
class Locale

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def initialize(locale: nil, language: nil, country: nil, variant: nil)

args = [language, country, variant]

if (locale)
@locale = locale
else
@locale = java.util.Locale.new(*(args.compact))
end
CANADA = Locale.new(locale: java.util.Locale::CANADA)
CANADA_FRENCH = Locale.new(locale: java.util.Locale::CANADA_FRENCH)
CHINA = Locale.new(locale: java.util.Locale::CHINA)
CHINESE = Locale.new(locale: java.util.Locale::CHINESE)
ENGLISH = Locale.new(locale: java.util.Locale::ENGLISH)
FRANCE = Locale.new(locale: java.util.Locale::FRANCE)
FRENCH = Locale.new(locale: java.util.Locale::FRENCH)
GERMAN = Locale.new(locale: java.util.Locale::GERMAN)
GERMANY = Locale.new(locale: java.util.Locale::GERMANY)
ITALIAN = Locale.new(locale: java.util.Locale::ITALIAN)
ITALY = Locale.new(locale: java.util.Locale::ITALY)
JAPAN = Locale.new(locale: java.util.Locale::JAPAN)
JAPANESE = Locale.new(locale: java.util.Locale::JAPANESE)
KOREA = Locale.new(locale: java.util.Locale::KOREA)
KOREAN = Locale.new(locale: java.util.Locale::KOREAN)
PRC = Locale.new(locale: java.util.Locale::PRC)
ROOT = Locale.new(locale: java.util.Locale::ROOT)
SIMPLIFIED_CHINESE = Locale.new(locale: java.util.Locale::SIMPLIFIED_CHINESE)
TAIWAN = Locale.new(locale: java.util.Locale::TAIWAN)
TRADITIONAL_CHINESE = Locale.new(locale: java.util.Locale::TRADITIONAL_CHINESE)
UK = Locale.new(locale: java.util.Locale::UK)
US = Locale.new(locale: java.util.Locale::US)
BRAZIL = Locale.new(language: "pt", country: "BR")

end

#---------------------------------------------------------------------------------------
##########################################################################################
#
#---------------------------------------------------------------------------------------

def method_missing(symbol, *args)
@locale.send(symbol, *args)
end

end

#=========================================================================================
#
#=========================================================================================

class Locale

CANADA = Locale.new(locale: java.util.Locale::CANADA)
CANADA_FRENCH = Locale.new(locale: java.util.Locale::CANADA_FRENCH)
CHINA = Locale.new(locale: java.util.Locale::CHINA)
CHINESE = Locale.new(locale: java.util.Locale::CHINESE)
ENGLISH = Locale.new(locale: java.util.Locale::ENGLISH)
FRANCE = Locale.new(locale: java.util.Locale::FRANCE)
FRENCH = Locale.new(locale: java.util.Locale::FRENCH)
GERMAN = Locale.new(locale: java.util.Locale::GERMAN)
GERMANY = Locale.new(locale: java.util.Locale::GERMANY)
ITALIAN = Locale.new(locale: java.util.Locale::ITALIAN)
ITALY = Locale.new(locale: java.util.Locale::ITALY)
JAPAN = Locale.new(locale: java.util.Locale::JAPAN)
JAPANESE = Locale.new(locale: java.util.Locale::JAPANESE)
KOREA = Locale.new(locale: java.util.Locale::KOREA)
KOREAN = Locale.new(locale: java.util.Locale::KOREAN)
PRC = Locale.new(locale: java.util.Locale::PRC)
ROOT = Locale.new(locale: java.util.Locale::ROOT)
SIMPLIFIED_CHINESE = Locale.new(locale: java.util.Locale::SIMPLIFIED_CHINESE)
TAIWAN = Locale.new(locale: java.util.Locale::TAIWAN)
TRADITIONAL_CHINESE = Locale.new(locale: java.util.Locale::TRADITIONAL_CHINESE)
UK = Locale.new(locale: java.util.Locale::UK)
US = Locale.new(locale: java.util.Locale::US)
BRAZIL = Locale.new(language: "pt", country: "BR")

end


##########################################################################################
#
##########################################################################################

class DFSymbols

attr_accessor :decimal_format_symbols
##########################################################################################

class << self
attr_accessor :available_locs
end

DFSymbols.available_locs = []

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.available_locales

if (@available_locs.size == 0)
java.text.DecimalFormatSymbols.available_locales.each do |loc|
@available_locs << Locale.new(loc)
class DFSymbols

attr_accessor :decimal_format_symbols

class << self
attr_accessor :available_locs
end

DFSymbols.available_locs = []

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.available_locales

if (@available_locs.size == 0)
java.text.DecimalFormatSymbols.available_locales.each do |loc|
@available_locs << Locale.new(loc)
end
end

@available_locs

end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.method_missing(symbol, *args)
java.text.DecimalFormatSymbols.send(symbol, *args)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def initialize(locale = nil)
@decimal_format_symbols = (locale.nil?)? java.text.DecimalFormatSymbols.new() :
java.text.DecimalFormatSymbols.new(locale.locale)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def method_missing(symbol, *args)
@decimal_format_symbols.send(symbol, *args)
end

@available_locs

end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def self.method_missing(symbol, *args)
java.text.DecimalFormatSymbols.send(symbol, *args)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def initialize(locale = nil)
@decimal_format_symbols = (locale.nil?)? java.text.DecimalFormatSymbols.new() :
java.text.DecimalFormatSymbols.new(locale.locale)
end

#---------------------------------------------------------------------------------------
#
#---------------------------------------------------------------------------------------

def method_missing(symbol, *args)
@decimal_format_symbols.send(symbol, *args)
end

end

15 changes: 10 additions & 5 deletions jcsv.gemspec → mdarray-jcsv.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ Gem::Specification.new do |gem|
gem.version = $version
gem.date = Date.today.to_s

gem.summary = "jCSV is a fast and flexible CSV parser for JRuby. Based on uniVocity parser,
considered by www.xxx.xxx. the fastest CSV reader for Java."
gem.summary = "MDArray-jCSV (jCSV for short) is the first and only (as far as I know)
multidimensional CSV reader. Multidimensional? Yes... jCSV can read multidimensional data,
also known sometimes as 'panel data'. jCSV is based on Super CSV
(http://super-csv.github.io/super-csv/index.html), a java CSV library. According to
Super CSV web page its motivation is 'for Super CSV is to be
the foremost, fastest, and most programmer-friendly, free CSV package for Java'. jCSV
motivation is to bring this view to the Ruby world, and since we are in Ruby, make
it even easier and more programmer-friendly."

gem.description = <<-EOF
Expand All @@ -19,7 +25,7 @@ EOF
gem.authors = ['Rodrigo Botafogo']
gem.email = 'rodrigo.a.botafogo@gmail.com'
gem.homepage = 'http://github.com/rbotafogo/jCSV/wiki'
gem.license = 'Apache'
gem.license = 'Apache-2.0'

gem.add_runtime_dependency('mdarray', '~> 0.5')
gem.add_runtime_dependency('critbit', '~> 0.5')
Expand All @@ -32,8 +38,7 @@ EOF

# ensure the gem is built out of versioned files
gem.files = Dir['Rakefile', 'version.rb', 'config.rb', '{lib,test}/**/*.rb', 'test/**/*.csv',
'test/**/*.xlsx',
'{bin,doc,spec,vendor,target}/**/*',
'test/**/*.xlsx', '{bin,doc,spec,vendor,target,data}/**/*',
'README*', 'LICENSE*'] # & `git ls-files -z`.split("\0")

gem.test_files = Dir['test/*.rb']
Expand Down
Loading

0 comments on commit 45eb06f

Please sign in to comment.