mdarray-jcsv 0.6.3-java
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 +7 -0
- data/LICENSE.txt +23 -0
- data/README.md +2 -0
- data/Rakefile +46 -0
- data/config.rb +104 -0
- data/lib/constraints.rb +205 -0
- data/lib/date_filters.rb +252 -0
- data/lib/dimensions.rb +276 -0
- data/lib/filters.rb +332 -0
- data/lib/jcsv.rb +107 -0
- data/lib/list_reader.rb +200 -0
- data/lib/locale.rb +192 -0
- data/lib/map_reader.rb +192 -0
- data/lib/mdarray-jcsv.rb +24 -0
- data/lib/mdarray_reader.rb +110 -0
- data/lib/numeric_filters.rb +225 -0
- data/lib/reader.rb +547 -0
- data/lib/supercsv_interface.rb +231 -0
- data/test/test_complete.rb +37 -0
- data/test/test_critbit.rb +442 -0
- data/test/test_customer_list.rb +436 -0
- data/test/test_customer_map.rb +209 -0
- data/test/test_customer_nhlist.rb +161 -0
- data/test/test_deep_map.rb +264 -0
- data/test/test_del.rb +73 -0
- data/test/test_dimensions.rb +231 -0
- data/test/test_example.rb +79 -0
- data/test/test_filters.rb +374 -0
- data/test/test_list_dimensions.rb +110 -0
- data/test/test_mdarray.rb +227 -0
- data/test/test_missing_data.rb +57 -0
- data/vendor/commons-beanutils-1.8.3.jar +0 -0
- data/vendor/commons-lang3-3.1.jar +0 -0
- data/vendor/dozer-5.4.0.jar +0 -0
- data/vendor/jcl-over-slf4j-1.6.6.jar +0 -0
- data/vendor/joda-time-2.7.jar +0 -0
- data/vendor/slf4j-api-1.7.5.jar +0 -0
- data/vendor/snakeyaml-1.14.jar +0 -0
- data/vendor/super-csv-2.4.0.jar +0 -0
- data/vendor/super-csv-dozer-2.4.0.jar +0 -0
- data/vendor/super-csv-java8-2.4.0.jar +0 -0
- data/vendor/super-csv-joda-2.4.0.jar +0 -0
- data/version.rb +2 -0
- metadata +196 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: a7a8ac56f5cb4c74eadaee32a942a2f76a9cd854
         | 
| 4 | 
            +
              data.tar.gz: ae705832c3b02d83969a7888d175240844d1cd15
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: aa42b29069ac053e86f2613ad5bddfc1cb063f3d0fb8213443e1f75f064d928066f9e3b6b17c07c4ce1ffb54f25f9e3d3b1585d3504ec1b97ff28986ce717cbc
         | 
| 7 | 
            +
              data.tar.gz: 9563e6d82f6a4eeb38b430a480cb00701402357e017381901af75bb1ebf600d6351d38e4401b430cfcaf66907d05bb4e2c9d7294fb613fb38446a212dd083673
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # -*- coding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            The MIT License (MIT)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Copyright (c) 2015 Rodrigo Botafogo 
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy of
         | 
| 8 | 
            +
            this software and associated documentation files (the "Software"), to deal in
         | 
| 9 | 
            +
            the Software without restriction, including without limitation the rights to
         | 
| 10 | 
            +
            use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
         | 
| 11 | 
            +
            the Software, and to permit persons to whom the Software is furnished to do so,
         | 
| 12 | 
            +
            subject to the following conditions:
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            The above copyright notice and this permission notice shall be included in all
         | 
| 15 | 
            +
            copies or substantial portions of the Software.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 18 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
         | 
| 19 | 
            +
            FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
         | 
| 20 | 
            +
            COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
         | 
| 21 | 
            +
            IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
         | 
| 22 | 
            +
            CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
| 23 | 
            +
             | 
    
        data/README.md
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require 'rake/testtask'
         | 
