csv_line_serialize 0.0.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 +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +9 -0
- data/bin/csvl-serial +6 -0
- data/csv_line_serialize.gemspec +24 -0
- data/lib/csv_line_serialize/serializer.rb +31 -0
- data/lib/csv_line_serialize/version.rb +3 -0
- data/lib/csv_line_serialize.rb +5 -0
- data/test/minitest_helper.rb +4 -0
- data/test/test_serializer.rb +49 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c71baf5126230f532dc2dda1132a9d989c5edd96
|
4
|
+
data.tar.gz: 84206384aef51e1ab094c30fed3197d9a4a1227d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0311f5c583c5c06087bf000da20ba70e016e88e3aa3572b5f5dbd317a0ac9667132437bc8ffdb7f4525891110969b8d8c535785106950731777e49972a68ac75
|
7
|
+
data.tar.gz: 070d2c2b56f44126c5ff1fdf9e4bd1792f0fe533a3027b82bbd723d55f5dd671e32437f31384228ff44ecde4849dba657f3852085dcb1227c7bd90efe8fa584d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Shinya131
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# CsvLineSerialize
|
2
|
+
|
3
|
+
A line of csv to list tool.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'csv_line_serialize'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install csv_line_serialize
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```shell
|
24
|
+
$ csvl-serial 111,222,333,444
|
25
|
+
111
|
26
|
+
222
|
27
|
+
333
|
28
|
+
444
|
29
|
+
```
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/csv_line_serialize/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/csvl-serial
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'csv_line_serialize/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "csv_line_serialize"
|
8
|
+
spec.version = CsvLineSerialize::VERSION
|
9
|
+
spec.authors = ["Shinya131"]
|
10
|
+
spec.email = ["nagai3mt5b@gmail.com"]
|
11
|
+
spec.summary = "A line of csv to list"
|
12
|
+
spec.description = "A line of csv to list"
|
13
|
+
spec.homepage = "https://github.com/Shinya131/csv_line_serialize"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class CsvLineSerialize::Serializer
|
2
|
+
def initialize(csv_line)
|
3
|
+
@csv_line = csv_line.to_s
|
4
|
+
end
|
5
|
+
|
6
|
+
def execute
|
7
|
+
strip_comma!
|
8
|
+
serialize!
|
9
|
+
|
10
|
+
@csv_line
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def strip_comma!
|
16
|
+
remove_comma_at_start_of_line!
|
17
|
+
remove_comma_at_end_of_line!
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove_comma_at_start_of_line!
|
21
|
+
@csv_line.gsub!(/^\,/,"")
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_comma_at_end_of_line!
|
25
|
+
@csv_line.gsub!(/\,$/, "")
|
26
|
+
end
|
27
|
+
|
28
|
+
def serialize!
|
29
|
+
@csv_line.gsub!(",", "\n")
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe CsvLineSerialize::Serializer do
|
4
|
+
describe '#execute' do
|
5
|
+
describe 'regular input' do
|
6
|
+
before do
|
7
|
+
csv_line = '111,222,333'
|
8
|
+
@Serializer = CsvLineSerialize::Serializer.new(csv_line)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'serialized' do
|
12
|
+
assert @Serializer.execute == "111\n222\n333"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'has comma at end of line' do
|
17
|
+
before do
|
18
|
+
csv_line = '111,222,333,'
|
19
|
+
@Serializer = CsvLineSerialize::Serializer.new(csv_line)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'removed' do
|
23
|
+
assert @Serializer.execute == "111\n222\n333"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'has comma at start of line' do
|
28
|
+
before do
|
29
|
+
csv_line = ',111,222,333'
|
30
|
+
@Serializer = CsvLineSerialize::Serializer.new(csv_line)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'removed' do
|
34
|
+
assert @Serializer.execute == "111\n222\n333"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'not string argument' do
|
39
|
+
before do
|
40
|
+
csv_line = 333
|
41
|
+
@Serializer = CsvLineSerialize::Serializer.new(csv_line)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'to_s' do
|
45
|
+
assert @Serializer.execute == "333"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: csv_line_serialize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shinya131
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A line of csv to list
|
56
|
+
email:
|
57
|
+
- nagai3mt5b@gmail.com
|
58
|
+
executables:
|
59
|
+
- csvl-serial
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/csvl-serial
|
70
|
+
- csv_line_serialize.gemspec
|
71
|
+
- lib/csv_line_serialize.rb
|
72
|
+
- lib/csv_line_serialize/serializer.rb
|
73
|
+
- lib/csv_line_serialize/version.rb
|
74
|
+
- test/minitest_helper.rb
|
75
|
+
- test/test_serializer.rb
|
76
|
+
homepage: https://github.com/Shinya131/csv_line_serialize
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.0
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: A line of csv to list
|
100
|
+
test_files:
|
101
|
+
- test/minitest_helper.rb
|
102
|
+
- test/test_serializer.rb
|