rdoba 0.9.1 → 0.9.4
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 -7
- data/.gitignore +4 -0
- data/.travis.yml +28 -0
- data/CHANGES.md +6 -0
- data/Gemfile +5 -0
- data/README.md +87 -108
- data/Rakefile +62 -54
- data/TODO +6 -0
- data/features/mixin.feature +85 -0
- data/features/step_definitions/mixin_steps.rb +305 -0
- data/features/support/env.rb +35 -145
- data/features/support/mixin_support.rb +17 -0
- data/html/.keep +0 -0
- data/lib/rdoba/_version_.rb +3 -1
- data/lib/rdoba/a.rb +44 -42
- data/lib/rdoba/bcd.rb +43 -26
- data/lib/rdoba/blank.rb +14 -0
- data/lib/rdoba/combinations.rb +17 -15
- data/lib/rdoba/common.rb +53 -68
- data/lib/rdoba/debug.rb +9 -3
- data/lib/rdoba/deploy.rb +55 -50
- data/lib/rdoba/dup.rb +31 -31
- data/lib/rdoba/fe.rb +6 -5
- data/lib/rdoba/gem.rb +33 -29
- data/lib/rdoba/hashorder.rb +24 -24
- data/lib/rdoba/io.rb +81 -74
- data/lib/rdoba/merge.rb +21 -0
- data/lib/rdoba/mixin/time.rb +17 -0
- data/lib/rdoba/mixin/try.rb +11 -0
- data/lib/rdoba/mixin/try_1_9_0.rb +9 -0
- data/lib/rdoba/mixin/wait_if.rb +27 -0
- data/lib/rdoba/mixin.rb +373 -52
- data/lib/rdoba/numeric.rb +19 -17
- data/lib/rdoba/os.rb +127 -0
- data/lib/rdoba/re.rb +4 -4
- data/lib/rdoba/require.rb +24 -19
- data/lib/rdoba/roman.rb +32 -22
- data/lib/rdoba/strings.rb +6 -144
- data/lib/rdoba/yaml.rb +20 -18
- data/lib/rdoba.rb +50 -47
- data/rdoba.gemspec +33 -26
- data/tddium.yml +11 -0
- metadata +184 -77
- data/features/bcd.feature +0 -29
- data/features/log.feature +0 -206
- data/features/step_definitions/bcd_steps.rb +0 -69
- data/features/step_definitions/log_steps.rb +0 -164
- data/lib/rdoba/log.rb +0 -248
- data/test/helper.rb +0 -18
- data/test/rdoba_test.rb.stub +0 -59
- data/test/test_rdoba.rb +0 -7
    
        data/lib/rdoba/require.rb
    CHANGED
    
    | @@ -1,56 +1,62 @@ | |
| 1 1 | 
             
            #!/usr/bin/ruby -KU
         | 
| 2 | 
            -
            # | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 3 |  | 
| 4 4 | 
             
            require 'rdoba/common'
         | 
| 5 5 | 
             
            require 'rdoba/debug'
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Kernel
         | 
| 8 | 
            -
            private
         | 
| 8 | 
            +
              private
         | 
| 9 | 
            +
             | 
| 9 10 | 
             
              def require_dir(dir, name)
         | 
| 10 11 | 
             
                dbp11 "[require_dir] <<< dir = #{dir}, name = #{name}"
         | 
| 11 12 | 
             
                begin
         | 
| 12 13 | 
             
                  rdir = File.join(dir, name)
         | 
| 13 14 | 
             
                  return false unless File.directory?(rdir)
         | 
| 15 | 
            +
             | 
| 14 16 | 
             
                  rdir = File.join(dir, name)
         | 
| 15 17 | 
             
                  $: << rdir unless $:.include?(rdir)
         | 
| 16 18 | 
             
                  dbp14 "[require_dir]> Found dir #{rdir}"
         | 
| 17 19 | 
             
                  Dir.foreach(rdir) do |file|
         | 
| 18 20 | 
             
                    next unless file =~ /(.*)\.(rb|so)$/
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                     | 
| 21 | 
            +
             | 
| 22 | 
            +
                    dbp14 "[require_dir]> Loading ... #{Regexp.last_match(1)}"
         | 