| 2 | 
            +
            require_relative 'version'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            name = "#{$gem_name}-#{$version}.gem"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            rule '.class' => '.java' do |t|
         | 
| 7 | 
            +
              sh "javac #{t.source}"
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            desc 'default task'
         | 
| 11 | 
            +
            task :default => [:install_gem]
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            desc 'Makes a Gem'
         | 
| 14 | 
            +
            task :make_gem do
         | 
| 15 | 
            +
              sh "gem build #{$gem_name}.gemspec"
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            desc 'Install the gem in the standard location'
         | 
| 19 | 
            +
            task :install_gem => [:make_gem] do
         | 
| 20 | 
            +
              sh "gem install #{$gem_name}-#{$version}-java.gem"
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            desc 'Make documentation'
         | 
| 24 | 
            +
            task :make_doc do
         | 
| 25 | 
            +
              sh "yard doc lib/*.rb lib/**/*.rb"
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            desc 'Push project to github'
         | 
| 29 | 
            +
            task :push do
         | 
| 30 | 
            +
              sh "git push origin master"
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            desc 'Push gem to rubygem'
         | 
| 34 | 
            +
            task :push_gem do
         | 
| 35 | 
            +
              sh "push #{name} -p $http_proxy"
         | 
| 36 | 
            +
            end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            Rake::TestTask.new do |t|
         | 
| 39 | 
            +
              t.libs << "test"
         | 
| 40 | 
            +
              t.test_files = FileList['test/complete.rb']
         | 
| 41 | 
            +
              t.ruby_opts = ["--server", "-Xinvokedynamic.constants=true", "-J-Xmn512m", 
         | 
| 42 | 
            +
                             "-J-Xms1024m", "-J-Xmx1024m"]
         | 
| 43 | 
            +
              t.verbose = true
         | 
| 44 | 
            +
              t.warning = true
         | 
| 45 | 
            +
            end
         | 
| 46 | 
            +
             | 
    
        data/config.rb
    ADDED
    
    | @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            require 'rbconfig'
         | 
| 2 | 
            +
            require 'java'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # In principle should not be in this file.  The right way of doing this is by executing
         | 
| 6 | 
            +
            # bundler exec, but I don't know how to do this from inside emacs.  So, should comment
         | 
| 7 | 
            +
            # the next line before publishing the GEM.  If not commented, this should be harmless
         | 
| 8 | 
            +
            # anyway.
         | 
| 9 | 
            +
            #
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            begin
         | 
| 12 | 
            +
              require 'bundler/setup'
         | 
| 13 | 
            +
            rescue LoadError
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            # the platform
         | 
| 17 | 
            +
            @platform = 
         | 
| 18 | 
            +
              case RUBY_PLATFORM
         | 
| 19 | 
            +
              when /mswin/ then 'windows'
         | 
| 20 | 
            +
              when /mingw/ then 'windows'
         | 
| 21 | 
            +
              when /bccwin/ then 'windows'
         | 
| 22 | 
            +
              when /cygwin/ then 'windows-cygwin'
         | 
| 23 | 
            +
              when /java/
         | 
| 24 | 
            +
                require 'java' #:nodoc:
         | 
| 25 | 
            +
                if java.lang.System.getProperty("os.name") =~ /[Ww]indows/
         | 
| 26 | 
            +
                  'windows-java'
         | 
| 27 | 
            +
                else
         | 
| 28 | 
            +
                  'default-java'
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              else
         | 
| 31 | 
            +
                'default'
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            #---------------------------------------------------------------------------------------
         | 
| 35 | 
            +
            # Set the project directories
         | 
| 36 | 
            +
            #---------------------------------------------------------------------------------------
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            class Jcsv
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              @home_dir = File.expand_path File.dirname(__FILE__)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              class << self
         | 
| 43 | 
            +
                attr_reader :home_dir
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              @project_dir = Jcsv.home_dir + "/.."
         | 
| 47 | 
            +
              @doc_dir = Jcsv.home_dir + "/doc"
         | 
| 48 | 
            +
              @lib_dir = Jcsv.home_dir + "/lib"
         | 
