csv_line_serialize 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in csv_line_serialize.gemspec
4
+ gemspec
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
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ end
7
+
8
+ task :default => :test
9
+
data/bin/csvl-serial ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'csv_line_serialize'
4
+
5
+ csv_line = ARGV.first.dup
6
+ puts CsvLineSerialize::Serializer.new(csv_line).execute
@@ -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,3 @@
1
+ module CsvLineSerialize
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "csv_line_serialize/version"
2
+
3
+ module CsvLineSerialize
4
+ require 'csv_line_serialize/serializer'
5
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'csv_line_serialize'
3
+
4
+ require 'minitest/autorun'
@@ -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