csv2hash 0.2.1 → 0.3.0

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.
@@ -1,4 +1,4 @@
1
- class Csv2hash
1
+ module Csv2hash
2
2
  module Parser
3
3
  end
4
4
  end
@@ -1,3 +1,5 @@
1
+ # require 'active_support/core_ext'
2
+
1
3
  module Csv2hash::StructureValidator
2
4
  class ValidationError < StandardError ; end
3
5
 
@@ -14,6 +16,7 @@ module Csv2hash::StructureValidator
14
16
 
15
17
  def rule_instance rule, options
16
18
  Csv2hash::StructureValidator.const_get(rule).new(options)
19
+ # 'min_columns'.camelize.constantize.new
17
20
  end
18
21
 
19
22
  module Validator
@@ -24,4 +27,4 @@ module Csv2hash::StructureValidator
24
27
  true
25
28
  end
26
29
  end
27
- end
30
+ end
@@ -1,4 +1,4 @@
1
- class Csv2hash
1
+ module Csv2hash
2
2
  module Validator
3
3
 
4
4
  def validate_rules y=nil
@@ -1,3 +1,3 @@
1
- module Cvs2hash
2
- VERSION = '0.2.1'
3
- end
1
+ module Csv2hash
2
+ VERSION = '0.3.0'
3
+ end
data/lib/csv2hash.rb CHANGED
@@ -1,94 +1,102 @@
1
- require 'csv2hash/version'
2
- require 'csv2hash/definition'
3
- require 'csv2hash/validator'
4
- require 'csv2hash/validator/mapping'
5
- require 'csv2hash/validator/collection'
6
- require 'csv2hash/structure_validator'
7
- require 'csv2hash/structure_validator/max_columns'
8
- require 'csv2hash/structure_validator/min_columns'
9
- require 'csv2hash/parser'
10
- require 'csv2hash/parser/mapping'
11
- require 'csv2hash/parser/collection'
12
- require 'csv2hash/csv_array'
13
- require 'csv2hash/data_wrapper'
14
- require 'csv2hash/notifier'
15
- require 'csv2hash/extra_validator'
16
-
17
- require 'csv'
18
-
19
- class Csv2hash
20
-
21
- include Csv2hash::StructureValidator
22
-
23
- attr_accessor :definition, :file_path, :data, :notifier, :exception_mode, :errors, :ignore_blank_line
24
-
25
- def initialize definition, file_path, exception_mode=true, data_source=nil, ignore_blank_line=false
26
- @data_source = data_source
27
- self.definition, self.file_path = definition, file_path
28
- dynamic_lib_loading 'Parser'
29
- self.exception_mode, self.errors = exception_mode, []
30
- dynamic_lib_loading 'Validator'
31
- self.notifier = Notifier.new
32
- self.ignore_blank_line = ignore_blank_line
33
- init_plugins
34
-
35
- end
36
-
37
- def init_plugins
38
- begin
39
- @plugins = []
40
- ::Csv2hash::Plugins.constants.each do |name|
41
- @plugins << ::Csv2hash::Plugins.const_get(name).new(self)
42
- end
43
- rescue; end
44
- end
45
-
46
- def parse
47
- load_data_source
1
+ require_relative 'csv2hash/version'
2
+ require_relative 'csv2hash/definition'
3
+ require_relative 'csv2hash/validator'
4
+ require_relative 'csv2hash/validator/mapping'
5
+ require_relative 'csv2hash/validator/collection'
6
+ require_relative 'csv2hash/structure_validator'
7
+ require_relative 'csv2hash/structure_validator/max_columns'
8
+ require_relative 'csv2hash/structure_validator/min_columns'
9
+ require_relative 'csv2hash/parser'
10
+ require_relative 'csv2hash/parser/mapping'
11
+ require_relative 'csv2hash/parser/collection'
12
+ require_relative 'csv2hash/csv_array'
13
+ require_relative 'csv2hash/data_wrapper'
14
+ require_relative 'csv2hash/notifier'
15
+ require_relative 'csv2hash/extra_validator'
16
+ require_relative 'csv2hash/adapters/base'
17
+
18
+ begin
19
+ require 'pry'
20
+ rescue LoadError
21
+ end
22
+
23
+ module Csv2hash
24
+ class Main
25
+ include Csv2hash::StructureValidator
26
+
27
+ attr_accessor :definition, :file_path_or_data, :data, :notifier, :exception_mode, :errors, :ignore_blank_line
28
+
29
+ def initialize definition, file_path_or_data, exception_mode=true, ignore_blank_line=false
30
+ self.definition, self.file_path_or_data = definition, file_path_or_data
31
+ @data_source = data_source
32
+ dynamic_lib_loading 'Parser'
33
+ self.exception_mode, self.errors = exception_mode, []
34
+ dynamic_lib_loading 'Validator'
35
+ self.notifier = Notifier.new
36
+ self.ignore_blank_line = ignore_blank_line
37
+
38
+ init_plugins
39
+ end
48
40
 
49
- definition.validate!
50
- definition.default!
51
- validate_structure!
52
- validate_data!
41
+ def init_plugins
42
+ begin
43
+ @plugins = []
44
+ ::Csv2hash::Plugins.constants.each do |name|
45
+ @plugins << ::Csv2hash::Plugins.const_get(name).new(self)
46
+ end
47
+ rescue; end
48
+ end
53
49
 
54
- Csv2hash::DataWrapper.new.tap do |response|
55
- if valid?
56
- fill!
57
- response.data = data[:data]
58
- else
59
- response.valid = false
60
- response.errors = csv_with_errors
61
- notifier.notify response
50
+ def parse
51
+ load_data_source
52
+
53
+ definition.validate!
54
+ definition.default!
55
+ validate_structure!
56
+ validate_data!
57
+
58
+ Csv2hash::DataWrapper.new.tap do |response|
59
+ if valid?
60
+ fill!
61
+ response.data = data[:data]
62
+ else
63
+ response.valid = false
64
+ response.errors = csv_with_errors
65
+ notifier.notify response
66
+ end
62
67
  end
63
68
  end
64
- end
65
69
 
66
- def csv_with_errors
67
- @csv_with_errors ||= begin
68
- CsvArray.new.tap do |rows|
69
- errors.each do |error|
70
- rows << error.merge({ value: (data_source[error[:y]][error[:x]] rescue nil) })
71
- end
72
- end #.to_csv
70
+ def csv_with_errors
71
+ @csv_with_errors ||= begin
72
+ CsvArray.new.tap do |rows|
73
+ errors.each do |error|
74
+ rows << error.merge({ value: (data_source[error[:y]][error[:x]] rescue nil) })
75
+ end
76
+ end #.to_csv
77
+ end
73
78
  end
74
- end
75
79
 
76
- # protected
80
+ # protected
77
81
 
78
- def data_source
79
- @data_source ||= CSV.read self.file_path
80
- end
81
- alias_method :load_data_source, :data_source
82
+ def data_source
83
+ @data_source ||= begin
84
+ adapter_name = self.file_path_or_data.is_a?(String) ? :csv : :memory
85
+ adapter = Adapter::Base.create(adapter_name, self.file_path_or_data)
86
+ adapter.source
87
+ end
88
+ end
89
+ alias_method :load_data_source, :data_source
82
90
 
83
- private
91
+ private
84
92
 
85
- def dynamic_lib_loading type
86
- case definition.type
87
- when Csv2hash::Definition::MAPPING
88
- self.extend Module.module_eval("Csv2hash::#{type}::Mapping")
89
- when Csv2hash::Definition::COLLECTION
90
- self.extend Module.module_eval("Csv2hash::#{type}::Collection")
93
+ def dynamic_lib_loading type
94
+ case definition.type
95
+ when Csv2hash::Definition::MAPPING
96
+ self.extend Module.module_eval("Csv2hash::#{type}::Mapping")
97
+ when Csv2hash::Definition::COLLECTION
98
+ self.extend Module.module_eval("Csv2hash::#{type}::Collection")
99
+ end
91
100
  end