| 49 | 
            +
              @src_dir = Jcsv.home_dir + "/src"
         | 
| 50 | 
            +
              @target_dir = Jcsv.home_dir + "/target"
         | 
| 51 | 
            +
              @test_dir = Jcsv.home_dir + "/test"
         | 
| 52 | 
            +
              @vendor_dir = Jcsv.home_dir + "/vendor"
         | 
| 53 | 
            +
              
         | 
| 54 | 
            +
              class << self
         | 
| 55 | 
            +
                attr_reader :project_dir
         | 
| 56 | 
            +
                attr_reader :doc_dir
         | 
| 57 | 
            +
                attr_reader :lib_dir
         | 
| 58 | 
            +
                attr_reader :src_dir
         | 
| 59 | 
            +
                attr_reader :target_dir
         | 
| 60 | 
            +
                attr_reader :test_dir
         | 
| 61 | 
            +
                attr_reader :vendor_dir
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              @build_dir = Jcsv.src_dir + "/build"
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              class << self
         | 
| 67 | 
            +
                attr_reader :build_dir
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              @classes_dir = Jcsv.build_dir + "/classes"
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              class << self
         | 
| 73 | 
            +
                attr_reader :classes_dir
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
             | 
| 79 | 
            +
            #----------------------------------------------------------------------------------------
         | 
| 80 | 
            +
            # If we need to test for coverage
         | 
| 81 | 
            +
            #----------------------------------------------------------------------------------------
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            if $COVERAGE == 'true'
         | 
| 84 | 
            +
              
         | 
| 85 | 
            +
              require 'simplecov'
         | 
| 86 | 
            +
              
         | 
| 87 | 
            +
              SimpleCov.start do
         | 
| 88 | 
            +
                @filters = []
         | 
| 89 | 
            +
                add_group "Jcsv"
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
              
         | 
| 92 | 
            +
            end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            ##########################################################################################
         | 
| 95 | 
            +
            # Load necessary jar files
         | 
| 96 | 
            +
            ##########################################################################################
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            Dir["#{Jcsv.vendor_dir}/*.jar"].each do |jar|
         | 
| 99 | 
            +
              require jar
         | 
| 100 | 
            +
            end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
            Dir["#{Jcsv.target_dir}/*.jar"].each do |jar|
         | 
| 103 | 
            +
              require jar
         | 
| 104 | 
            +
            end
         | 
    
        data/lib/constraints.rb
    ADDED
    
    | @@ -0,0 +1,205 @@ | |
| 1 | 
            +
            # -*- coding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ##########################################################################################
         | 
| 4 | 
            +
            # @author Rodrigo Botafogo
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            # Copyright © 2015 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify, 
         | 
| 7 | 
            +
            # and distribute this software and its documentation, without fee and without a signed 
         | 
| 8 | 
            +
            # licensing agreement, is hereby granted, provided that the above copyright notice, this 
         | 
| 9 | 
            +
            # paragraph and the following two paragraphs appear in all copies, modifications, and 
         | 
| 10 | 
            +
            # distributions.
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, 
         | 
| 13 | 
            +
            # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF 
         | 
| 14 | 
            +
            # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE 
         | 
| 15 | 
            +
            # POSSIBILITY OF SUCH DAMAGE.
         | 
| 16 | 
            +
            #
         | 
| 17 | 
            +
            # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
         | 
| 18 | 
            +
            # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 
         | 
| 19 | 
            +
            # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". 
         | 
| 20 | 
            +
            # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 
         | 
| 21 | 
            +
            # OR MODIFICATIONS.
         | 
| 22 | 
            +
            ##########################################################################################
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            class Jcsv
         | 
| 25 | 
            +
              # include_package "org.supercsv.cellprocessor"
         | 
| 26 | 
            +
              # include_package "org.supercsv.cellprocessor.constraint"
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              #========================================================================================
         | 
| 29 | 
            +
              #
         | 
