Commit e43e0c8b authored by Immanuel Häussermann's avatar Immanuel Häussermann
Browse files

rename gem to excelsieur

parent 93eb3ba5
Pipeline #28549 failed with stage
in 2 seconds
......@@ -4,5 +4,5 @@ source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in excelsior.gemspec
# Specify your gem's dependencies in excelsieur.gemspec
gemspec
PATH
remote: .
specs:
excelsior (0.1.0)
excelsieur (0.1.0)
activerecord (>= 4.0.0)
rails (>= 4.0.0)
simple_xlsx_reader (~> 1.0.2)
......@@ -142,7 +142,7 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.16)
excelsior!
excelsieur!
minitest (~> 5.0)
rake (~> 10.0)
rubocop (~> 0.56.0)
......
<img src="docs/excelsior-logo.png" width="480">
<img src="docs/excelsieur-logo.png" width="480">
---
......@@ -9,7 +9,7 @@ A straightforward way to import data from an excel sheet into your ruby app.
Add this line to your application's Gemfile:
```ruby
gem 'excelsior'
gem 'excelsieur'
```
And then execute:
......@@ -18,14 +18,14 @@ And then execute:
Or install it yourself as:
$ gem install excelsior
$ gem install excelsieur
## How to use it
Create a class which declares how columns from an excel sheet map to your ruby object model by extending from the `Excelsior::Importer` class:
Create a class which declares how columns from an excel sheet map to your ruby object model by extending from the `Excelsieur::Importer` class:
```ruby
class UserImporter < Excelsior::Importer
class UserImporter < Excelsieur::Importer
# declare the source file
source "static/ftp/users.xlsx"
......@@ -44,7 +44,7 @@ import = UserImport.new
import.run # calls User.create!(row) for each row
```
The result is an instance of `Excelsior::Result`:
The result is an instance of `Excelsieur::Result`:
```ruby
result = import.run
......@@ -53,7 +53,7 @@ result.status
result.errors
# => { missing_column: [], model: [] }
result.report
# => #<struct Excelsior::Report inserted=2, failed=0>
# => #<struct Excelsieur::Report inserted=2, failed=0>
```
### Model validation
......@@ -67,7 +67,7 @@ import = UserImport.new
import.run
import.errors[:model]
# => [#<struct Excelsior::Error row=3, errors=["First name can't be blank"]>]
# => [#<struct Excelsieur::Error row=3, errors=["First name can't be blank"]>]
```
### Report
......@@ -80,7 +80,7 @@ import = UserImport.new
import.run
import.report
# => #<struct Excelsior::Report inserted=2, failed=1>
# => #<struct Excelsieur::Report inserted=2, failed=1>
import.total
# => 3
......@@ -91,7 +91,7 @@ import.total
When setting `transaction true` no record is inserted if any one of them has an error.
```ruby
class UserImporter < Excelsior::Importer
class UserImporter < Excelsieur::Importer
# declare the source file
source "static/ftp/users.xlsx"
......@@ -153,7 +153,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/manufaktor/excelsior.
Bug reports and pull requests are welcome on GitHub at https://github.com/panter/excelsieur.
## License
......
......@@ -2,7 +2,7 @@
# frozen_string_literal: true
require 'bundler/setup'
require 'excelsior'
require 'excelsieur'
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
......
......@@ -2,18 +2,18 @@
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'excelsior/version'
require 'excelsieur/version'
Gem::Specification.new do |spec|
spec.name = 'excelsior'
spec.version = Excelsior::VERSION
spec.name = 'excelsieur'
spec.version = Excelsieur::VERSION
spec.authors = ['Immanuel Häussermann', 'Alexis Reigel']
spec.email = ['hai@panter.ch', 'lex@panter.ch']
spec.summary = 'Helps you import data from an excel sheet'
spec.description = 'Provides a concise DSL to map, validate and import data ' \
'from an excel sheet into your ruby app'
spec.homepage = 'https://git.panter.ch/open-source/excelsior'
spec.homepage = 'https://git.panter.ch/open-source/excelsieur'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0").reject do |f|
......
# frozen_string_literal: true
require 'excelsior/version'
require 'excelsieur/version'
module Excelsior
module Excelsieur
end
# frozen_string_literal: true
module Excelsior
module Excelsieur
Error = Struct.new(:row, :errors)
end
......@@ -3,14 +3,14 @@
require 'simple_xlsx_reader'
require 'rails'
require 'active_record'
require 'excelsior/source'
require 'excelsior/mapping'
require 'excelsior/error'
require 'excelsior/report'
require 'excelsior/transaction'
require 'excelsior/result'
module Excelsior
require 'excelsieur/source'
require 'excelsieur/mapping'
require 'excelsieur/error'
require 'excelsieur/report'
require 'excelsieur/transaction'
require 'excelsieur/result'
module Excelsieur
class Import
include Source
include Mapping
......
# frozen_string_literal: true
module Excelsior
module Excelsieur
module Mapping
def self.included(host_class)
host_class.extend ClassMethods
......
# frozen_string_literal: true
module Excelsior
module Excelsieur
Report = Struct.new(:expected, :inserted, :failed) do
def initialize(*args)
super(*args)
......
# frozen_string_literal: true
module Excelsior
module Excelsieur
class Result
module Statuses
PENDING = :pending
......
# frozen_string_literal: true
module Excelsior
module Excelsieur
module Source
def self.included(host_class)
host_class.extend ClassMethods
......
# frozen_string_literal: true
module Excelsior
module Excelsieur
module Transaction
def self.included(host_class)
host_class.extend ClassMethods
......
# frozen_string_literal: true
module Excelsior
module Excelsieur
VERSION = '0.1.0'
end
# frozen_string_literal: true
require 'test_helper'
require 'excelsior/import'
require 'excelsieur/import'
class User < ActiveRecord::Base
validates :first_name, presence: true
end
describe Excelsior do
describe Excelsieur do
before do
Object.send(:remove_const, :UserImport) if Object.constants.include?(:UserImport)
class UserImport < Excelsior::Import
class UserImport < Excelsieur::Import
source 'test/files/complete.xlsx'
map 'Vorname', to: :first_name
......@@ -23,7 +23,7 @@ describe Excelsior do
end
it 'has a version number' do
refute_nil ::Excelsior::VERSION
refute_nil ::Excelsieur::VERSION
end
describe 'source' do
......@@ -50,7 +50,7 @@ describe Excelsior do
before do
Object.send(:remove_const, :UserImport) if Object.constants.include?(:UserImport)
class UserImport < Excelsior::Import
class UserImport < Excelsieur::Import
source 'test/files/complete.xlsx'
transaction true
......@@ -132,8 +132,8 @@ describe Excelsior do
it 'returns a result object' do
result = @import.run
assert_equal Excelsior::Result::Statuses::SUCCEEDED, result.status
assert_equal Excelsior::Report.new(2, 2, 0), result.report
assert_equal Excelsieur::Result::Statuses::SUCCEEDED, result.status
assert_equal Excelsieur::Report.new(2, 2, 0), result.report
assert_equal({ missing_column: [], model: [] }, result.errors)
end
end
......@@ -158,8 +158,8 @@ describe Excelsior do
it 'returns a result object' do
result = @import.run { |v| v }
assert_equal Excelsior::Result::Statuses::SUCCEEDED, result.status
assert_equal Excelsior::Report.new(2, 2, 0), result.report
assert_equal Excelsieur::Result::Statuses::SUCCEEDED, result.status
assert_equal Excelsieur::Report.new(2, 2, 0), result.report
assert_equal({ missing_column: [], model: [] }, result.errors)
end
end
......@@ -180,7 +180,7 @@ describe Excelsior do
it 'returns the model validation errors' do
import = UserImport.new('test/files/missing-first-name.xlsx').tap(&:run)
assert import.errors[:model].any?
assert_equal import.errors[:model], [Excelsior::Error.new(3, ["First name can't be blank"])]
assert_equal import.errors[:model], [Excelsieur::Error.new(3, ["First name can't be blank"])]
end
end
......
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'excelsior'
require 'excelsieur'
require 'active_record'
require 'minitest/autorun'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment