simple-excel-import 0.0.2 → 0.0.2.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -18
  3. data/lib/simple-excel-import.rb +2 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6311b3e80c8528884c7a21d17523471361f212b3
4
- data.tar.gz: 579c94d75d22592f33e8c778e53b8c541299857a
3
+ metadata.gz: f8a7e465f7acc18f1a2f7bd0b7d2a64d265303f5
4
+ data.tar.gz: 907d3c025a1fd93ed5926cc1ef3c0ff29d943f1e
5
5
  SHA512:
6
- metadata.gz: 799815e2b45c2ff232b79aa9acb433b0f918b9fbba7bb75fe84f3ede29e874fde6a67c43a56eff774d71caefff2827afedaba0666db6fad0e4a16e619423fdd7
7
- data.tar.gz: 35b850e5dff2f63aea8710beddcfbb3dc9c32512ef2867f04cbe8baba0b82e2f42aa18be7eb08f37d3cb4900275a957677b7560e4c6963ce70ec6938131ab83b
6
+ metadata.gz: 902a4dad2473850f8e1d1a00da5237ecf54f008e719a7fec1f9a5ff45bd97645602903fb3dc216f394562f4931228b9164d994665c43c6ad20ccfab8ad265d1e
7
+ data.tar.gz: 81cca5a831821c849ac136f50a8fe5db083ac3aefc9821776f56b2536451f4504cb994d7a13610353342d00d63767eb892ee91edd493e4e6ccc4547552c2cfbf
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  simple-excel-import
2
2
  ===================
3
3
 
4
+ [![Build Status](https://travis-ci.org/mindpin/simple-excel-import.png?branch=master)](https://travis-ci.org/mindpin/simple-excel-import)
5
+ [![Coverage Status](https://coveralls.io/repos/mindpin/simple-excel-import/badge.png?branch=master)](https://coveralls.io/r/mindpin/simple-excel-import)
6
+ [![Code Climate](https://codeclimate.com/github/mindpin/simple-excel-import.png)](https://codeclimate.com/github/mindpin/simple-excel-import)
7
+
4
8
 
5
9
  ## Target
6
10
  Get data from excel file and save into database model
@@ -18,38 +22,39 @@ include in Gemfile:
18
22
  gem 'simple-excel-import'
19
23
  ```
20
24
 
21
- ## How-To
25
+ ## How to use
26
+
27
+ in a model
22
28
 
23
29
  ```ruby
24
- # declare in model
25
- class User
26
- simple_excel_import :teacher, :fields => [:tid, :age, :gender, :nation]
27
- :default => {
28
- :role => :teacher
29
- }
30
+ class Book < ActiveRecord::Base
31
+ simple_excel_import :common, :fields => [:title, :price, :kind]
30
32
 
31
- simple_excel_import :student, :fields => [:sid, :age, :gender, :graduated]
33
+ simple_excel_import :program, :fields => [:title, :price, :url],
32
34
  :default => {
33
- :role => :student
35
+ :kind => '编程'
34
36
  }
35
37
  end
38
+ ```
36
39
 
40
+ then, you can call Model.parse_excel_xxx
37
41
 
38
-
42
+ ```ruby
39
43
  # parse excel file without saving
40
- User.parse_excel_teacher(excel_file)
41
- # -> return [user, user, user] user array
42
-
44
+ Book.parse_excel_common(excel_file)
45
+ # -> return a array of <#Book> with fields title, price, kind filled
43
46
 
44
- # parse excel file and save
45
- User.import_excel_teacher(excel_file)
47
+ Book.parse_excel_program(excel_file)
48
+ # -> return a array of <#Book> with fields title, price, url filled, and kind of default value '编程'
49
+ ```
46
50
 
47
- # generate sample excel file and return file object
48
- User.get_sample_excel_teacher
51
+ you can call Model.import_excel_xxx to save models into database
49
52
 
53
+ ```ruby
54
+ Book.parse_excel_common(excel_file)
55
+ Book.parse_excel_program(excel_file)
50
56
  ```
51
57
 
52
-
53
58
  ## TODO
54
59
  - support nil field in field list
55
60
  :fields => [:tid, nil, :gender, :nation]
@@ -1,4 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ require 'roo'
3
+
2
4
  module SimpleExcelImport
3
5
  module Base
4
6
  extend ActiveSupport::Concern
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-excel-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - arlyxiao