| 30 | 
            +
              #========================================================================================
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              class RBInRange < Filter
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                attr_reader :min
         | 
| 35 | 
            +
                attr_reader :max
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                def initialize(min, max)
         | 
| 38 | 
            +
                  @min = min
         | 
| 39 | 
            +
                  @max = max
         | 
| 40 | 
            +
                  super()
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
                
         | 
| 43 | 
            +
                def execute(value, context)
         | 
| 44 | 
            +
                  validateInputNotNull(value, context)
         | 
| 45 | 
            +
                  raise ConstraintViolation,
         | 
| 46 | 
            +
                        "#{@min} <= #{value} <= #{@max} does not hold:\n#{context}" if
         | 
| 47 | 
            +
                    (value < @min || value > @max)
         | 
| 48 | 
            +
                  exec_next(value, context)
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
                
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
              
         | 
| 53 | 
            +
              #========================================================================================
         | 
| 54 | 
            +
              #
         | 
| 55 | 
            +
              #========================================================================================
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              class RBForbidSubstrings < Filter
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                attr_reader :substrings
         | 
| 60 | 
            +
                
         | 
| 61 | 
            +
                def initialize(substrings)
         | 
| 62 | 
            +
                  @substrings = substrings
         | 
| 63 | 
            +
                  super()
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                def execute(value, context)
         | 
| 67 | 
            +
                  validateInputNotNull(value, context)
         | 
| 68 | 
            +
                  substrings.each do |sub|
         | 
| 69 | 
            +
                    raise "Substring #{sub} found in #{value}:\n#{context}" if value.include?(sub)
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
                  exec_next(value, context)
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
                
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
              
         | 
| 76 | 
            +
              #========================================================================================
         | 
| 77 | 
            +
              #
         | 
| 78 | 
            +
              #========================================================================================
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              class RBEquals < Filter
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                attr_reader :value
         | 
| 83 | 
            +
                
         | 
| 84 | 
            +
                def initialize(value = nil)
         | 
| 85 | 
            +
                  @value = value
         | 
| 86 | 
            +
                  super()
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
                
         | 
| 89 | 
            +
                def execute(value, context)
         | 
| 90 | 
            +
                  validateInputNotNull(value, context)
         | 
| 91 | 
            +
                  @value ||= value # if value not initialized then use the first read value for equals
         | 
| 92 | 
            +
                  
         | 
| 93 | 
            +
                  raise "Value '#{value}' is not equal to '#{@value}':\n#{context}" if
         | 
| 94 | 
            +
                    (value != @value)
         | 
| 95 | 
            +
                  exec_next(value, context)
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
              
         | 
| 100 | 
            +
              #========================================================================================
         | 
| 101 | 
            +
              #
         | 
| 102 | 
            +
              #========================================================================================
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              class RBNotNil < Filter
         | 
| 105 | 
            +
                    
         | 
| 106 | 
            +
                def execute(value, context)
         | 
| 107 | 
            +
                  raise ConstraintViolation, "Empty value found:\n#{context}" if (value.nil?)
         | 
| 108 | 
            +
                  exec_next(value, context)
         | 
| 109 | 
            +
                end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
              #========================================================================================
         | 
| 114 | 
            +
              #
         | 
| 115 | 
            +
              #========================================================================================
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              class RBIsElementOf < Filter
         | 
| 118 | 
            +
                
         | 
| 119 | 
            +
                attr_reader :strings
         | 
| 120 | 
            +
                
         | 
| 121 | 
            +
                def initialize(strings)
         | 
| 122 | 
            +
                  @strings = strings
         | 
| 123 | 
            +
                  super()
         | 
| 124 | 
            +
                end
         | 
| 125 | 
            +
                
         | 
| 126 | 
            +
                def execute(value, context)
         | 
| 127 | 
            +
                  validateInputNotNull(value, context)
         | 
| 128 | 
            +
                  raise "Value #{value} not element of #{@strings}:\n#{context}" if
         | 
| 129 | 
            +
                    !@strings.include?(value)
         | 
