csvn 0.1.4 → 0.1.5.1

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
2
  SHA256:
3
- metadata.gz: d248aa4b3b16845aecb364fc15dcf0d9c46b319f1827bbe771a45fa552070abe
4
- data.tar.gz: e95933d958a36e230c56c3dc86e1620d6fbb869a8b7cbb7f32aef501655d1ff6
3
+ metadata.gz: 602040055b5de864f762415fc8a75f65d7877c0e2e27aff3b92a3fd8fe372f21
4
+ data.tar.gz: 11157a6ee8412fc2d9ba7ade470293ce07633d116a1be782327a354055dcf39a
5
5
  SHA512:
6
- metadata.gz: 37196e30b6f774ee3471f699f61c24ad0cba7d4d9bc3d404c18b081d4ff7bf0e1409502e982411671bdbe903a4efab1c57da947409de50dcb85c10ff2bdfc5da
7
- data.tar.gz: 77bf83290039664a15f55c6fd585509b2ed7699a28e59cb87139e4cce5f1dc53813051aac3b5caa97b6b81dcb0f173a40e8322de033ac595fcdfc6168d178268
6
+ metadata.gz: 96f66737334d7ac18dd5eb38788a4e3708d4e88b9a48fe859ff3106d7c20ea6c1c96c79f48b233d64b9dd59eb284994f1628cbe84369c1ea33c4187d9c706ef7
7
+ data.tar.gz: 1de87400bfe09ca01462cef1ae908d06d7f894c950927bf109974f71ca755fe59d0c29a032dd0ece8d23640f3367f26c1228cb9d08b78be832519280a479e73a
data/Gemfile CHANGED
@@ -4,5 +4,4 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem "colorize", "~> 0.8.1"
7
+ gem "rspec", "~> 3.0"
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Csvn
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/csvn`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is my first gem for simple and more convinient work with csv files (especially for csv exports from DB).
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,42 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+
24
+ ### Base description of instance variables
25
+
26
+ `file_name` - source file name for reading (absolute or relative path should be provided)
27
+
28
+ `file_extension` - file extension
29
+
30
+ `data` - file data rows (as array when readed and array of hashes after .smart_convert! method)
31
+
32
+ `smart_convert` - convert readed data in array of hashes with file headers keys - false by default
33
+
34
+ `file_headers` - file headers array
35
+
36
+ `read_flag` - service flag to see if data already readed
37
+
38
+ `output` - output file name with extension to use .write method
39
+
40
+
41
+ ### read data
42
+
43
+ Can read data with all standart separators (iterating over DefaultConstants::COL_SEPS - `["\t", ",", ";", " ", "|", ":"]`)
44
+
45
+ ```
46
+ csv_instance = CSVFile.new(file_name: "export_for_saller.csv") # create new instance
47
+ csv_instance.info # show stat about file
48
+ csv_instance.read # read file data - return array of arrays - allow to read file
49
+ csv_instance.smart_convert! - convert readed data into array of hashes with file headers keys
50
+ ```
51
+
52
+ ### write data
53
+
54
+ ```
55
+ csv_instance.write(data_to_write: data, headers: headers) # write data in file with name provided with @destination instance variables
56
+ ```
57
+
58
+ `data` - may be array of arrays or array of hashes -> will be automaticly converted while writing. If data is array of hashes - headers will be extracted from first data hash. Else - headers must be provided mannually.
26
59
 
27
60
  ## Development
28
61
 
@@ -32,8 +65,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
65
 
33
66
  ## Contributing
34
67
 
35
- Bug reports and pull requests are welcome on GitHub at hhttps://github.com/shamritskiy3468/csvn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/shamritskiy3468/csvn/blob/master/CODE_OF_CONDUCT.md).
36
-
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/shamritskiy3468/csvn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/shamritskiy3468/csvn/blob/master/CODE_OF_CONDUCT.md).
37
69
 
38
70
  ## License
39
71
 
@@ -41,4 +73,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
73
 
42
74
  ## Code of Conduct
43
75
 
44
- Everyone interacting in the Csvn project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/csvn/blob/master/CODE_OF_CONDUCT.md).
76
+ Everyone interacting in the Csvn project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shamritskiy3468/csvn/blob/master/CODE_OF_CONDUCT.md).
data/csvn.gemspec CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ["shamritskiy3468"]
7
7
  spec.email = ["sshamritskiy3468@gmail.com"]
8
8
 
9
- spec.summary = %q{Simple attemp to simplify routine work with CSV file.}
10
- spec.description = %q{Too lazy to write something, so use summary please :) }
9
+ spec.summary = %q{Attemp to simplify routine work with CSV files (such as DB request result)}
10
+ spec.description = %q{My simple gem for work with .csv data files. Can read data from files with any separator and allow work with them more comfortable.}
11
11
  spec.homepage = "https://github.com/shamritskiy3468/csvn"
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.bindir = "exe"
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
+ spec.add_dependency "colorize", "= 0.8.1"
26
27
  end
data/lib/csvn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Csvn
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5.1"
3
3
  end
data/lib/csvn.rb CHANGED
@@ -57,7 +57,7 @@ class CSVFile
57
57
  end
58
58
 
59
59
  # Only for string row values
60
- # will be improved to be able to handle more complex selecting like SQL does
60
+ # will be improved to be able to handle more complex selecting like SQL does ----> multiple select
61
61
  def select(opts = {})
62
62
  return @data.select { |row| row[opts[:where]] =~ /#{opts[:like]}/ } if opts[:like]
63
63
  return @data.select { |row| row[opts[:where]] !~ /#{opts[:not_like]}/ } if opts[:not_like]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - shamritskiy3468
@@ -9,8 +9,23 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2021-08-29 00:00:00.000000000 Z
12
- dependencies: []
13
- description: 'Too lazy to write something, so use summary please :) '
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.1
27
+ description: My simple gem for work with .csv data files. Can read data from files
28
+ with any separator and allow work with them more comfortable.
14
29
  email:
15
30
  - sshamritskiy3468@gmail.com
16
31
  executables: []
@@ -53,5 +68,5 @@ requirements: []
53
68
  rubygems_version: 3.0.8
54
69
  signing_key:
55
70
  specification_version: 4
56
- summary: Simple attemp to simplify routine work with CSV file.
71
+ summary: Attemp to simplify routine work with CSV files (such as DB request result)
57
72
  test_files: []