dbf 3.1.1 → 3.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a8b06626d3eb46fa746bd21d8b359c099dec90b2
4
- data.tar.gz: e1da4bd35cc876d257552581d1d41079d55fc15c
2
+ SHA256:
3
+ metadata.gz: 2701f07f7f1de7cf433af7589ddab5e0d63d465735e1bf6e3856ab26246cb40b
4
+ data.tar.gz: 788b16069d991e4a0d56fa776d8a52911d3acbc7c32c583e20651977d1189b63
5
5
  SHA512:
6
- metadata.gz: 1496225ad7fbbc044287627d2a13196e70614d4adbd7467911b51bd4860ce6e35f86c86713c5ec05dbed19a0c956bad80e2906ea8c6541ffd4f6a26764e73304
7
- data.tar.gz: 23f28160bb106378de8e7ffe409ab1db78d31d6c8f380a5a2e21e05f820b48b86030dba346e6d5c461cb292cfbd640c7562ec5a653e29055ea3822166bf97593
6
+ metadata.gz: 8df157ab067bd42bf9dc2b875630e2fcbaa378292cd480bc638c83a0b5aca4001d9fccbc1ab6604dd940d74837b512ea9f997c0f16c9aaf6d8837c1a5fd38eaa
7
+ data.tar.gz: cd9f715b341ac1f696ba0f25183af91a64dda196ae6fbe48f81e595aacdffe677eca01826106b933d2c9abf067dfb570fa57c146f7da0695764e83f0fa3996f4
@@ -1,3 +1,6 @@
1
+ # 3.1.2
2
+ - Fix incorrect columns list when StringIO and encoding set
3
+
1
4
  # 3.1.1
2
5
  - Use Date.strptime to parse date fields
3
6
 
data/Gemfile CHANGED
@@ -2,9 +2,11 @@ gemspec
2
2
  source 'https://rubygems.org'
3
3
 
4
4
  group :development, :test do
5
+ gem 'awesome_print'
5
6
  gem 'byebug'
6
- gem 'rake'
7
- gem 'rspec'
8
7
  gem 'guard'
9
8
  gem 'guard-rspec'
9
+ gem 'rake'
10
+ gem 'rubocop'
11
+ gem 'rspec'
10
12
  end
@@ -1,20 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbf (3.1.1)
4
+ dbf (3.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- byebug (9.0.5)
10
- coderay (1.1.0)
11
- diff-lcs (1.2.5)
12
- ffi (1.9.10)
13
- ffi (1.9.10-java)
9
+ ast (2.3.0)
10
+ awesome_print (1.8.0)
11
+ byebug (9.1.0)
12
+ coderay (1.1.2)
13
+ diff-lcs (1.3)
14
+ ffi (1.9.18)
14
15
  formatador (0.2.5)
15
- guard (2.13.0)
16
+ guard (2.14.1)
16
17
  formatador (>= 0.2.4)
17
- listen (>= 2.7, <= 4.0)
18
+ listen (>= 2.7, < 4.0)
18
19
  lumberjack (~> 1.0)
19
20
  nenv (~> 0.1)
20
21
  notiffany (~> 0.0)
@@ -22,62 +23,71 @@ GEM
22
23
  shellany (~> 0.0)
23
24
  thor (>= 0.18.1)
24
25
  guard-compat (1.2.1)
25
- guard-rspec (4.6.4)
26
+ guard-rspec (4.7.3)
26
27
  guard (~> 2.1)
27
28
  guard-compat (~> 1.1)
28
29
  rspec (>= 2.99.0, < 4.0)
29
- listen (3.0.5)
30
- rb-fsevent (>= 0.9.3)
31
- rb-inotify (>= 0.9)
32
- lumberjack (1.0.9)
33
- method_source (0.8.2)
34
- nenv (0.2.0)
35
- notiffany (0.0.8)
30
+ listen (3.1.5)
31
+ rb-fsevent (~> 0.9, >= 0.9.4)
32
+ rb-inotify (~> 0.9, >= 0.9.7)
33
+ ruby_dep (~> 1.2)
34
+ lumberjack (1.0.12)
35
+ method_source (0.9.0)
36
+ nenv (0.3.0)
37
+ notiffany (0.1.1)
36
38
  nenv (~> 0.1)
37
39
  shellany (~> 0.0)
38
- pry (0.10.3)
40
+ parallel (1.12.0)
41
+ parser (2.4.0.2)
42
+ ast (~> 2.3)
43
+ powerpack (0.1.1)
44
+ pry (0.11.3)
39
45
  coderay (~> 1.1.0)
40
- method_source (~> 0.8.1)
41
- slop (~> 3.4)
42
- pry (0.10.3-java)
43
- coderay (~> 1.1.0)
44
- method_source (~> 0.8.1)
45
- slop (~> 3.4)
46
- spoon (~> 0.0)
47
- rake (11.2.2)
48
- rb-fsevent (0.9.6)
49
- rb-inotify (0.9.5)
50
- ffi (>= 0.5.0)
51
- rspec (3.4.0)
52
- rspec-core (~> 3.4.0)
53
- rspec-expectations (~> 3.4.0)
54
- rspec-mocks (~> 3.4.0)
55
- rspec-core (3.4.1)
56
- rspec-support (~> 3.4.0)
57
- rspec-expectations (3.4.0)
46
+ method_source (~> 0.9.0)
47
+ rainbow (2.2.2)
48
+ rake
49
+ rake (12.3.0)
50
+ rb-fsevent (0.10.2)
51
+ rb-inotify (0.9.10)
52
+ ffi (>= 0.5.0, < 2)
53
+ rspec (3.7.0)
54
+ rspec-core (~> 3.7.0)
55
+ rspec-expectations (~> 3.7.0)
56
+ rspec-mocks (~> 3.7.0)
57
+ rspec-core (3.7.0)
58
+ rspec-support (~> 3.7.0)
59
+ rspec-expectations (3.7.0)
58
60
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.4.0)
60
- rspec-mocks (3.4.0)
61
+ rspec-support (~> 3.7.0)
62
+ rspec-mocks (3.7.0)
61
63
  diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.4.0)