| 130 | 
            +
                  exec_next(value, context)
         | 
| 131 | 
            +
                end
         | 
| 132 | 
            +
                
         | 
| 133 | 
            +
              end
         | 
| 134 | 
            +
             | 
| 135 | 
            +
              #========================================================================================
         | 
| 136 | 
            +
              #
         | 
| 137 | 
            +
              #========================================================================================
         | 
| 138 | 
            +
             | 
| 139 | 
            +
              class RBStrConstraints < Filter
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                def initialize(function, *args, check: true)
         | 
| 142 | 
            +
                  @function = function
         | 
| 143 | 
            +
                  @args = args
         | 
| 144 | 
            +
                  @check = check
         | 
| 145 | 
            +
                  super()
         | 
| 146 | 
            +
                end
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                def execute(value, context)
         | 
| 149 | 
            +
                  truth = value.send(@function, *(@args))
         | 
| 150 | 
            +
                  raise "Constraint #{@function} with value #{value} is #{truth}:\n#{context}" if
         | 
| 151 | 
            +
                    truth == @check
         | 
| 152 | 
            +
                  exec_next(value, context)
         | 
| 153 | 
            +
                end
         | 
| 154 | 
            +
             | 
| 155 | 
            +
              end
         | 
| 156 | 
            +
              
         | 
| 157 | 
            +
              #========================================================================================
         | 
| 158 | 
            +
              #
         | 
| 159 | 
            +
              #========================================================================================
         | 
| 160 | 
            +
             | 
| 161 | 
            +
              def self.in_range(min, max)
         | 
| 162 | 
            +
                RBInRange.new(min, max)
         | 
| 163 | 
            +
              end
         | 
| 164 | 
            +
             | 
| 165 | 
            +
              def self.equals(value = nil)
         | 
| 166 | 
            +
                RBEquals.new(value)
         | 
| 167 | 
            +
              end
         | 
| 168 | 
            +
              
         | 
| 169 | 
            +
              def self.ascii_only?
         | 
| 170 | 
            +
                RBStrConstraints.new(:ascii_only?)
         | 
| 171 | 
            +
              end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
              def self.not_ascii?
         | 
| 174 | 
            +
                RBStrConstraints.new(:ascii_only?, check: false)
         | 
| 175 | 
            +
              end
         | 
| 176 | 
            +
             | 
| 177 | 
            +
              def self.empty?
         | 
| 178 | 
            +
                RBStrConstraints.new(:empty?)
         | 
| 179 | 
            +
              end
         | 
| 180 | 
            +
             | 
| 181 | 
            +
              def self.end_with?(*args)
         | 
| 182 | 
            +
                RBStrConstraints.new(:end_with?, *args)
         | 
| 183 | 
            +
              end
         | 
| 184 | 
            +
              
         | 
| 185 | 
            +
              def self.include?(*args)
         | 
| 186 | 
            +
                RBStrConstraints.new(:include?, *args)
         | 
| 187 | 
            +
              end
         | 
| 188 | 
            +
             | 
| 189 | 
            +
              def self.start_with?(*args)
         | 
| 190 | 
            +
                RBStrConstraints.new(:start_with?, *args)
         | 
| 191 | 
            +
              end
         | 
| 192 | 
            +
             | 
| 193 | 
            +
              def self.not_nil
         | 
| 194 | 
            +
                RBNotNil.new
         | 
| 195 | 
            +
              end
         | 
| 196 | 
            +
             | 
| 197 | 
            +
              def self.forbid_substrings(substrings)
         | 
| 198 | 
            +
                RBForbidSubstrings.new(substrings)
         | 
| 199 | 
            +
              end
         | 
| 200 | 
            +
             | 
| 201 | 
            +
              def self.is_element_of(strings)
         | 
| 202 | 
            +
                RBIsElementOf.new(strings)
         | 
| 203 | 
            +
              end
         | 
| 204 | 
            +
             | 
| 205 | 
            +
            end
         | 
    
        data/lib/date_filters.rb
    ADDED
    
    | @@ -0,0 +1,252 @@ | |
| 1 | 
            +
            # -*- coding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ##########################################################################################
         | 
| 4 | 
            +
            # @author Rodrigo Botafogo
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            # Copyright © 2015 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify, 
         | 
| 7 | 
            +
            # and distribute this software and its documentation, without fee and without a signed 
         | 
| 8 | 
            +
            # licensing agreement, is hereby granted, provided that the above copyright notice, this 
         | 
| 9 | 
            +
            # paragraph and the following two paragraphs appear in all copies, modifications, and 
         | 
| 10 | 
            +
            # distributions.
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, 
         | 
| 13 | 
            +
            # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF 
         | 
| 14 | 
            +
            # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE 
         | 
| 15 | 
            +
            # POSSIBILITY OF SUCH DAMAGE.
         | 
| 16 | 
            +
            #
         | 
| 17 | 
            +
            # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
         | 
| 18 | 
            +
            # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 
         | 
| 19 | 
            +
            # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". 
         | 
| 20 | 
            +
            # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 
         | 
| 21 | 
            +
            # OR MODIFICATIONS.
         | 
| 22 | 
            +
            ##########################################################################################
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            require 'bigdecimal'
         | 
| 25 | 
            +
            require_relative 'locale'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            class Jcsv
         | 
| 28 | 
            +
              include_package "org.supercsv.cellprocessor"
         | 
| 29 | 
            +
              include_package "org.supercsv.cellprocessor.constraint"
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              #========================================================================================
         | 
| 32 | 
            +
              #
         | 
| 33 | 
            +
              #========================================================================================
         | 
| 34 | 
            +
              
         | 
| 35 | 
            +
              class RBParseHTTPDate < Filter
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                def initialize(start)
         | 
| 38 | 
            +
                  @start = start
         | 
| 39 | 
            +
                  super()
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
                def execute(value, context)
         | 
| 43 | 
            +
                  validateInputNotNull(value, context)
         | 
| 44 | 
            +
                  exec_next(DateTime.httpdate(value, @start), context)
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
              
         | 
| 49 | 
            +
              #========================================================================================
         | 
| 50 | 
            +
              #
         | 
| 51 | 
            +
              #========================================================================================
         | 
| 52 | 
            +
              
         | 
| 53 | 
            +
              class RBParseISO8601 < Filter
         | 
| 54 | 
            +
                
         | 
| 55 | 
            +
                def initialize(start)
         | 
| 56 | 
            +
                  @start = start
         | 
| 57 | 
            +
                  super()
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
                
         | 
| 60 | 
            +
                def execute(value, context)
         | 
| 61 | 
            +
                  validateInputNotNull(value, context)
         | 
| 62 | 
            +
                  exec_next(DateTime.iso8601(value, @start), context)
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              #========================================================================================
         | 
| 68 | 
            +
              #
         | 
| 69 | 
            +
              #========================================================================================
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              class RBParseJD < Filter
         | 
| 72 | 
            +
                    
         | 
| 73 | 
            +
                def execute(value, context)
         | 
| 74 | 
            +
                  validateInputNotNull(value, context)
         | 
| 75 | 
            +
                  exec_next(DateTime.jd(value), context)
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
              #========================================================================================
         | 
| 81 | 
            +
              #
         | 
| 82 | 
            +
              #========================================================================================
         | 
| 83 | 
            +
             | 
| 84 | 
            +
              class RBParseJisx0301 < Filter
         | 
| 85 | 
            +
                
         | 
| 86 | 
            +
                def initialize(start)
         | 
| 87 | 
            +
                  @start = start
         | 
| 88 | 
            +
                  super()
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
                
         | 
| 91 | 
            +
                def execute(value, context)
         | 
| 92 | 
            +
                  validateInputNotNull(value, context)
         | 
| 93 | 
            +
                  exec_next(DateTime.jisx0301(value, @start), context)
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              #========================================================================================
         | 
| 99 | 
            +
              #
         | 
