smuggle 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa3dadc3be4934ed2b6829c8b96a80a7a10da5cc4466d251e9306007f555c52a
4
- data.tar.gz: 5768506f6b6bfa05bad2f2e51c357f210545a2e0d7da4748a71b976f5702d027
3
+ metadata.gz: 76c28e234e739e3124cd325d75adcbdfbce6af88b4b48ad55ece82ca5d0db14e
4
+ data.tar.gz: 2e5357b380f21f5249e233505c6d67f91b43db50b28bdbdcc04f771af95dd112
5
5
  SHA512:
6
- metadata.gz: f63495bd7e4cd81c3df888123990444c310c932886ce087b76817d29ed0964ffdb2842e2edf413f9e7a0b70f19a383a61faba689278273209c7950f86393def4
7
- data.tar.gz: '08959772994e511e90bf5fb6996b3ceab6880e27cc1d9f025e88f8b9084c1c0150e3fd452786ee93bfae3080824e55fc343f9959aadecb9f7baf8a56b9cf157f'
6
+ metadata.gz: 8a6b749134917f0b16b745e5678b6332f6f2f24895fd5171c34762c7b8dad848d439fa713b495d860eda326e16a40de31c236d0d252fbfe5af7928c02d43e9a1
7
+ data.tar.gz: a91cd6e70449ed729cab625faa84a79d199364abf538de800c4646077709619c93ba33b3aab9ec55d54a937f3e621bc29a595105b53b905b6af5cc094e4b53b6
data/README.md CHANGED
@@ -1,136 +1,209 @@
1
1
  # Smuggle
2
2
 
3
- Is a gem to manage exports with ease, separating the logic from the models, resulting in a much cleaner codebase. Easy to use, with familiar structure.
3
+ [![Gem](https://img.shields.io/gem/v/smuggle.svg?style=flat)](http://rubygems.org/gems/smuggle)
4
+ [![Depfu](https://badges.depfu.com/badges/6f2f73672eae4d603d6ae923164435e2/overview.svg)](https://depfu.com/github/InspireNL/smuggle?project=Bundler)
5
+ [![Inline docs](http://inch-ci.org/github/InspireNL/smuggle.svg?branch=master&style=shields)](http://inch-ci.org/github/InspireNL/smuggle)
6
+ [![CircleCI](https://circleci.com/gh/InspireNL/smuggle.svg?style=svg)](https://circleci.com/gh/InspireNL/smuggle)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/cc59cfca7a9d29c18e12/maintainability)](https://codeclimate.com/github/InspireNL/smuggle/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/cc59cfca7a9d29c18e12/test_coverage)](https://codeclimate.com/github/InspireNL/smuggle/test_coverage)
4
9
 
5
- **Smuggle is not dependent on Rails**, you can use it on ActiveRecord models, as well as plain ruby objects and hashes.
10
+ Is a gem to manage exports and imports with ease, separating the logic from the models, resulting in a much cleaner codebase. Easy to use, with familiar structure.
6
11
 
7
- ## Installation
12
+ **Smuggle is not dependent on Rails**, you can use it on ActiveModel/ActiveRecord models, as well as plain ruby objects and hashes.
8
13
 
9
- Add this line to your application's Gemfile:
14
+ Links:
10
15
 
11
- ```ruby
12
- gem 'smuggle'
13
- ```
16
+ - [API Docs](https://www.rubydoc.info/gems/smuggle)
17
+ - [Contributing](https://github.com/InspireNL/smuggle/blob/master/CONTRIBUTING.md)
18
+ - [Code of Conduct](https://github.com/InspireNL/smuggle/blob/master/CODE_OF_CONDUCT.md)
14
19
 
15
- And then execute:
20
+ ## Requirements
16
21
 
17
- ```
18
- $ bundle
19
- ```
22
+ 1. [Ruby 2.5.0](https://www.ruby-lang.org)
23
+
24
+ ## Installation
20
25
 
21
- Or install it yourself as:
26
+ To install, run:
22
27
 
23
28
  ```
24
- $ gem install smuggle
29
+ gem install smuggle
25
30
  ```
26
31
 
27
- To generate the base exporter run:
32
+ Or add the following to your Gemfile:
28
33
 
29
34
  ```
30
- $ rails g smuggle:install
31
- create app/exporters/application_exporter.rb
35
+ gem "smuggle"
32
36
  ```
33
37
 
34
- To geneate an exporter, you can run the following command:
38
+ ## Usage
35
39
 
36
- ```
37
- $ rails g smuggle:exporter user
38
- create app/exporters/user_exporter.rb
39
- ```
40
+ ### Exporters
40
41
 
41
- You can also include the attributes you wish to export by running:
42
+ Given the following plain old ruby object:
42
43
 
43
- ```
44
- $ rails g smuggle:exporter user email username created_at
45
- create app/exporters/user_exporter.rb
46
- ```
44
+ ```ruby
45
+ class User
46
+ attr_accessor :name
47
47
 
48
- ## Example
48
+ def initialize(name)
49
+ @name = name
50
+ end
51
+ end
52
+ ```
49
53
 
50
- Inside the `user_exporter.rb` file:
54
+ An exporter can be defined by inheriting from [Smuggle::Exporter::Base](lib/smuggle/exporter/base.rb) and define the attributes to export:
51
55
 
52
56
  ```ruby
53
- class UserExporter < ApplicationExporter
54
- attributes :email, :username, :created_at
57
+ class UserExporter < Smuggle::Exporter::Base
58
+ attributes :name
55
59
  end
56
60
  ```
57
61
 
58
62
  Extra logic can be establish inside the exporter file, using the same name as the attribute:
59
63
 
60
64
  ```ruby
61
- class UserExporter < ApplicationExporter
62
- attributes :email, :username, :created_at
65
+ class UserExporter < Smuggle::Exporter::Base
66
+ attributes :name
63
67
 
64
- def created_at
65
- super.created_at.strftime("%m/%d/%Y")
68
+ def name
69
+ super + " - exported"
66
70
  end
67
71
  end
68
72
  ```
69
73
 
70
- If there are no attributes defined in the exporter, all the attributes of the ActiveModel record will be included.
74
+ If there are no attributes defined in the exporter and you are using ActiveModel or ActiveRecord, all the attributes of the record will be included.
71
75
  If it is a hash, then all values will be included.
72
76
 
73
- ## Usage
77
+ To generate the csv data simply call:
74
78
 
75
- Generate the csv in the desired export controller simply call:
79
+ ```ruby
80
+ users = [User.new("Rick Sanchez"), User.new("Morty Smith")]
81
+ Smuggle::Services::Export.call(scope: users, exporter: UserExporter)
82
+ # => "Full name,Full name\nRick Sanchez,Rick Sanchez\nMorty Smith,Morty Smith\n"
83
+ ```
84
+
85
+ Or if you are using ActiveRecord, the exporter class will be automatically resolved from the scope:
76
86
 
77
87
  ```ruby
78
- class User
79
- attr_accessor :name
88
+ Smuggle::Services::Export.call(scope: User.all)
89
+ ```
80
90
 
81
- def initialize(name)
82
- @name = name
83
- end
84
- end
91
+ To add labels for your attributes (to show in the header instead of the raw attribute keys) you can add **attribute_labels** to your exporter:
85
92
 
86
- class UserExporter < ApplicationExporter
93
+ ``` ruby
94
+ class UserExporter < Smuggle::Exporter::Base
87
95
  attributes :name
96
+ attribute_labels name: "Full name"
88
97
  end
89
98
 
90
- users = [User.new('Rick Sanchez'), User.new('Morty Smith')]
99
+ users = [User.new("Rick Sanchez"), User.new("Morty Smith")]
91
100
 
92
101
  Smuggle::Services::Export.call(scope: users, exporter: UserExporter)
93
- # => "name\n" + "Rick Sanchez\n" + "Morty Smith\n"
102
+ # => "Full name\nRick Sanchez\nMorty Smith\n"
94
103
  ```
95
104
 
96
- Or if you are using active record, the exporter class will be automatically resolved from the scope:
105
+ ### Importers
106
+
107
+ Give the following ActiveRecord model:
97
108
 
98
109
  ```ruby
99
- Smuggle::Services::Export.call(scope: User.all)
110
+ class User < ApplicationRecord
111
+ validates :full_name, :username, presence: true
112
+ end
100
113
  ```
101
114
 
102
- ## Attribute labels
115
+ To define a importers you need to inherit from [Smuggle::Importer::Base](lib/smuggle/importer/base.rb) and define the attributes to import:
103
116
 
104
- To add labels for your attributes (to show in the header instead of the raw attribute keys) you can add **attribute_labels** to your exporter:
117
+ ```ruby
118
+ class UserImporter < Smuggle::Importer::Base
119
+ # List all the attributes you need to import, everything else will be ignored
120
+ attributes :full_name, :username
105
121
 
106
- ``` ruby
107
- class User
108
- attr_accessor :name
122
+ # Computed attributes from the row data
123
+ def full_name
124
+ [row[:first_name], row[:last_name]].join(" ")
125
+ end
109
126
 
110
- def initialize(name)
111
- @name = name
127
+ def persist
128
+ # You can implement how to persist the data anyway you prefer
129
+ # This is an example using active record
130
+ model.create(to_h)
131
+ # model.new(to_h).save(validate: false) # Another example skipping validations
112
132
  end
113
133
  end
134
+ ```
114
135
 
115
- class UserExporter < ApplicationExporter
116
- attributes :name
117
- attribute_labels name: 'Full name'
118
- end
136
+ For example:
119
137
 
120
- users = [User.new('Rick Sanchez'), User.new('Morty Smith')]
138
+ Given the following `users.csv` file:
139
+
140
+ ```
141
+ "first_name","last_name","username"
142
+ "Rick","Sanchez","rsanchez"
143
+ "Morty","Smith","msmith"
144
+ "Jerry","Smith","jsmith"
145
+ ```
146
+
147
+ Just run:
148
+
149
+ ```ruby
150
+ Smuggle::Services::Import.call(model: User, filepath: "users.csv")
151
+ ```
152
+
153
+ The importer class will be resolved from the model name, otherwise you could explicitely set the importer like this:
154
+
155
+ ```ruby
156
+ Smuggle::Services::Import.call(model: User, filepath: "users.csv", importer: UserImporter)
157
+ ```
158
+
159
+ ### Generators
160
+
161
+ If you are using rails you can use the following generators:
121
162
 
122
- Smuggle::Services::Export.call(scope: users, exporter: UserExporter)
123
- # => "Full name\n" + "Rick Sanchez\n" + "Morty Smith\n"
124
163
  ```
164
+ $ rails g smuggle:install
165
+ create app/exporters/application_exporter.rb
166
+ create app/importers/application_importer.rb
167
+ ```
168
+
169
+ To generate an exporter, you can run the following command:
170
+
171
+ ```
172
+ $ rails g smuggle:exporter user
173
+ create app/exporters/user_exporter.rb
174
+ ```
175
+
176
+ You can also include the attributes you wish to export by running:
177
+
178
+ ```
179
+ $ rails g smuggle:exporter user email username created_at
180
+ create app/exporters/user_exporter.rb
181
+ ```
182
+
183
+ And to generate an importer, just run:
184
+
185
+ ```
186
+ $ rails g smuggle:importer user email username full_name
187
+ create app/importers/user_importer.rb
188
+ ```
189
+
190
+ ## Tests
125
191
 
126
- ## Contributing
192
+ To test, run:
193
+
194
+ ```
195
+ bundle exec rspec spec/
196
+ ```
127
197
 
128
- Bug reports and pull requests are welcome on GitHub at https://github.com/InspireNL/smuggle.
198
+ ## Versioning
129
199
 
130
- ## Todo
200
+ Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
131
201
 
132
- - Implement `importer` functionality
202
+ - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
203
+ - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
204
+ - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
133
205
 
134
206
  ## License
135
207
 
136
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
208
+ Copyright 2018 [Inspire Innovation BV](https://inspire.nl).
209
+ Read [LICENSE](LICENSE) for details.
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Smuggle
2
4
  module Generators
3
5
  class ExporterGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
6
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
5
7
 
6
8
  argument :attributes, type: :array, required: false
7
9
 
8
10
  def create_exporter
9
- template 'exporter.rb', File.join('app/exporters', class_path, "#{file_name}_exporter.rb")
11
+ template "exporter.rb", File.join("app/exporters", class_path, "#{file_name}_exporter.rb")
10
12
  end
11
13
  end
12
14
  end
@@ -1,5 +1,5 @@
1
1
  class <%= class_name %>Exporter < ApplicationExporter
2
2
  <% if attributes -%>
3
- attributes <%= attributes.map { |attribute| ":#{attribute}" }.join(', ') %>
3
+ attributes <%= attributes.map { |attribute| ":#{attribute.name}" }.join(', ') %>
4
4
  <% end -%>
5
5
  end
@@ -0,0 +1,14 @@
1
+ Description:
2
+ Generates a importer for a model with the given name.
3
+ You need to pass the attributes to include in the import.
4
+
5
+ Example:
6
+ rails generate smuggle:importer user first_name last_name
7
+
8
+ This will create:
9
+
10
+ # app/importer/user_importer.rb
11
+
12
+ class UserImporter < ApplicationImporter
13
+ attributes :first_name, :last_name
14
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smuggle
4
+ module Generators
5
+ class ImporterGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
7
+
8
+ argument :attributes, type: :array, required: true
9
+
10
+ def create_importer
11
+ template "importer.rb", File.join("app/importers", class_path, "#{file_name}_importer.rb")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ class <%= class_name %>Importer < ApplicationImporter
2
+ <% if attributes -%>
3
+ attributes <%= attributes.map { |attribute| ":#{attribute.name}" }.join(', ') %>
4
+ <% end -%>
5
+
6
+ def persist
7
+ # Save your model here. Example using ActiveRecord:
8
+ # model.create(to_h)
9
+ raise NotImplementedError
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
 
2
2
  Description:
3
- Generates an application exporter as a starting point for your application.
3
+ Generates an application exporter and/or application importer as a starting point for your application.
@@ -1,10 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Smuggle
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
6
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
5
7
 
6
8
  def copy_application_exporter
7
- template 'application_exporter.rb', 'app/exporters/application_exporter.rb'
9
+ template "application_exporter.rb", "app/exporters/application_exporter.rb"
10
+ end
11
+
12
+ def copy_application_importer
13
+ template "application_importer.rb", "app/importers/application_importer.rb"
8
14
  end
9
15
  end
10
16
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationExporter < Smuggle::Exporter::Base
2
4
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationImporter < Smuggle::Importer::Base
4
+ end
data/lib/smuggle.rb CHANGED
@@ -1,8 +1,10 @@
1
- require 'smuggle/version'
2
- require 'smuggle/exporter/base'
3
- require 'smuggle/services/export'
4
- require 'smuggle/exporter_not_found'
5
- require 'smuggle/engine' if defined?(Rails)
1
+ # frozen_string_literal: true
6
2
 
7
- module Smuggle
8
- end
3
+ require "csv"
4
+ require "smuggle/version"
5
+ require "smuggle/errors"
6
+ require "smuggle/exporter/base"
7
+ require "smuggle/importer/base"
8
+ require "smuggle/services/export"
9
+ require "smuggle/services/import"
10
+ require "smuggle/engine" if defined?(Rails)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Smuggle
2
4
  class Engine < Rails::Engine
3
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smuggle
4
+ class ExporterNotFound < StandardError
5
+ end
6
+
7
+ class ImporterNotFound < StandardError
8
+ end
9
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Smuggle
2
4
  module Exporter
3
5
  class Base < SimpleDelegator
4
6
  class << self
5
- attr_accessor :attributes
6
- attr_accessor :attribute_labels
7
+ attr_writer :attributes
8
+ attr_writer :attribute_labels
7
9
 
8
10
  def inherited(base)
9
11
  base.attributes = []
@@ -28,7 +30,8 @@ module Smuggle
28
30
 
29
31
  def header
30
32
  return @attributes unless attribute_labels?
31
- return @attributes.map do |attribute|
33
+
34
+ @attributes.map do |attribute|
32
35
  @attribute_labels.fetch(attribute, attribute)
33
36
  end
34
37
  end
@@ -43,6 +46,7 @@ module Smuggle
43
46
  def defined_attributes
44
47
  return self.class.attributes if self.class.attributes?
45
48
  return attribute_names if __getobj__.respond_to?(:attribute_names)
49
+
46
50
  keys if __getobj__.respond_to?(:keys)
47
51
  end
48
52
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smuggle
4
+ module Importer
5
+ class Base
6
+ class << self
7
+ attr_writer :attributes
8
+
9
+ def inherited(base)
10
+ base.attributes = []
11
+ end
12
+
13
+ def attributes(*names)
14
+ @attributes.concat names
15
+ end
16
+
17
+ def attributes?
18
+ @attributes.any?
19
+ end
20
+
21
+ def csv_converters
22
+ Hash(header_converters: :symbol, converters: %i[all])
23
+ end
24
+ end
25
+
26
+ attr_reader :row, :model
27
+
28
+ def initialize(row, model)
29
+ @model = model
30
+ @row = row
31
+ end
32
+
33
+ def persist
34
+ raise NotImplementedError
35
+ end
36
+
37
+ def to_h
38
+ defined_attributes.each_with_object({}) do |attribute, hash|
39
+ hash[attribute.to_sym] = respond_to?(attribute) ? public_send(attribute) : row[attribute.to_sym]
40
+ end
41
+ end
42
+
43
+ def defined_attributes
44
+ return self.class.attributes if self.class.attributes?
45
+
46
+ model.attribute_names if model.respond_to?(:attribute_names)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,4 +1,4 @@
1
- require 'csv'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Smuggle
4
4
  module Services
@@ -14,8 +14,8 @@ module Smuggle
14
14
  attr_reader :scope
15
15
 
16
16
  def initialize(scope, options = {})
17
- @scope = scope
18
17
  @exporter = options[:exporter]
18
+ @scope = scope
19
19
  end
20
20
 
21
21
  def call
@@ -23,8 +23,8 @@ module Smuggle
23
23
  end
24
24
 
25
25
  def resolve
26
- "#{scope.name.demodulize}Exporter".constantize
27
- rescue
26
+ Object.const_get("#{scope.name}Exporter")
27
+ rescue NameError
28
28
  raise ExporterNotFound
29
29
  end
30
30
 
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Smuggle
4
+ module Services
5
+ class Import
6
+ class << self
7
+ def call(model:, filepath:, **options)
8
+ new(model, filepath, options).send(:call)
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ attr_reader :model, :filepath
15
+
16
+ def initialize(model, filepath, options = {})
17
+ @filepath = filepath
18
+ @importer = options[:importer]
19
+ @model = model
20
+ end
21
+
22
+ def call
23
+ import_from_csv
24
+ end
25
+
26
+ def resolve
27
+ Object.const_get("#{model.name}Importer")
28
+ rescue NameError
29
+ raise ImporterNotFound
30
+ end
31
+
32
+ def importer
33
+ @importer || resolve
34
+ end
35
+
36
+ def import_from_csv
37
+ CSV.read(filepath, headers: true, **importer.csv_converters).map do |row|
38
+ importer.new(row, model).persist
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Smuggle
2
- VERSION = '0.3.0'.freeze
4
+ VERSION = "0.4.0"
3
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smuggle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Crivella
8
+ - InspireNL
8
9
  autorequire:
9
- bindir: exe
10
+ bindir: bin
10
11
  cert_chain: []
11
- date: 2018-08-29 00:00:00.000000000 Z
12
+ date: 2018-09-10 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -25,33 +26,33 @@ dependencies:
25
26
  - !ruby/object:Gem::Version
26
27
  version: '1.15'
27
28
  - !ruby/object:Gem::Dependency
28
- name: factory_girl
29
+ name: faker
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '4.0'
34
+ version: '1.8'
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '4.0'
41
+ version: '1.8'
41
42
  - !ruby/object:Gem::Dependency
42
- name: faker
43
+ name: pry
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: '1.8'
48
+ version: '0.10'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: '1.8'
55
+ version: '0.10'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: pry-byebug
57
58
  requirement: !ruby/object:Gem::Requirement
@@ -67,84 +68,126 @@ dependencies:
67
68
  - !ruby/object:Gem::Version
68
69
  version: '3.5'
69
70
  - !ruby/object:Gem::Dependency
70
- name: pry
71
+ name: rake
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
74
  - - "~>"
74
75
  - !ruby/object:Gem::Version
75
- version: '0.10'
76
+ version: '12.3'
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - "~>"
81
82
  - !ruby/object:Gem::Version
82
- version: '0.10'
83
+ version: '12.3'
83
84
  - !ruby/object:Gem::Dependency
84
- name: rake
85
+ name: rspec
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - "~>"
88
89
  - !ruby/object:Gem::Version
89
- version: '10.0'
90
+ version: '3.0'
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
95
  - - "~>"
95
96
  - !ruby/object:Gem::Version
96
- version: '10.0'
97
+ version: '3.0'
97
98
  - !ruby/object:Gem::Dependency
98
- name: rspec
99
+ name: rspec_junit_formatter
99
100
  requirement: !ruby/object:Gem::Requirement
100
101
  requirements:
101
102
  - - "~>"
102
103
  - !ruby/object:Gem::Version
103
- version: '3.0'
104
+ version: '0.4'
104
105
  type: :development
105
106
  prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - "~>"
109
110
  - !ruby/object:Gem::Version
110
- version: '3.0'
111
- description: It Exports all kind of stuff to CSV
111
+ version: '0.4'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '0.59'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.59'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '1.29'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.29'
140
+ - !ruby/object:Gem::Dependency
141
+ name: simplecov
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '0.16'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0.16'
154
+ description:
112
155
  email:
113
156
  - pablocrivella@gmail.com
157
+ - info@inspire.nl
114
158
  executables: []
115
159
  extensions: []
116
- extra_rdoc_files: []
160
+ extra_rdoc_files:
161
+ - README.md
162
+ - LICENSE
117
163
  files:
118
- - ".editorconfig"
119
- - ".gitignore"
120
- - ".rspec"
121
- - ".rubocop.yml"
122
- - ".travis.yml"
123
- - CHANGELOG.md
124
- - CODE_OF_CONDUCT.md
125
- - Gemfile
126
164
  - LICENSE
127
165
  - README.md
128
- - Rakefile
129
- - bin/console
130
- - bin/setup
131
166
  - lib/generators/smuggle/exporter/USAGE
132
167
  - lib/generators/smuggle/exporter/exporter_generator.rb
133
168
  - lib/generators/smuggle/exporter/templates/exporter.rb
169
+ - lib/generators/smuggle/importer/USAGE
170
+ - lib/generators/smuggle/importer/importer_generator.rb
171
+ - lib/generators/smuggle/importer/templates/importer.rb
134
172
  - lib/generators/smuggle/install/USAGE
135
173
  - lib/generators/smuggle/install/install_generator.rb
136
174
  - lib/generators/smuggle/install/templates/application_exporter.rb
175
+ - lib/generators/smuggle/install/templates/application_importer.rb
137
176
  - lib/smuggle.rb
138
177
  - lib/smuggle/engine.rb
178
+ - lib/smuggle/errors.rb
139
179
  - lib/smuggle/exporter/base.rb
140
- - lib/smuggle/exporter_not_found.rb
180
+ - lib/smuggle/importer/base.rb
141
181
  - lib/smuggle/services/export.rb
182
+ - lib/smuggle/services/import.rb
142
183
  - lib/smuggle/version.rb
143
- - smuggle.gemspec
144
- homepage: https://github.com/pablocrivella/smuggle
184
+ homepage: https://github.com/InspireNL/smuggle
145
185
  licenses:
146
186
  - MIT
147
- metadata: {}
187
+ metadata:
188
+ bug_tracker_uri: https://github.com/InspireNL/smuggle/issues
189
+ changelog_uri: https://github.com/InspireNL/smuggle/blob/master/CHANGELOG.md
190
+ source_code_uri: https://github.com/InspireNL/smuggle
148
191
  post_install_message:
149
192
  rdoc_options: []
150
193
  require_paths:
@@ -164,5 +207,5 @@ rubyforge_project:
164
207
  rubygems_version: 2.7.7
165
208
  signing_key:
166
209
  specification_version: 4
167
- summary: It Exports stuff to CSV
210
+ summary: It exports and imports all kinds of stuff from and to CSV
168
211
  test_files: []
data/.editorconfig DELETED
@@ -1,30 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- end_of_line = lf
6
- charset = utf-8
7
- trim_trailing_whitespace = true
8
- insert_final_newline = true
9
- indent_style = space
10
- indent_size = 2
11
-
12
- [*.scss]
13
- indent_style = space
14
- indent_size = 2
15
-
16
- [*.js]
17
- indent_style = space
18
- indent_size = 2
19
-
20
- [Rakefile]
21
- indent_style = space
22
- indent_size = 2
23
-
24
- [Gemfile*]
25
- indent_style = space
26
- indent_size = 2
27
-
28
- [config.ru]
29
- indent_style = space
30
- indent_size = 2
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
- *.gem
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.rubocop.yml DELETED
@@ -1,71 +0,0 @@
1
- AllCops:
2
- Include:
3
- - Gemfile
4
- Exclude:
5
- - vendor/ruby/**/*
6
- - lib/generators/**/*
7
- TargetRubyVersion: 2.4
8
-
9
- Layout/SpaceBeforeFirstArg:
10
- Enabled: false
11
-
12
- Metrics/AbcSize:
13
- Max: 25
14
-
15
- Metrics/CyclomaticComplexity:
16
- Max: 10
17
-
18
- Metrics/LineLength:
19
- Enabled: true
20
- Max: 125
21
-
22
- Metrics/MethodLength:
23
- Max: 25
24
-
25
- Metrics/BlockLength:
26
- Exclude:
27
- - spec/**/*
28
- - '*.gemspec'
29
-
30
- Layout/AlignHash:
31
- EnforcedLastArgumentHashStyle: ignore_implicit
32
-
33
- Layout/AlignParameters:
34
- EnforcedStyle: with_fixed_indentation
35
-
36
- Layout/MultilineMethodCallIndentation:
37
- EnforcedStyle: indented
38
-
39
- Layout/MultilineOperationIndentation:
40
- EnforcedStyle: indented
41
-
42
- Style/ClassAndModuleChildren:
43
- EnforcedStyle: nested
44
-
45
- Style/Documentation:
46
- Enabled: false
47
-
48
- Style/FileName:
49
- Enabled: false
50
-
51
- Style/FormatString:
52
- EnforcedStyle: sprintf
53
-
54
- Style/EmptyMethod:
55
- EnforcedStyle: expanded
56
-
57
- Style/RegexpLiteral:
58
- EnforcedStyle: mixed
59
-
60
- Style/StringLiterals:
61
- EnforcedStyle: single_quotes
62
-
63
- Style/StringLiteralsInInterpolation:
64
- EnforcedStyle: single_quotes
65
-
66
- Style/TrivialAccessors:
67
- AllowPredicates: true
68
- AllowDSLWriters: true
69
-
70
- Style/FrozenStringLiteralComment:
71
- Enabled: false
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.15.3
data/CHANGELOG.md DELETED
@@ -1,12 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6
-
7
- ## 0.3.0 - 2018-08-29
8
-
9
- ### Added
10
-
11
- - Changelog
12
- - Attribute labels
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at pablocrivella@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in smuggle.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/bin/console DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'smuggle'
5
- require 'faker'
6
- require 'factory_girl'
7
- require 'pry'
8
- require_relative '../spec/support/user.rb'
9
- require_relative '../spec/support/exporters/with_attributes.rb'
10
- require_relative '../spec/support/exporters/without_attributes.rb'
11
-
12
- FactoryGirl.find_definitions
13
- Pry.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,4 +0,0 @@
1
- module Smuggle
2
- class ExporterNotFound < StandardError
3
- end
4
- end
data/smuggle.gemspec DELETED
@@ -1,32 +0,0 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'smuggle/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'smuggle'
9
- spec.version = Smuggle::VERSION
10
- spec.authors = ['Pablo Crivella']
11
- spec.email = ['pablocrivella@gmail.com']
12
-
13
- spec.summary = %q{It Exports stuff to CSV}
14
- spec.description = %q{It Exports all kind of stuff to CSV}
15
- spec.homepage = 'https://github.com/pablocrivella/smuggle'
16
- spec.license = 'MIT'
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(test|spec|features)/})
20
- end
21
- spec.bindir = 'exe'
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ['lib']
24
-
25
- spec.add_development_dependency 'bundler', '~> 1.15'
26
- spec.add_development_dependency 'factory_girl', '~> 4.0'
27
- spec.add_development_dependency 'faker', '~> 1.8'
28
- spec.add_development_dependency 'pry-byebug', '~> 3.5'
29
- spec.add_development_dependency 'pry', '~> 0.10'
30
- spec.add_development_dependency 'rake', '~> 10.0'
31
- spec.add_development_dependency 'rspec', '~> 3.0'
32
- end