63
- rspec-support (3.4.0)
64
+ rspec-support (~> 3.7.0)
65
+ rspec-support (3.7.0)
66
+ rubocop (0.51.0)
67
+ parallel (~> 1.10)
68
+ parser (>= 2.3.3.1, < 3.0)
69
+ powerpack (~> 0.1)
70
+ rainbow (>= 2.2.2, < 3.0)
71
+ ruby-progressbar (~> 1.7)
72
+ unicode-display_width (~> 1.0, >= 1.0.1)
73
+ ruby-progressbar (1.9.0)
74
+ ruby_dep (1.5.0)
64
75
  shellany (0.0.1)
65
- slop (3.6.0)
66
- spoon (0.0.4)
67
- ffi
68
- thor (0.19.1)
76
+ thor (0.20.0)
77
+ unicode-display_width (1.3.0)
69
78
 
70
79
  PLATFORMS
71
- java
72
80
  ruby
73
81
 
74
82
  DEPENDENCIES
83
+ awesome_print
75
84
  byebug
76
85
  dbf!
77
86
  guard
78
87
  guard-rspec
79
88
  rake
80
89
  rspec
90
+ rubocop
81
91
 
82
92
  BUNDLED WITH
83
- 1.13.7
93
+ 1.16.1
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2017 Keith Morrison <keithm@infused.org>
1
+ Copyright (c) 2006-2018 Keith Morrison <keithm@infused.org>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # DBF
2
2
  [![Version](http://img.shields.io/gem/v/dbf.svg?style=flat)](https://rubygems.org/gems/dbf)
3
3
  [![Build Status](http://img.shields.io/travis/infused/dbf/master.svg?style=flat)](http://travis-ci.org/infused/dbf)
4
- [![Code Quality](http://img.shields.io/codeclimate/github/infused/dbf.svg?style=flat)](https://codeclimate.com/github/infused/dbf)
5
- [![Test Coverage](http://img.shields.io/codeclimate/coverage/github/infused/dbf.svg?style=flat)](https://codeclimate.com/github/infused/dbf)
4
+ [![Code Quality](http://img.shields.io/codeclimate/maintainability/infused/dbf.svg?style=flat)](https://codeclimate.com/github/infused/dbf)
5
+ [![Code Coverage](http://img.shields.io/codeclimate/c/infused/dbf.svg?style=flat)](https://codeclimate.com/github/infused/dbf)
6
6
  [![Dependency Status](http://img.shields.io/gemnasium/infused/dbf.svg?style=flat)](https://gemnasium.com/infused/dbf)
7
7
  [![Total Downloads](https://img.shields.io/gem/dt/dbf.svg)](https://rubygems.org/gems/dbf/)
8
8
 
@@ -22,7 +22,7 @@ NOTE: beginning with version 3 we have dropped support for Ruby 1.8 and 1.9. If
22
22
 
23
23
  DBF is tested to work with the following versions of Ruby:
24
24
 
25
- * MRI Ruby 2.0.x, 2.1.x, 2.2.x, 2.3.x, 2.4.x
25
+ * MRI Ruby 2.0.x, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x
26
26
  * JRuby 1.7.x
27
27
 
28
28
  ## Installation
@@ -272,7 +272,7 @@ for a full list of supported column types.
272
272
 
273
273
  ## License
274
274
 
275
- Copyright (c) 2006-2017 Keith Morrison <<keithm@infused.org>>
275
+ Copyright (c) 2006-2018 Keith Morrison <<keithm@infused.org>>
276
276
 
277
277
  Permission is hereby granted, free of charge, to any person
278
278
  obtaining a copy of this software and associated documentation
data/Rakefile CHANGED
@@ -3,16 +3,16 @@ Bundler.setup(:default, :development)
3
3
 
4
4
  require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new :spec do |t|
6
- t.rspec_opts = %w(--color)
6
+ t.rspec_opts = %w[--color]
7
7
  end
8
8
 
9
9
  RSpec::Core::RakeTask.new :specdoc do |t|
10
- t.rspec_opts = %w(-fl)
10
+ t.rspec_opts = %w[-fl]
11
11
  end
12
12
 
13
13
  task default: :spec
14
14
 
15
- desc "Open an irb session preloaded with this library"
15
+ desc 'Open an irb session preloaded with this library'
16
16
  task :console do
17
- sh "irb -rubygems -I lib -r dbf.rb"
17
+ sh 'irb -rubygems -I lib -r dbf.rb'
18
18
  end
data/bin/dbf CHANGED
@@ -11,16 +11,16 @@ if params['v']
11
11
 
12
12
  elsif params['h'] then
13
13
  puts "usage: #{File.basename(__FILE__)} [-h|-s|-a|-c|-r] filename"
14
- puts " -h = print this message"
15
- puts " -v = print the DBF gem version"
16
- puts " -s = print summary information"
17
- puts " -a = create an ActiveRecord::Schema"
18
- puts " -r = create a Sequel migration"
19
- puts " -c = create a CSV file"
14
+ puts ' -h = print this message'
15
+ puts ' -v = print the DBF gem version'
16
+ puts ' -s = print summary information'
17
+ puts ' -a = create an ActiveRecord::Schema'
18
+ puts ' -r = create a Sequel migration'
19
+ puts ' -c = create a CSV file'
20
20
  else
21
21
 
22
22
  filename = ARGV.shift
23
- abort "You must supply a filename on the command line" unless filename
23
+ abort 'You must supply a filename on the command line' unless filename
24
24
 
25
25
  # create an ActiveRecord::Schema
26
26
  if params['a']
@@ -43,10 +43,10 @@ else
43
43
  puts "Records: #{table.record_count}"
44
44
 
45
45
  puts "\nFields:"
46
- puts "Name Type Length Decimal"
47
- puts "-" * 78
46
+ puts 'Name Type Length Decimal'
47
+ puts '-' * 78
48
48
  table.columns.each do |f|
49
- puts "%-16s %-10s %-10s %-10s" % [f.name, f.type, f.length, f.decimal]
49
+ puts '%-16s %-10s %-10s %-10s' % [f.name, f.type, f.length, f.decimal]
50
50
  end
51
51
  end
52
52
 
@@ -21,6 +21,7 @@ module DBF
21
21
  G: ColumnType::General
22
22
  }
23
23
  TYPE_CAST_CLASS.default = ColumnType::String
24
+ TYPE_CAST_CLASS.freeze
24
25
 
25
26
  # Initialize a new DBF::Column
26
27
  #
@@ -81,68 +82,41 @@ module DBF
81
82
 
82
83
  private
83
84
 
84
- def clean(value) # nodoc
85
+ def clean(value) # :nodoc:
85
86
  truncated_value = value.strip.partition("\x00").first
86
87
  truncated_value.gsub(/[^\x20-\x7E]/, '')
87
88
  end
88
89
 
89
- def encode(value, strip_output = false) # nodoc
90
- return value if !value.respond_to?(:encoding)
90
+ def encode(value, strip_output = false) # :nodoc:
91
+ return value unless value.respond_to?(:encoding)
91
92
 
92
93
  output = @encoding ? encode_string(value) : value
93
94
  strip_output ? output.strip : output
94
95
  end
95
96
 
96
- def encoding_args # nodoc
97
+ def encoding_args # :nodoc:
97
98
  @encoding_args ||= [
98
99
  Encoding.default_external,
99
100
  {undef: :replace, invalid: :replace}
100
101
  ]
101
102
  end
102
103
 
103
- def encode_string(string) # nodoc
104
+ def encode_string(string) # :nodoc:
104
105
  string.force_encoding(@encoding).encode(*encoding_args)
105
106
  end
106
107
 
107
- def schema_data_type(format = :activerecord) # nodoc
108
- case type
109
- when 'N', 'F'
110
- decimal > 0 ? ':float' : ':integer'
111
- when 'I'
112
- ':integer'
113
- when 'Y'
114
- ':decimal, :precision => 15, :scale => 4'
115
- when 'D'
116
- ':date'
117
- when 'T'
118
- ':datetime'
119
- when 'L'
120
- ':boolean'
121
- when 'M'
122
- ':text'
123
- when 'B'
124
- ':binary'
125
- else
126
- if format == :sequel
127
- ":varchar, :size => #{length}"
128
- else
129
- ":string, :limit => #{length}"
130
- end
131
- end
132
- end
133
-
134
- def type_cast_class # nodoc
108
+ def type_cast_class # :nodoc:
135
109
  @type_cast_class ||= begin
136
110
  klass = @length == 0 ? ColumnType::Nil : TYPE_CAST_CLASS[type.to_sym]
137
111
  klass.new(@decimal, @encoding)
138
112
  end
139
113
  end
140
114
 
141
- def validate_length # nodoc
115
+ def validate_length # :nodoc:
142
116
  raise LengthError, 'field length must be 0 or greater' if length < 0
143
117
  end
144
118
 
145
- def validate_name # nodoc
119
+ def validate_name # :nodoc:
146
120
  raise NameError, 'column name cannot be empty' if @name.empty?
147
121
  end
148
122
  end
@@ -4,7 +4,7 @@ module DBF
4
4
  ENCODING_ARGS = [
5
5
  Encoding.default_external,
6
6
  {undef: :replace, invalid: :replace}
7
- ]
7
+ ].freeze
8
8
 
9
9
  attr_reader :decimal, :encoding
10
10
 
@@ -21,7 +21,6 @@ module DBF
21
21
  @dirname = File.dirname(@path)
22
22
  @db = DBF::Table.new(@path)
23
23
  @tables = extract_dbc_data
24
-
25
24
  rescue Errno::ENOENT
26
25
  raise DBF::FileNotFoundError, "file not found: #{data}"
27
26
  end
@@ -33,7 +32,7 @@ module DBF
33
32
  # Returns table with given name
34
33
  # @return Table
35
34
  def table(name)
36
- Table.new(table_path name) do |table|
35
+ Table.new table_path(name) do |table|
37
36
  table.long_names = @tables[name]
38
37
  end
39
38
  end
@@ -53,12 +52,12 @@ module DBF
53
52
  path
54
53
  end
55
54
 
56
- def method_missing(method, *args) # nodoc
57
- if table_names.index(method.to_s)
58
- table method.to_s
59
- else
60
- super
61
- end
55
+ def method_missing(method, *args) # :nodoc:
56
+ table_names.index(method.to_s) ? table(method.to_s) : super
57
+ end
58
+
59
+ def respond_to_missing?(method, *)
60
+ table_names.index(method.to_s) || super
62
61
  end
63
62
 
64
63
  private
@@ -67,7 +66,7 @@ module DBF
67
66
  # just an ordinary table with a treelike structure. Field definitions
68
67
  # are in the same order as in the linked tables but only the long name
69
68
  # is provided.
70
- def extract_dbc_data # nodoc
69
+ def extract_dbc_data # :nodoc:
71
70
  data = {}
72
71
  @db.each do |record|
73
72
  next unless record
@@ -110,7 +109,7 @@ module DBF
110
109
  class Table < DBF::Table
111
110
  attr_accessor :long_names
112
111
 
113
- def build_columns # nodoc
112
+ def build_columns # :nodoc:
114
113
  columns = super
115
114
 
116
115
  # modify the column definitions to use the long names as the
@@ -58,6 +58,6 @@ module DBF
58
58
  'c9' => 'cp1251', # Russian Windows
59
59
  'ca' => 'cp1254', # Turkish Windows
60
60
  'cb' => 'cp1253', # Greek Windows
61
- 'cc' => 'cp1257', # Baltic Windows
62
- }
61
+ 'cc' => 'cp1257' # Baltic Windows
62
+ }.freeze
63
63
  end
@@ -28,19 +28,19 @@ module DBF
28
28
 
29
29
  private
30
30
 
31
- def offset(start_block) # nodoc
31
+ def offset(start_block) # :nodoc:
32
32
  start_block * block_size
33
33
  end
34
34
 
35
- def content_size(memo_size) # nodoc
35
+ def content_size(memo_size) # :nodoc:
36
36
  (memo_size - block_size) + BLOCK_HEADER_SIZE
37
37
  end
38
38
 
39
- def block_content_size # nodoc
39
+ def block_content_size # :nodoc:
40
40
  @block_content_size ||= block_size - BLOCK_HEADER_SIZE
41
41
  end
42
42
 
43
- def block_size #nodoc
43
+ def block_size # :nodoc:
44
44
  BLOCK_SIZE
45
45
  end
46
46
  end