| 100 | 
            +
              #========================================================================================
         | 
| 101 | 
            +
             | 
| 102 | 
            +
              class RBParseDate < Filter
         | 
| 103 | 
            +
                
         | 
| 104 | 
            +
                def initialize(start, next_filter: nil)
         | 
| 105 | 
            +
                  @start = start
         | 
| 106 | 
            +
                  super()
         | 
| 107 | 
            +
                end
         | 
| 108 | 
            +
                
         | 
| 109 | 
            +
                def execute(value, context)
         | 
| 110 | 
            +
                  validateInputNotNull(value, context)
         | 
| 111 | 
            +
                  exec_next(DateTime.parse(value, @start), context)
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
              end
         | 
| 115 | 
            +
              
         | 
| 116 | 
            +
              #========================================================================================
         | 
| 117 | 
            +
              #
         | 
| 118 | 
            +
              #========================================================================================
         | 
| 119 | 
            +
             | 
| 120 | 
            +
              class RBParseRFC2822 < Filter
         | 
| 121 | 
            +
                
         | 
| 122 | 
            +
                def initialize(start)
         | 
| 123 | 
            +
                  @start = start
         | 
| 124 | 
            +
                  super()
         | 
| 125 | 
            +
                end
         | 
| 126 | 
            +
                
         | 
| 127 | 
            +
                def execute(value, context)
         | 
| 128 | 
            +
                  validateInputNotNull(value, context)
         | 
| 129 | 
            +
                  exec_next(DateTime.rfc2822(value, @start), context)
         | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
              end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
              #========================================================================================
         | 
| 135 | 
            +
              #
         | 
| 136 | 
            +
              #========================================================================================
         | 
| 137 | 
            +
             | 
| 138 | 
            +
              class RBParseRFC3339 < Filter
         | 
| 139 | 
            +
                
         | 
| 140 | 
            +
                def initialize(start)
         | 
| 141 | 
            +
                  @start = start
         | 
| 142 | 
            +
                  super()
         | 
| 143 | 
            +
                end
         | 
| 144 | 
            +
                
         | 
| 145 | 
            +
                def execute(value, context)
         | 
| 146 | 
            +
                  validateInputNotNull(value, context)
         | 
| 147 | 
            +
                  exec_next(DateTime.rfc3339(value, @start), context)
         | 
| 148 | 
            +
                end
         | 
| 149 | 
            +
             | 
| 150 | 
            +
              end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
              #========================================================================================
         | 
| 153 | 
            +
              #
         | 
| 154 | 
            +
              #========================================================================================
         | 
| 155 | 
            +
             | 
| 156 | 
            +
              class RBParseRFC822 < Filter
         | 
| 157 | 
            +
                include NextFilter
         | 
| 158 | 
            +
                
         | 
| 159 | 
            +
                def initialize(start)
         | 
| 160 | 
            +
                  @start = start
         | 
| 161 | 
            +
                  super()
         | 
| 162 | 
            +
                end
         | 
| 163 | 
            +
                
         | 
| 164 | 
            +
                def execute(value, context)
         | 
| 165 | 
            +
                  validateInputNotNull(value, context)
         | 
| 166 | 
            +
                  exec_next(DateTime.rfc822(value, @start), context)
         | 
| 167 | 
            +
                end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
              end
         | 
| 170 | 
            +
             | 
| 171 | 
            +
              #========================================================================================
         | 
| 172 | 
            +
              #
         | 
| 173 | 
            +
              #========================================================================================
         | 
| 174 | 
            +
             | 
| 175 | 
            +
              class RBParseStrptime < Filter
         | 
| 176 | 
            +
                
         | 
| 177 | 
            +
                def initialize(format, start)
         | 
| 178 | 
            +
                  @format = format
         | 
| 179 | 
            +
                  @start = start
         | 
| 180 | 
            +
                  super()
         | 
| 181 | 
            +
                end
         | 
| 182 | 
            +
                
         | 
| 183 | 
            +
                def execute(value, context)
         | 