| 23 | 
            +
                    require Regexp.last_match(1)
         | 
| 21 24 | 
             
                  end
         | 
| 22 25 | 
             
                  true
         | 
| 23 | 
            -
                rescue
         | 
| 26 | 
            +
                rescue StandardError
         | 
| 24 27 | 
             
                  false
         | 
| 25 28 | 
             
                end
         | 
| 26 29 | 
             
              end
         | 
| 27 30 |  | 
| 28 31 | 
             
              def sub_require(name)
         | 
| 29 32 | 
             
                dbp11 "[sub_require] <<< name = #{name} "
         | 
| 30 | 
            -
                 | 
| 31 | 
            -
                   | 
| 32 | 
            -
                     | 
| 33 | 
            -
                       | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 33 | 
            +
                unless $".include?(name)
         | 
| 34 | 
            +
                  $:.each do |dir|
         | 
| 35 | 
            +
                    begin
         | 
| 36 | 
            +
                      Dir.foreach(dir) do |file|
         | 
| 37 | 
            +
                        next unless /^#{name}\.(rb|so)$/.match?(file)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                        dbp14 "[sub_require]> Require Dir #{dir}/#{name} for #{file}"
         | 
| 40 | 
            +
                        r1 = require_dir(dir, name + '.modules')
         | 
| 41 | 
            +
                        r2 = require_dir(dir, name)
         | 
| 42 | 
            +
                        dbp14 "[sub_require]> Require Dir #{(r1 || r2) && 'passed' || 'failed'} ... #{name}"
         | 
| 43 | 
            +
                      end
         | 
| 44 | 
            +
                    rescue StandardError
         | 
| 38 45 | 
             
                    end
         | 
| 39 | 
            -
                  rescue
         | 
| 40 46 | 
             
                  end
         | 
| 41 | 
            -
                end | 
| 47 | 
            +
                end
         | 
| 42 48 | 
             
                true
         | 
| 43 49 | 
             
              end
         | 
| 44 50 |  | 
| 45 | 
            -
            public
         | 
| 51 | 
            +
              public
         | 
| 46 52 |  | 
| 47 | 
            -
              alias  | 
| 53 | 
            +
              alias __require__ require
         | 
| 48 54 | 
             
              def require(name, *opts)
         | 
| 49 55 | 
             
                v = parse_opts(opts)
         | 
| 50 56 | 
             
                dbp11 "[require] <<< name = #{name}"
         | 
| 51 57 | 
             
                begin
         | 
| 52 58 | 
             
                  res = __require__ name
         | 
| 53 | 
            -
                rescue =>  | 
| 59 | 
            +
                rescue StandardError => e
         | 
| 54 60 | 
             
                  puts "Lib internal error: #{$!.class} -> #{$!}\n\t#{$@.join("\n\t")}"
         | 
| 55 61 | 
             
                  exit
         | 
| 56 62 | 
             
                end
         | 
| @@ -59,4 +65,3 @@ public | |
| 59 65 | 
             
                res
         | 
| 60 66 | 
             
              end
         | 
| 61 67 | 
             
            end
         | 
| 62 | 
            -
             | 
    
        data/lib/rdoba/roman.rb
    CHANGED
    
    | @@ -1,45 +1,55 @@ | |
| 1 1 | 
             
            #!/usr/bin/ruby -KU
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 2 3 |  | 
| 3 4 | 
             
            class Numeric
         | 