92
101
  end
93
-
94
- end
102
+ end
@@ -12,8 +12,8 @@ describe Csv2hash::Definition do
12
12
  end
13
13
 
14
14
  it 'variable should be assigned' do
15
- subject.type.should eql Csv2hash::Definition::MAPPING
16
- subject.rules.should eql [ { position: [0,0], key: 'name' } ]
15
+ expect(subject.type).to eql Csv2hash::Definition::MAPPING
16
+ expect(subject.rules).to eql [ { position: [0,0], key: 'name' } ]
17
17
  end
18
18
  end
19
19
 
@@ -56,7 +56,7 @@ describe Csv2hash::Definition do
56
56
  before { subject.default! }
57
57
 
58
58
  it 'missing key must be filled' do
59
- subject.rules.should eql([{ position: [0, 0],
59
+ expect(subject.rules).to eql([{ position: [0, 0],
60
60
  key: 'name',
61
61
  message: 'undefined :key on :position',
62
62
  mappable: true,
@@ -68,7 +68,3 @@ describe Csv2hash::Definition do
68
68
  end
69
69
  end
70
70
  end
71
-
72
-
73
-
74
-
@@ -9,21 +9,22 @@ describe Csv2hash::Parser::Collection do
9
9
  let(:data_source) { [ [ 'John Doe' ], [ 'Jane Doe' ] ] }
10
10
 
11
11
  subject do
12
- Csv2hash.new(definition, 'file_path', false, data_source)
12
+ Csv2hash::Main.new(definition, data_source, exception_mode=false, ignore_blank_line=false)
13
13
  end
14
14
 
15
15
  context 'regular way' do
16
16
  it { expect { subject.parse }.to_not raise_error }
17
17
  it {
18
- subject.tap do |parser|
18
+ expect(subject.tap do |parser|
19
19
  parser.parse
20
- end.data.should eql({ data: [ { 'name' => 'John Doe' }, { 'name' => 'Jane Doe' } ] })
20
+ end.data).to eql({ data: [ { 'name' => 'John Doe' }, { 'name' => 'Jane Doe' } ] })
21
21
  }
22
22
  context 'with header' do
23
23
  before { subject.definition.header_size = 1 }
24
24
  let(:data_source) { [ [ 'Name' ], [ 'John Doe' ], [ 'Jane Doe' ] ] }
25
25
  it {
26
- subject.tap { |c| c.parse }.data.should eql({ data: [ { 'name' => 'John Doe' }, { 'name' => 'Jane Doe' } ] })
26
+ expect(subject.tap { |c| c.parse }.data).to eql(
27
+ { data: [ { 'name' => 'John Doe' }, { 'name' => 'Jane Doe' } ] })
27
28
  }
28
29
  end
29
30
  end
@@ -34,7 +35,7 @@ describe Csv2hash::Parser::Collection do
34
35
  definition.rules << { position: 1, key: 'age', nested: 'infos' }
35
36
  end
36
37
  it {
37
- subject.tap { |c| c.parse }.data.should eql(
38
+ expect(subject.tap { |c| c.parse }.data).to eql(
38
39
  { data: [
39
40
  { 'name' => 'John Doe', 'infos' => { 'age' => 22 } },
40
41
  { 'name' => 'Jane Doe', 'infos' => { 'age' => 19 } }
@@ -47,10 +48,10 @@ describe Csv2hash::Parser::Collection do
47
48
  context '#ignore_blank_line' do
48
49
  let(:data_source) { [ [ 'John Doe' ], [ 'Jane Doe' ], [ nil ] ] }
49
50
  it {
50
- subject.tap do |parser|
51
+ expect(subject.tap do |parser|
51
52
  parser.ignore_blank_line = true
52
53
  parser.parse
53
- end.data.should eql({ data: [ { 'name' => 'John Doe' }, { 'name' => 'Jane Doe' } ] })
54
+ end.data).to eql({ data: [ { 'name' => 'John Doe' }, { 'name' => 'Jane Doe' } ] })
54
55
  }
55
56
  end
56
- end
57
+ end
@@ -9,15 +9,15 @@ describe Csv2hash::Parser::Mapping do
9
9
  let(:data_source) { [ [ 'John Doe' ] ] }
10
10
 
11
11
  subject do
12
- Csv2hash.new(definition, 'file_path', false, data_source)
12
+ Csv2hash::Main.new(definition, data_source, exception_mode=false, ignore_blank_line=false)
13
13
  end
14
14
 
15
15
  context 'regular way' do
16
16
  it { expect { subject.parse }.to_not raise_error }
17
17
  it {
18
- subject.tap do |csv2hash|
18
+ expect(subject.tap do |csv2hash|
19
19
  csv2hash.parse
20
- end.data.should eql({ data: [ { 'name' => 'John Doe' } ] })
20
+ end.data).to eql({ data: [ { 'name' => 'John Doe' } ] })
21
21
  }
22
22
  end
23
23
 
@@ -27,10 +27,10 @@ describe Csv2hash::Parser::Mapping do
27
27
  definition.rules << { position: [0,1], key: 'age', nested: 'infos' }
28
28
  end
29
29
  it {
30
- subject.tap { |c| c.parse }.data.should eql(
30
+ expect(subject.tap { |c| c.parse }.data).to eql(
31
31
  { data: [ { 'name' => 'John Doe', 'infos' => { 'age' => 22 } } ] }
32
32
  )
33
33
  }
34
34
  end
35
35
 
36
- end
36
+ end
@@ -13,7 +13,7 @@ describe Csv2hash::StructureValidator do
13
13
  end
14
14
 
15
15
  subject do
16
- Csv2hash.new(definition, 'file_path', exception_mode, data_source)
16
+ Csv2hash::Main.new(definition, data_source, exception_mode, ignore_blank_line=false)
17
17
  end
18
18
 
19
19
  context 'the csv with errors' do
@@ -29,7 +29,7 @@ describe Csv2hash::StructureValidator do
29
29
 
30
30
  its(:csv_with_errors) { should be_kind_of CsvArray }
31
31
  it "adds structure error in first cell" do
32
- subject.csv_with_errors.first[:message].should eq 'Too many columns (max. 2) on line 1'
32
+ expect(subject.csv_with_errors.first[:message]).to eq 'Too many columns (max. 2) on line 1'
33
33
  end
34
34
  end
35
35
 
@@ -80,4 +80,4 @@ describe Csv2hash::StructureValidator do
80
80
  end
81
81
  end
82
82
 
83
- end
83
+ end
@@ -10,7 +10,7 @@ describe Csv2hash::Validator::Collection do
10
10
  end
11
11
 
12
12
  subject do
13
- Csv2hash.new(definition, 'file_path', true, data_source)
13
+ Csv2hash::Main.new(definition, data_source, exception_mode=true, ignore_blank_line=false)
14
14
  end
15
15
 
16
16
  context 'with valid data' do
@@ -46,7 +46,7 @@ describe Csv2hash::Validator::Collection do
46
46
  context 'wihtout exception' do
47
47
  let(:data_source) { [ [ ] ]}
48
48
  before { subject.exception_mode = false }
49
- it { subject.parse.errors.to_csv.should eql ",\"undefined name on [0, 0]\"\n" }
49
+ it { expect(subject.parse.errors.to_csv).to eql ",\"undefined name on [0, 0]\"\n" }
50
50
 
51
51
  context 'errors should be filled' do
52
52
  before { subject.parse }
@@ -61,7 +61,7 @@ describe Csv2hash::Validator::Collection do
61
61
  end
62
62
  end
63
63
  let(:data_source) { [ [ 'what?' ], [ 'yes' ], [ 'no' ] ] }
64
- it { subject.parse.errors.to_csv.should eql "what?,\"agree not supported, please use one of [\"\"yes\"\", \"\"no\"\"]\"\n" }
64
+ it { expect(subject.parse.errors.to_csv).to eql "what?,\"agree not supported, please use one of [\"\"yes\"\", \"\"no\"\"]\"\n" }
65
65
  end
66
66
  end
67
67
 
@@ -10,7 +10,7 @@ describe Csv2hash::Validator::Mapping do
10
10
  end
11
11
 
12
12
  subject do
13
- Csv2hash.new(definition, 'file_path', true, data_source)
13
+ Csv2hash::Main.new(definition, data_source, exception_mode=true, ignore_blank_line=false)
14
14
  end
15
15
 
16
16
  context 'with valid data' do
@@ -26,7 +26,7 @@ describe Csv2hash::Validator::Mapping do
26
26
  context 'wihtout exception' do
27
27
  let(:data_source) { [ [ ] ] }
28
28
  before { subject.exception_mode = false }
29
- it { subject.parse.errors.to_csv.should eql ",\"undefined name on [0, 0]\"\n" }
29
+ it { expect(subject.parse.errors.to_csv).to eql ",\"undefined name on [0, 0]\"\n" }
30
30
 
31
31
  context 'errors should be filled' do
32
32
  before { subject.parse }
@@ -48,7 +48,7 @@ describe Csv2hash::Validator::Mapping do
48
48
  ]
49
49
  end
50
50
  let(:data_source) { [ [ 'what?' ], [ 'yes', 'what?' ], [ 'yes', 'what?', 'no' ] ] }
51
- it { subject.parse.errors.to_csv.should eql(
51
+ it { expect(subject.parse.errors.to_csv).to eql(
52
52
  "what?,\"agree not supported, please use one of [\"\"yes\"\", \"\"no\"\"]\"\n") }
53
53
  end
54
54
  context 'range values' do
@@ -60,7 +60,7 @@ describe Csv2hash::Validator::Mapping do
60
60
  ]
61
61
  end
62
62
  let(:data_source) { [ [ 12 ], [ 2, 12 ], [ 3, 12, 1 ] ] }
63
- it { subject.parse.errors.to_csv.should eql("12,\"score not supported, please use one of 1..10\"\n") }
63
+ it { expect(subject.parse.errors.to_csv).to eql("12,\"score not supported, please use one of 1..10\"\n") }
64
64
  end
65
65
  end
66
66
 
@@ -93,4 +93,3 @@ class DowncaseValidator < Csv2hash::ExtraValidator
93
93
  !!(value.match /^[a-z]+$/)
94
94
  end
95
95
  end
96
-
@@ -10,13 +10,13 @@ describe Csv2hash::Validator do
10
10
  end
11
11
 
12
12
  describe '#message' do
13
- subject { Csv2hash.new double('definition', type: Csv2hash::Definition::COLLECTION), nil }
13
+ subject { Csv2hash::Main.new double('definition', type: Csv2hash::Definition::COLLECTION), nil }
14
14
 
15
15
  context 'string value' do
16
16
  let(:rule) { { foo: 'bar', message: ':foo are value of foo key' } }
17
17
 
18
18
  it 'substitue value of key' do
19
- subject.send(:message, rule, nil, nil).should eql 'bar are value of foo key'
19
+ expect(subject.send(:message, rule, nil, nil)).to eql 'bar are value of foo key'
20
20
  end
21
21
  end
22
22
 
@@ -24,7 +24,7 @@ describe Csv2hash::Validator do
24
24
  let(:rule) { { foo: ['bar', 'zone'], message: ':foo are values of foo key' } }
25
25
 
26
26
  it 'substitue value of key' do
27
- subject.send(:message, rule, nil, nil).should eql '["bar", "zone"] are values of foo key'
27
+ expect(subject.send(:message, rule, nil, nil)).to eql '["bar", "zone"] are values of foo key'
28
28
  end
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ describe Csv2hash::Validator do
32
32
  let(:rule) { { message: 'value not found on :position' } }
33
33
 
34
34
  it 'substitue value of key' do
35
- subject.send(:message, rule, 0, 2).should eql 'value not found on [0, 2]'
35
+ expect(subject.send(:message, rule, 0, 2)).to eql 'value not found on [0, 2]'
36
36
  end
37
37
  end
38
38
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,15 @@
1
1
  require 'csv2hash'
2
2
  require 'bundler/setup'
3
3
  require 'coveralls'
4
+ require 'its'
5
+
6
+ begin
7
+ require 'pry'
8
+ rescue LoadError
9
+ end
4
10
 
5
11
  Coveralls.wear!
6
12
 
7
13
  RSpec.configure do |c|
8
14
  c.run_all_when_everything_filtered = true
9
15
  end
10
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv2hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel AZEMAR
@@ -14,67 +14,83 @@ dependencies:
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: its
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  description: DSL to map a CSV to a Ruby Hash
56
70
  email: joel.azemar@gmail.com
57
71
  executables:
58
72
  - load_rvm
59
- - publish
60
73
  extensions: []
61
74
  extra_rdoc_files: []
62
75
  files:
63
- - .coveralls.yml
64
- - .gitignore
65
- - .rspec
66
- - .travis.yml
76
+ - ".coveralls.yml"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
67
80
  - Gemfile
68
81
  - Gemfile.lock
69
- - Guardfile
70
82
  - LICENSE
71
83
  - README.md
72
84
  - Rakefile
73
85
  - ReleaseNotes.md
74
86
  - bin/load_rvm
75
- - bin/publish
87
+ - coverage/.resultset.json.lock
76
88
  - csv2hash.gemspec
77
89
  - lib/csv2hash.rb
90
+ - lib/csv2hash/adapters/abstract.rb
91
+ - lib/csv2hash/adapters/base.rb
92
+ - lib/csv2hash/adapters/csv_adapter.rb
93
+ - lib/csv2hash/adapters/memory_adapter.rb
78
94
  - lib/csv2hash/csv_array.rb
79
95
  - lib/csv2hash/data_wrapper.rb
80
96
  - lib/csv2hash/definition.rb
@@ -110,17 +126,17 @@ require_paths:
110
126
  - lib
111
127
  required_ruby_version: !ruby/object:Gem::Requirement
112
128
  requirements:
113
- - - ~>
129
+ - - "~>"
114
130
  - !ruby/object:Gem::Version
115
- version: '2.0'
131
+ version: '2.1'
116
132
  required_rubygems_version: !ruby/object:Gem::Requirement
117
133
  requirements:
118
- - - '>='
134
+ - - ">="
119
135
  - !ruby/object:Gem::Version
120
136
  version: '0'
121
137
  requirements: []
122
138
  rubyforge_project:
123
- rubygems_version: 2.1.11
139
+ rubygems_version: 2.2.2
124
140
  signing_key:
125
141
  specification_version: 4
126
142
  summary: Mapping a CSV to a Ruby Hash
data/Guardfile DELETED
@@ -1,8 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :rspec, cmd: 'rspec --color --fail-fast' do
5
- watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
- end
data/bin/publish DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # bin/publish 0.0.1
4
-
5
- class Publish
6
-
7
- def start version
8
- system "bundle && bundle exec rake spec"
9
- system "gem build csv2hash.gemspec"
10
- system "git tag -a v#{version} -m 'version #{version}'"
11
- system "git push --tags"
12
- system "gem push csv2hash-#{version}.gem"
13
- system "git push origin master"
14
- end
15
-
16
- end
17
-
18
- if ARGV.length != 1 # or !ARGV[0].match(/\d{1,3}.\d{1,3}.\d{1,3}/)
19
- puts 'HELP: '
20
- puts '$ bin/publish 0.0.1'
21
- exit 0
22
- end
23
-
24
- Publish.new.start ARGV[0]