| 184 | 
            +
                  validateInputNotNull(value, context)
         | 
| 185 | 
            +
                  exec_next(DateTime.strptime(value, @format, @start), context)
         | 
| 186 | 
            +
                end
         | 
| 187 | 
            +
             | 
| 188 | 
            +
              end
         | 
| 189 | 
            +
             | 
| 190 | 
            +
              #========================================================================================
         | 
| 191 | 
            +
              #
         | 
| 192 | 
            +
              #========================================================================================
         | 
| 193 | 
            +
             | 
| 194 | 
            +
              class RBParseXmlSchema < Filter
         | 
| 195 | 
            +
                
         | 
| 196 | 
            +
                def initialize(start)
         | 
| 197 | 
            +
                  @start = start
         | 
| 198 | 
            +
                  super()
         | 
| 199 | 
            +
                end
         | 
| 200 | 
            +
                
         | 
| 201 | 
            +
                def execute(value, context)
         | 
| 202 | 
            +
                  validateInputNotNull(value, context)
         | 
| 203 | 
            +
                  exec_next(DateTime.xmlschema(value, @start), context)
         | 
| 204 | 
            +
                end
         | 
| 205 | 
            +
             | 
| 206 | 
            +
              end
         | 
| 207 | 
            +
             | 
| 208 | 
            +
              #========================================================================================
         | 
| 209 | 
            +
              #
         | 
| 210 | 
            +
              #========================================================================================
         | 
| 211 | 
            +
              
         | 
| 212 | 
            +
              def self.httpdate(start = Date::ITALY)
         | 
| 213 | 
            +
                Jcsv::RBParseHTTPDate.new(start)
         | 
| 214 | 
            +
              end
         | 
| 215 | 
            +
             | 
| 216 | 
            +
              def self.iso8601(start = Date::ITALY)
         | 
| 217 | 
            +
                Jcsv::RBParseISO8601.new(start)
         | 
| 218 | 
            +
              end
         | 
| 219 | 
            +
             | 
| 220 | 
            +
              def self.jd
         | 
| 221 | 
            +
                Jcsv::RBParseJD.new
         | 
| 222 | 
            +
              end
         | 
| 223 | 
            +
             | 
| 224 | 
            +
              def self.jisx0301(start = Date::ITALY)
         | 
| 225 | 
            +
                Jcsv::RBParseJisx0301.new(start)
         | 
| 226 | 
            +
              end
         | 
| 227 | 
            +
             | 
| 228 | 
            +
              def self.date(start = Date::ITALY)
         | 
| 229 | 
            +
                Jcsv::RBParseDate.new(start)
         | 
| 230 | 
            +
              end
         | 
| 231 | 
            +
             | 
| 232 | 
            +
              def self.rfc2822(start = Date::ITALY)
         | 
| 233 | 
            +
                Jcsv::RBParseRFC2822.new(start)
         | 
| 234 | 
            +
              end
         | 
| 235 | 
            +
              
         | 
| 236 | 
            +
              def self.rfc3339(start = Date::ITALY)
         | 
| 237 | 
            +
                Jcsv::RBParseRFC3339.new(start)
         | 
| 238 | 
            +
              end
         | 
| 239 | 
            +
             | 
| 240 | 
            +
              def self.rfc822(start = Date::ITALY)
         | 
| 241 | 
            +
                Jcsv::RBParseRFC822.new(start)
         | 
| 242 | 
            +
              end
         | 
| 243 | 
            +
             | 
| 244 | 
            +
              def self.strptime(format, start = Date::ITALY)
         | 
| 245 | 
            +
                Jcsv::RBParseStrptime.new(format, start)
         | 
| 246 | 
            +
              end
         | 
| 247 | 
            +
             | 
| 248 | 
            +
              def self.xmlschema(start = Date::ITALY)
         | 
| 249 | 
            +
                Jcsv::RBParseXmlSchema.new(start)
         | 
| 250 | 
            +
              end
         | 
| 251 | 
            +
             | 
| 252 | 
            +
            end
         |