| 4 | 
            -
              Roman = { | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 5 | 
            +
              Roman = {
         | 
| 6 | 
            +
                1 => 'I',
         | 
| 7 | 
            +
                4 => 'IV',
         | 
| 8 | 
            +
                5 => 'V',
         | 
| 9 | 
            +
                9 => 'IX',
         | 
| 10 | 
            +
                10 => 'X',
         | 
| 11 | 
            +
                40 => 'XL',
         | 
| 12 | 
            +
                50 => 'L',
         | 
| 13 | 
            +
                90 => 'XC',
         | 
| 14 | 
            +
                100 => 'C',
         | 
| 15 | 
            +
                400 => 'CD',
         | 
| 16 | 
            +
                500 => 'D',
         | 
| 17 | 
            +
                900 => 'CM',
         | 
| 18 | 
            +
                1000 => 'M'
         | 
| 19 | 
            +
              }
         | 
| 20 | 
            +
              RomanNumbers = Roman.keys.sort
         | 
| 21 | 
            +
              RomanToInteger = Roman.invert
         | 
| 22 | 
            +
              RomanDigits = RomanToInteger.keys.sort { |x, y| x.size < y.size ? 1 : x.size > y.size ? -1 : x <=> y }
         | 
| 7 23 |  | 
| 8 24 | 
             
              def to_rom
         | 
| 9 25 | 
             
                res = ''
         | 
| 10 26 | 
             
                num = self
         | 
| 11 | 
            -
                i =  | 
| 27 | 
            +
                i = RomanNumbers.size - 1
         | 
| 12 28 |  | 
| 13 29 | 
             
                while num > 0
         | 
| 14 | 
            -
                  if num >=  | 
| 15 | 
            -
                    res << Roman[ | 
| 16 | 
            -
                    num -=  | 
| 30 | 
            +
                  if num >= RomanNumbers[i]
         | 
| 31 | 
            +
                    res << Roman[RomanNumbers[i]]
         | 
| 32 | 
            +
                    num -= RomanNumbers[i]
         | 
| 17 33 | 
             
                  else
         | 
| 18 34 | 
             
                    i -= 1
         | 
| 19 35 | 
             
                  end
         | 
| 20 36 | 
             
                end
         | 
| 21 37 | 
             
                res
         | 
| 22 38 | 
             
              end
         | 
| 23 | 
            -
             | 
| 24 39 | 
             
            end
         | 
| 25 40 |  | 
| 26 41 | 
             
            class String
         | 
| 42 | 
            +
              RomanRe = /(#{Numeric::RomanDigits.join('|')})/
         | 
| 43 | 
            +
             | 
| 27 44 | 
             
              def rom
         | 
| 28 | 
            -
                 | 
| 29 | 
            -
                 | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
                while str and not str.empty?
         | 
| 33 | 
            -
                raise "Invalid roman number" if (keys.each do |key|
         | 
| 34 | 
            -
                  if str =~ /^#{key}(.*)/
         | 
| 35 | 
            -
                    str = $1
         | 
| 36 | 
            -
                    res += h[key]
         | 
| 37 | 
            -
                    break nil
         | 
| 45 | 
            +
                numbers = upcase.scan(RomanRe).flatten.map { |x| Numeric::RomanToInteger[x] }
         | 
| 46 | 
            +
                numbers.sort do |x, y|
         | 
| 47 | 
            +
                  if x < y
         | 
| 48 | 
            +
                    raise 'Invalid roman number'
         | 
| 38 49 | 
             
                  end
         | 
| 39 | 
            -
             | 
| 50 | 
            +
             | 
| 51 | 
            +
                  0
         | 
| 40 52 | 
             
                end
         | 
| 41 | 
            -
                 | 
| 53 | 
            +
                numbers.sum
         | 
| 42 54 | 
             
              end
         | 
| 43 55 | 
             
            end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
    
        data/lib/rdoba/strings.rb
    CHANGED
    
    | @@ -1,149 +1,11 @@ | |
| 1 1 | 
             
            #!/usr/bin/ruby -KU
         | 
| 2 | 
            -
            # | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 3 |  | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
              def self.upcase(char)
         | 
| 7 | 
            -
                  chr = char.class == String ? char.ord : char.to_i
         | 
| 8 | 
            -
                  if chr >= 0x430 and chr < 0x450
         | 
| 9 | 
            -
                    chr -= 0x20
         | 
| 10 | 
            -
                  elsif chr >= 0x410 and chr < 0x430
         | 
| 11 | 
            -
                  elsif chr >= 0x400 and chr < 0x410 or
         | 
| 12 | 
            -
                      chr >= 0x450 and chr < 0x482 or
         | 
| 13 | 
            -
                      chr >= 0x48A and chr < 0x524 or
         | 
| 14 | 
            -
                      chr >= 0xA642 and chr < 0xA668 or
         | 
| 15 | 
            -
                      chr >= 0xA680 and chr < 0xA698
         | 
| 16 | 
            -
                    chr -= 1 if (chr % 1) == 1
         | 
| 17 | 
            -
                  else
         | 
| 18 | 
            -
                    return chr.chr.__upcase__
         | 
| 19 | 
            -
                  end
         | 
| 20 | 
            -
                  chr.chr
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              def self.downcase(char)
         | 
| 24 | 
            -
                  chr = (char.class == String) ? char.ord : char.to_i
         | 
| 25 | 
            -
                  if chr >= 0x410 and chr < 0x430
         | 
| 26 | 
            -
                    chr += 0x20
         | 
| 27 | 
            -
                  elsif chr >= 0x430 and chr < 0x450
         | 
| 28 | 
            -
                  elsif chr >= 0x400 and chr < 0x410 or
         | 
| 29 | 
            -
                      chr >= 0x450 and chr < 0x482 or
         | 
| 30 | 
            -
                      chr >= 0x48A and chr < 0x524 or
         | 
| 31 | 
            -
                      chr >= 0xA642 and chr < 0xA668 or
         | 
| 32 | 
            -
                      chr >= 0xA680 and chr < 0xA698
         | 
| 33 | 
            -
                    chr += 1 if (chr % 1) == 0
         | 
| 34 | 
            -
                  else
         | 
| 35 | 
            -
                    return chr.chr.__downcase__
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
                  chr.chr
         | 
| 38 | 
            -
              end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
              if RUBY_VERSION < '1.9'
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                alias :setbyte :[]=
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                def encoding
         | 
| 45 | 
            -
                  'UTF-8'
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                def force_encoding(*args)
         | 
| 49 | 
            -
                  self
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                def ord
         | 
| 53 | 
            -
                  a = nil
         | 
| 54 | 
            -
                  self.each_byte do |b|
         | 
| 55 | 
            -
            	c = b & 0xC0
         | 
| 56 | 
            -
            	case c
         | 
| 57 | 
            -
            	when 0xc0
         | 
| 58 | 
            -
            	  a = (b & 0x3F)
         | 
| 59 | 
            -
            	when 0x80
         | 
| 60 | 
            -
            	  return (a << 6) + (b & 0x3F)
         | 
| 61 | 
            -
            	else
         | 
| 62 | 
            -
            	  return b
         | 
| 63 | 
            -
            	end
         | 
| 64 | 
            -
                  end
         | 
| 65 | 
            -
                end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
              end
         | 
| 4 | 
            +
            warn "Warning: the module 'string' has kept only for backward " \
         | 
| 5 | 
            +
                   "compatibility\nPlease use 'rdoba :mixin' form instead"
         | 
| 68 6 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
              alias  | 
| 71 | 
            -
              def upcase(option = nil)
         | 
| 72 | 
            -
                if option == FirstChar
         | 
| 73 | 
            -
                  r = self.dup
         | 
| 74 | 
            -
                  r[0] = String.upcase(self.ord)
         | 
| 75 | 
            -
                  r
         | 
| 76 | 
            -
                elsif self.match(/[Ѐ-ҁҊ-ԣꙀ-ꙧꚀꚗ]/u)
         | 
| 77 | 
            -
                  self.unpack('U*').map do |chr| String.upcase(chr) end.join
         | 
| 78 | 
            -
                else; __upcase__ end
         | 
| 79 | 
            -
              end
         | 
| 80 | 
            -
             | 
| 81 | 
            -
              alias :__downcase__ :downcase
         | 
| 82 | 
            -
              def downcase(option = nil)
         | 
| 83 | 
            -
                if option == FirstChar
         | 
| 84 | 
            -
                  r = self.dup
         | 
| 85 | 
            -
                  r[0] = String.downcase(self.ord)
         | 
| 86 | 
            -
                  r
         | 
| 87 | 
            -
                elsif self.match(/[Ѐ-ҁҊ-ԣꙀ-ꙧꚀꚗ]/u)
         | 
| 88 | 
            -
                  self.unpack('U*').map do |chr| String.downcase(chr) end.join
         | 
| 89 | 
            -
                else; __downcase__ end
         | 
| 90 | 
            -
              end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
              alias :to_p :to_s
         | 
| 93 | 
            -
             | 
| 94 | 
            -
              ByteByByte = 0
         | 
| 95 | 
            -
              alias :__reverse__ :reverse
         | 
| 96 | 
            -
              def reverse(step = 1)
         | 
| 97 | 
            -
                  case step
         | 
| 98 | 
            -
                  when ByteByByte
         | 
| 99 | 
            -
                      arr = []
         | 
| 100 | 
            -
                      self.each_byte do |byte| arr << byte.chr end
         | 
| 101 | 
            -
                      arr.reverse.join
         | 
| 102 | 
            -
                  when 1
         | 
| 103 | 
            -
                      __reverse__
         | 
| 104 | 
            -
                  else
         | 
| 105 | 
            -
                      res = ''
         | 
| 106 | 
            -
                      offset = (self.size + 1) / step * step - step
         | 
| 107 | 
            -
                      (0..offset).step(step) do |shift|
         | 
| 108 | 
            -
                          res += self[offset - shift..offset - shift + 1]
         | 
| 109 | 
            -
                      end
         | 
| 110 | 
            -
                      res
         | 
| 111 | 
            -
                  end
         | 
| 112 | 
            -
              end
         | 
| 113 | 
            -
             | 
| 114 | 
            -
              def compare_to(value, opts = {} )
         | 
| 115 | 
            -
                if opts == :ignore_diacritics or
         | 
| 116 | 
            -
                  (opts.class == Hash and opts.key? :ignore_diacritics)
         | 
| 117 | 
            -
                  # TODO verify composite range
         | 
| 118 | 
            -
                  def crop_diacritics(x)
         | 
| 119 | 
            -
                    (x < 0x300 or
         | 
| 120 | 
            -
                       x > 0x36f and x < 0x483 or
         | 
| 121 | 
            -
                       x > 0x487 and x < 0xa67c or
         | 
| 122 | 
            -
                       x > 0xa67d) && x || nil
         | 
| 123 | 
            -
                  end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
                  (self.unpack('U*').map do |x| crop_diacritics(x)
         | 
| 126 | 
            -
                  end.compact) <=> (value.unpack('U*').map do |x| crop_diacritics(x)
         | 
| 127 | 
            -
                  end.compact)
         | 
| 128 | 
            -
                else
         | 
| 129 | 
            -
                  self <=> value
         | 
| 130 | 
            -
                end
         | 
| 131 | 
            -
              end
         | 
| 132 | 
            -
            end
         | 
| 133 | 
            -
             | 
| 134 | 
            -
            class Fixnum
         | 
| 135 | 
            -
              alias :__chr__ :chr
         | 
| 136 | 
            -
              def chr
         | 
| 137 | 
            -
                if self >= 256
         | 
| 138 | 
            -
                  num = self; s = "\0"; byte = 0x80; a = []
         | 
| 139 | 
            -
                  while num >= 0x40
         | 
| 140 | 
            -
            	s.setbyte(0, byte + (num & 0x3F))
         | 
| 141 | 
            -
            	a << s.dup; num >>= 6; byte = 0x40
         | 
| 142 | 
            -
                  end
         | 
| 143 | 
            -
                  s.setbyte(0, 0xC0 + (num & 0x3F))
         | 
| 144 | 
            -
                  a << s
         | 
| 145 | 
            -
                  a.reverse.join.force_encoding('UTF-8')
         | 
| 146 | 
            -
                else; __chr__ end
         | 
| 147 | 
            -
              end
         | 
| 7 | 
            +
            class String
         | 
| 8 | 
            +
              alias to_p to_s
         | 
| 148 9 | 
             
            end
         | 
| 149 10 |  | 
| 11 | 
            +
            rdoba mixin: %i[case reverse compare]
         | 
    
        data/lib/rdoba/yaml.rb
    CHANGED
    
    | @@ -1,48 +1,50 @@ | |
| 1 1 | 
             
            #!/usr/bin/ruby
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 2 3 |  | 
| 3 4 | 
             
            require 'rdoba/common'
         | 
| 4 5 |  | 
| 5 6 | 
             
            class Object
         | 
| 6 | 
            -
              def to_yml( | 
| 7 | 
            +
              def to_yml(o = {})
         | 
| 7 8 | 
             
                level = o[:level] || 0
         | 
| 8 9 | 
             
                res = ''
         | 
| 9 10 | 
             
                res += '---' if level == 0
         | 
| 10 | 
            -
                res += | 
| 11 | 
            +
                res +=
         | 
| 12 | 
            +
                  case self.class.to_sym
         | 
| 11 13 | 
             
                  when :Hash
         | 
| 12 14 | 
             
                    rs = ''
         | 
| 13 | 
            -
                     | 
| 14 | 
            -
                       | 
| 15 | 
            +
                    keys.sort do |x, y|
         | 
| 16 | 
            +
                      ix, iy = o[:order] ? [o[:order].index(x), o[:order].index(y)] : [nil, nil]
         | 
| 15 17 | 
             
                      (ix and iy) ? ix <=> iy : (ix ? -1 : (iy ? 1 : x <=> y))
         | 
| 16 18 | 
             
                    end.each do |key|
         | 
| 17 19 | 
             
                      value = self[key]
         | 
| 18 | 
            -
                      rs += "\n" + ' ' * level * 2 + key.to_yml( | 
| 19 | 
            -
                      rs += ': ' + value.to_yml( | 
| 20 | 
            +
                      rs += "\n" + ' ' * level * 2 + key.to_yml({ level: level + 1, order: o[:order] })
         | 
| 21 | 
            +
                      rs += ': ' + value.to_yml({ level: level + 1, order: o[:order] })
         | 
| 20 22 | 
             
                    end
         | 
| 21 | 
            -
                    rs.empty? and  | 
| 23 | 
            +
                    rs.empty? and '{}' or rs
         | 
| 22 24 | 
             
                  when :Array
         | 
| 23 25 | 
             
                    rs = ''
         | 
| 24 | 
            -
                     | 
| 25 | 
            -
                      rs += "\n" + ' ' * level * 2 + '- ' + value.to_yml( | 
| 26 | 
            +
                    each do |value|
         | 
| 27 | 
            +
                      rs += "\n" + ' ' * level * 2 + '- ' + value.to_yml({ level: level + 1, order: o[:order] })
         | 
| 26 28 | 
             
                    end
         | 
| 27 | 
            -
                    rs.empty? and  | 
| 29 | 
            +
                    rs.empty? and '[]' or rs
         | 
| 28 30 | 
             
                  when :Fixnum
         | 
| 29 | 
            -
                     | 
| 31 | 
            +
                    to_s
         | 
| 30 32 | 
             
                  when :String
         | 
| 31 33 | 
             
                    if self =~ /^["'\-:!#={}\[\]~]/ or self =~ /\s+$/ or self =~ /:\s/
         | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 34 | 
            +
                      if count("'") < count('"')
         | 
| 35 | 
            +
                        "'#{gsub("'", "\\'")}'"
         | 
| 36 | 
            +
                      else
         | 
| 37 | 
            +
                        "\"#{gsub('"', '\"')}\""
         | 
| 38 | 
            +
                      end
         | 
| 37 39 | 
             
                    else
         | 
| 38 40 | 
             
                      self
         | 
| 39 41 | 
             
                    end
         | 
| 40 42 | 
             
                  when :NilClass
         | 
| 41 43 | 
             
                    ''
         | 
| 42 44 | 
             
                  else
         | 
| 43 | 
            -
             | 
| 45 | 
            +
                    warn "Unsupported class #{self.class} to export to yml"
         | 
| 46 | 
            +
                    ''
         | 
| 44 47 | 
             
                  end
         | 
| 45 48 | 
             
                res
         | 
| 46 49 | 
             
              end
         | 
| 47 50 | 
             
            end
         | 
| 48 | 
            -
             | 
    
        data/lib/rdoba.rb
    CHANGED
    
    | @@ -1,57 +1,60 @@ | |
| 1 | 
            -
            # | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Kernel
         | 
| 4 | 
            -
              Modules = [ | 
| 4 | 
            +
              Modules = %i[bcd mixin log debug]
         | 
| 5 5 |  | 
| 6 | 
            -
              def rdoba | 
| 6 | 
            +
              def rdoba(*options)
         | 
| 7 7 | 
             
                options.each do |option|
         | 
| 8 | 
            -
                   | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
                  case key
         | 
| 12 | 
            -
                  when :mixin
         | 
| 13 | 
            -
                    require "rdoba/mixin"
         | 
| 14 | 
            -
                    Rdoba.mixin value
         | 
| 15 | 
            -
                  when :log, :debug
         | 
| 8 | 
            +
                  (option.is_a?(Hash) && option || { option.to_s.to_sym => {} }).each_pair do |key, value|
         | 
| 9 | 
            +
                    next unless Modules.include? key
         | 
| 10 | 
            +
             | 
| 16 11 | 
             
                    require "rdoba/#{key}"
         | 
| 17 | 
            -
                     | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
                     | 
| 22 | 
            -
             | 
| 23 | 
            -
                     | 
| 12 | 
            +
                    next unless Rdoba.methods.include? key
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                    unless value.is_a? Hash
         | 
| 15 | 
            +
                      value = { value: value }
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                    value.replace({ self: self }.merge(value))
         | 
| 18 | 
            +
                    Rdoba.send key, value
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| 24 23 |  | 
| 25 24 | 
             
            require 'rbconfig'
         | 
| 26 25 |  | 
| 27 26 | 
             
            module Rdoba
         | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
                  @@os ||= (
         | 
| 37 | 
            -
                     host_os = RbConfig::CONFIG['host_os']
         | 
| 38 | 
            -
                     case host_os
         | 
| 39 | 
            -
                     when /(mswin|msys|mingw|cygwin|bccwin|wince|emc)/
         | 
| 40 | 
            -
                        plat = $1 == 'mswin' && 'native' || $1
         | 
| 41 | 
            -
                        out = `ver`.encode( 'US-ASCII',
         | 
| 42 | 
            -
                              :invalid => :replace, :undef => :replace )
         | 
| 43 | 
            -
                        if out =~ /\[.* (\d+)\.([\d\.]+)\]/
         | 
| 44 | 
            -
                           "windows-#{plat}-#{$1 == '5' && 'xp' || 'vista'}-#{$1}.#{$2}"
         | 
| 45 | 
            -
                        else
         | 
| 46 | 
            -
                           "windows-#{plat}" ; end
         | 
| 47 | 
            -
                     when /darwin|mac os/
         | 
| 48 | 
            -
                        'macosx'
         | 
| 49 | 
            -
                     when /linux/
         | 
| 50 | 
            -
                        'linux'
         | 
| 51 | 
            -
                     when /(solaris|bsd)/
         | 
| 52 | 
            -
                        "unix-#{$1}"
         | 
| 53 | 
            -
                     else
         | 
| 54 | 
            -
                        raise "unknown os: #{host_os.inspect}"
         | 
| 55 | 
            -
                     end)
         | 
| 56 | 
            -
               end ; end
         | 
| 27 | 
            +
              def self.gemroot(name = nil, path = '')
         | 
| 28 | 
            +
                unless gem(name)
         | 
| 29 | 
            +
                  raise "Invalid gem named as #{name.inspect}"
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                g = Gem::Specification.find_by_name(name)
         | 
| 33 | 
            +
                File.join g.full_gem_path, path
         | 
| 34 | 
            +
              end
         | 
| 57 35 |  | 
| 36 | 
            +
              def self.os
         | 
| 37 | 
            +
                @@os ||=
         | 
| 38 | 
            +
                  begin
         | 
| 39 | 
            +
                    host_os = RbConfig::CONFIG['host_os']
         | 
| 40 | 
            +
                    case host_os
         | 
| 41 | 
            +
                    when /(mswin|msys|mingw|cygwin|bccwin|wince|emc)/
         | 
| 42 | 
            +
                      plat = Regexp.last_match(1) == 'mswin' && 'native' || Regexp.last_match(1)
         | 
| 43 | 
            +
                      out = `ver`.encode('US-ASCII', invalid: :replace, undef: :replace)
         | 
| 44 | 
            +
                      if out =~ /\[.* (\d+)\.([\d.]+)\]/
         | 
| 45 | 
            +
                        "windows-#{plat}-#{Regexp.last_match(1) == '5' && 'xp' || 'vista'}-#{Regexp.last_match(1)}.#{Regexp.last_match(2)}"
         | 
| 46 | 
            +
                      else
         | 
| 47 | 
            +
                        "windows-#{plat}"
         | 
| 48 | 
            +
                      end
         | 
| 49 | 
            +
                    when /darwin|mac os/
         | 
| 50 | 
            +
                      'macosx'
         | 
| 51 | 
            +
                    when /linux/
         | 
| 52 | 
            +
                      'linux'
         | 
| 53 | 
            +
                    when /(solaris|bsd)/
         | 
| 54 | 
            +
                      "unix-#{Regexp.last_match(1)}"
         | 
| 55 | 
            +
                    else
         | 
| 56 | 
            +
                      raise "unknown os: #{host_os.inspect}"
         | 
| 57 | 
            +
                    end
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
    
        data/rdoba.gemspec
    CHANGED
    
    | @@ -1,32 +1,39 @@ | |
| 1 | 
            -
            #  | 
| 2 | 
            -
             | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            $:.push File.expand_path('lib', __dir__)
         | 
| 3 4 | 
             
            require "rdoba/_version_"
         | 
| 4 5 |  | 
| 5 6 | 
             
            Gem::Specification.new do |s|
         | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 7 | 
            +
               s.name         = "rdoba"
         | 
| 8 | 
            +
               s.version      = Rdoba::VERSION
         | 
| 9 | 
            +
               s.platform     = Gem::Platform::RUBY
         | 
| 10 | 
            +
               s.authors      = [ 'Малъ Скрылёвъ (Malo Skrylevo)' ]
         | 
| 11 | 
            +
               s.email        = [ '3aHyga@gmail.com' ]
         | 
| 12 | 
            +
               s.homepage     = 'https://github.com/3aHyga/rdoba'
         | 
| 13 | 
            +
               s.summary      = 'Ruby extension library (Ruby DOBAvka)'
         | 
| 14 | 
            +
               s.description  = 'Ruby extension library. It extends Kernel, Object, '       \
         | 
| 15 | 
            +
                                'String, Hash, Array, and some other classes. Also allows ' \
         | 
| 16 | 
            +
                                'to log application state with debug lines to an io'
         | 
| 17 | 
            +
               s.license      = 'MIT'
         | 
| 17 18 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 19 | 
            +
               s.rubyforge_project = "rdoba"
         | 
| 20 | 
            +
               s.files             = `git ls-files`.split("\n")
         | 
| 21 | 
            +
               s.test_files        = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 22 | 
            +
               s.executables       = `git ls-files -- bin/*`.split( "\n" ).map{ |f| File.basename(f) }
         | 
| 23 | 
            +
               s.require_paths     = [ "lib" ]
         | 
| 24 | 
            +
               s.extra_rdoc_files  = [ 'README.md', 'LICENSE', 'CHANGES.md' ] |
         | 
| 25 | 
            +
                                    `find html/`.split( "\n" )
         | 
| 24 26 |  | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            +
               s.add_development_dependency 'bundler', '~> 2.0'
         | 
| 28 | 
            +
               s.add_development_dependency 'coveralls'
         | 
| 29 | 
            +
               s.add_development_dependency 'cucumber', '~> 1.3'
         | 
| 30 | 
            +
               s.add_development_dependency 'ffi-stat', '~> 0.4'
         | 
| 31 | 
            +
               s.add_development_dependency 'rake', '~> 12.0', '>= 12.3.3'
         | 
| 32 | 
            +
               s.add_development_dependency 'rdiscount', '~> 2.1'
         | 
| 33 | 
            +
               s.add_development_dependency 'rdoc', '~> 6.2'
         | 
| 34 | 
            +
               s.add_development_dependency 'rspec-expectations', '~> 3.3'
         | 
| 35 | 
            +
               s.add_development_dependency 'simplecov', '~> 0'
         | 
| 36 | 
            +
               s.add_development_dependency 'tddium', '~> 1.25'
         | 
| 27 37 |  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
              s.add_development_dependency 'cucumber', '~> 1.3'
         | 
| 31 | 
            -
              s.add_development_dependency 'coveralls'
         | 
| 32 | 
            -
            end
         | 
| 38 | 
            +
               s.required_rubygems_version = '>= 1.6.0'
         | 
| 39 | 
            +
               s.required_ruby_version = '>= 1.9.0' ; end
         |