easy_axlsx 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ea0852c41405a1672b62d5a59b64155e5f482c0a
4
+ data.tar.gz: 26e471b43cb9a8ac975813a0e52b8799f6efcd7b
5
+ SHA512:
6
+ metadata.gz: 3f125d0b7b6bc6aafbd8692f73b58b37edb983bd26e7c6dce74a9e8c34f1c4fda7afbf47c415a97a75fc7c9e83d12f58a9b2001089c1376fbec4de424fa3fed6
7
+ data.tar.gz: 09d74038bf9514b1b737c3ef368df1c6e6d72324f2b5e89822b52b36b7def31a61fe50b3c8cc87c7bc4db9b39605d930c5b1a4b9c4bf7dc110f8cc22cfccc060
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,15 @@
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
+ *.DS_Store
15
+ mkmf.log
@@ -0,0 +1,13 @@
1
+ Style/AsciiComments:
2
+ Enabled: false
3
+ Metrics/LineLength:
4
+ Max: 120
5
+ Documentation:
6
+ Enabled: false
7
+ Style/ClassAndModuleChildren:
8
+ SupportedStyles:
9
+ - nested
10
+ - compact
11
+ SingleSpaceBeforeFirstArg:
12
+ Enabled: false
13
+
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ bundler_args: --without profile
3
+ rvm:
4
+ - 2.0.0
5
+ # notifications:
6
+ # email:
7
+ # recipients:
8
+ # - dmsilaev@yandex.com
9
+ # on_success: always
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
7
+ end
8
+ # Added by devtools
9
+ eval_gemfile 'Gemfile.devtools'
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+
3
+ group :development do
4
+ gem 'rake', '~> 10.3.2'
5
+ gem 'yard', '~> 0.8.7.4'
6
+ gem 'pry'
7
+ gem 'minitest'
8
+ gem 'minitest-reporters'
9
+ gem 'ansi'
10
+
11
+
12
+ platform :rbx do
13
+ gem 'rubysl-singleton', '~> 2.0.0'
14
+ gem 'rubinius-coverage', '~> 2.0.1'
15
+ end
16
+
17
+ end
18
+
19
+ group :yard do
20
+ gem 'kramdown', '~> 1.3.3'
21
+ end
22
+
23
+ group :guard do
24
+ gem 'guard', '~> 2.8.1'
25
+ gem 'guard-bundler', '~> 2.0.0'
26
+ gem 'guard-rubocop', '~> 1.1.0'
27
+ gem 'guard-minitest'
28
+
29
+
30
+ # file system change event handling
31
+ gem 'listen', '~> 2.7.7'
32
+ gem 'rb-fchange', '~> 0.0.6', require: false
33
+ gem 'rb-fsevent', '~> 0.9.4', require: false
34
+ gem 'rb-inotify', '~> 0.9.5', require: false
35
+
36
+ # notification handling
37
+ # gem 'libnotify', '~> 0.8.3', require: false
38
+ gem 'rb-notifu', '~> 0.0.4', require: false
39
+ gem 'terminal-notifier-guard', '~> 1.5.3', require: false
40
+ end
41
+
42
+ group :metrics do
43
+ gem 'coveralls', '~> 0.7.0'
44
+ gem 'flay', '~> 2.5.0'
45
+ gem 'flog', '~> 4.2.1'
46
+ gem 'reek', '~> 1.3.7'
47
+ gem 'rubocop', '~> 0.26.0'
48
+ gem 'simplecov', '~> 0.9.1'
49
+ gem 'yardstick', '~> 0.9.9'
50
+
51
+
52
+ platforms :ruby_19, :ruby_20 do
53
+ gem 'yard-spellcheck', '~> 0.1.5'
54
+ end
55
+
56
+ platform :rbx do
57
+ gem 'json', '~> 1.8.1'
58
+ gem 'racc', '~> 1.4.11'
59
+ gem 'rubysl-logger', '~> 2.0.0'
60
+ gem 'rubysl-open-uri', '~> 2.0.0'
61
+ gem 'rubysl-prettyprint', '~> 2.0.3'
62
+ end
63
+ end
64
+
65
+ group :benchmarks do
66
+ gem 'rbench', '~> 0.2.3'
67
+ end
68
+
69
+ platform :jruby do
70
+ group :jruby do
71
+ gem 'jruby-openssl', '~> 0.9.4'
72
+ end
73
+ end
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :minitest do
5
+
6
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
7
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
8
+ watch('test/test_helper.rb') { 'test' }
9
+
10
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Dmitry Silaev
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.
@@ -0,0 +1,63 @@
1
+ EasyAxlsx
2
+ ======
3
+
4
+ [![Build Status](https://secure.travis-ci.org/dmsilaev/light_axlsx_builder.png?branch=master)][travis]
5
+ [![Dependency Status](https://gemnasium.com/dmsilaev/light_axlsx_builder.png)][gemnasium]
6
+ [![Code Climate](https://codeclimate.com/github/dmsilaev/light_axlsx_builder.png)][codeclimate]
7
+ [![Coverage Status](https://coveralls.io/repos/dmsilaev/light_axlsx_builder/badge.png?branch=master)][coveralls]
8
+
9
+ [travis]: https://travis-ci.org/dmsilaev/light_axlsx_builder
10
+ [gemnasium]: https://gemnasium.com/dmsilaev/light_axlsx_builder
11
+ [codeclimate]: https://codeclimate.com/github/dmsilaev/light_axlsx_builder
12
+ [coveralls]: https://coveralls.io/r/dmsilaev/light_axlsx_builder
13
+
14
+ This is gem lets you generate axlsx object of an any class. Very easy.
15
+ TODO: Description readme.
16
+
17
+ Installation
18
+ ------------
19
+
20
+ ``` terminal
21
+ $ gem install easy_axlsx
22
+ ```
23
+
24
+ or in your **Gemfile**
25
+
26
+ ``` ruby
27
+ gem 'easy_axlsx'
28
+ ```
29
+
30
+ Examples
31
+ --------
32
+
33
+ ``` ruby
34
+ class User
35
+ include EasyAxlsx::ClassConfig
36
+ attr_reader :id, :name, :last_name
37
+
38
+ def initialize(args = {})
39
+ @id = args.fetch(:id)
40
+ @name = args.fetch(:name)
41
+ @last_name = args.fetch(:last_name)
42
+ end
43
+
44
+ def second_name
45
+ end
46
+
47
+ as_easy_axlsx_fields :id, :name, :last_name # this is method names,which will be use as row info
48
+ as_easy_axlsx_widths 1.5, 2.5, 3.5 # this is with column as pt
49
+ end
50
+
51
+ @row_items = (1...3).map { |i| User.new(id: i, name: "Name#{i}", last_name: "Last Name #{i}") } # create your object array
52
+
53
+ # and after build axlsx object
54
+ @axlsx_object = EasyAxlsx::Builder.build @row_items
55
+
56
+ # after you can save this axlsx object as xlsx file
57
+ @axlsx_object.package.serialize('simple.xlsx')
58
+ ```
59
+
60
+ This code generate next xlsx file
61
+
62
+ ![Screen 1](http://habrastorage.org/files/986/d6a/281/986d6a281706441bb9e072b5eaf69b96.png)
63
+
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+
5
+ # Added by devtools
6
+ require 'devtools'
7
+ Devtools.init_rake_tasks
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs << 'test'
11
+ t.test_files = FileList['test/**/test*.rb']
12
+ end
13
+
14
+ task default: :test
@@ -0,0 +1,4 @@
1
+ ---
2
+ unit_test_timeout: 0.1
3
+ fail_on_branch:
4
+ - "master"
@@ -0,0 +1,3 @@
1
+ ---
2
+ threshold: 0
3
+ total_score: 0
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 0
@@ -0,0 +1,3 @@
1
+ ---
2
+ name: your_lib
3
+ namespace: YourLib
@@ -0,0 +1,103 @@
1
+ ---
2
+ Attribute:
3
+ enabled: true
4
+ exclude: []
5
+ BooleanParameter:
6
+ enabled: true
7
+ exclude: []
8
+ ClassVariable:
9
+ enabled: true
10
+ exclude: []
11
+ ControlParameter:
12
+ enabled: true
13
+ exclude: []
14
+ DataClump:
15
+ enabled: true
16
+ exclude: []
17
+ max_copies: 2
18
+ min_clump_size: 2
19
+ DuplicateMethodCall:
20
+ enabled: true
21
+ exclude: []
22
+ max_calls: 1
23
+ allow_calls: []
24
+ FeatureEnvy:
25
+ enabled: true
26
+ exclude: []
27
+ IrresponsibleModule:
28
+ enabled: true
29
+ exclude: []
30
+ LongParameterList:
31
+ enabled: true
32
+ exclude: []
33
+ max_params: 2
34
+ overrides:
35
+ initialize:
36
+ max_params: 3
37
+ LongYieldList:
38
+ enabled: true
39
+ exclude: []
40
+ max_params: 2
41
+ NestedIterators:
42
+ enabled: true
43
+ exclude: []
44
+ max_allowed_nesting: 1
45
+ ignore_iterators: []
46
+ NilCheck:
47
+ enabled: true
48
+ exclude: []
49
+ RepeatedConditional:
50
+ enabled: true
51
+ exclude: []
52
+ max_ifs: 1
53
+ TooManyInstanceVariables:
54
+ enabled: true
55
+ exclude: []
56
+ max_instance_variables: 3
57
+ TooManyMethods:
58
+ enabled: true
59
+ exclude: []
60
+ max_methods: 10
61
+ TooManyStatements:
62
+ enabled: true
63
+ exclude:
64
+ - each
65
+ max_statements: 2
66
+ UncommunicativeMethodName:
67
+ enabled: true
68
+ exclude: []
69
+ reject:
70
+ - !ruby/regexp /^[a-z]$/
71
+ - !ruby/regexp /[0-9]$/
72
+ - !ruby/regexp /[A-Z]/
73
+ accept: []
74
+ UncommunicativeModuleName:
75
+ enabled: true
76
+ exclude: []
77
+ reject:
78
+ - !ruby/regexp /^.$/
79
+ - !ruby/regexp /[0-9]$/
80
+ accept: []
81
+ UncommunicativeParameterName:
82
+ enabled: true
83
+ exclude: []
84
+ reject:
85
+ - !ruby/regexp /^.$/
86
+ - !ruby/regexp /[0-9]$/
87
+ - !ruby/regexp /[A-Z]/
88
+ accept: []
89
+ UncommunicativeVariableName:
90
+ enabled: true
91
+ exclude: []
92
+ reject:
93
+ - !ruby/regexp /^.$/
94
+ - !ruby/regexp /[0-9]$/
95
+ - !ruby/regexp /[A-Z]/
96
+ accept: []
97
+ UnusedParameters:
98
+ enabled: true
99
+ exclude: []
100
+ UtilityFunction:
101
+ enabled: true
102
+ exclude: []
103
+ max_helper_calls: 0
@@ -0,0 +1,13 @@
1
+ Style/AsciiComments:
2
+ Enabled: false
3
+ Metrics/LineLength:
4
+ Max: 120
5
+ Documentation:
6
+ Enabled: false
7
+ Style/ClassAndModuleChildren:
8
+ SupportedStyles:
9
+ - nested
10
+ - compact
11
+ SingleSpaceBeforeFirstArg:
12
+ Enabled: false
13
+
@@ -0,0 +1,33 @@
1
+ ---
2
+ threshold: 100
3
+ rules:
4
+ ApiTag::Presence:
5
+ enabled: true
6
+ exclude: []
7
+ ApiTag::Inclusion:
8
+ enabled: true
9
+ exclude: []
10
+ ApiTag::ProtectedMethod:
11
+ enabled: true
12
+ exclude: []
13
+ ApiTag::PrivateMethod:
14
+ enabled: true
15
+ exclude: []
16
+ ExampleTag:
17
+ enabled: true
18
+ exclude: []
19
+ ReturnTag:
20
+ enabled: true
21
+ exclude: []
22
+ Summary::Presence:
23
+ enabled: true
24
+ exclude: []
25
+ Summary::Length:
26
+ enabled: true
27
+ exclude: []
28
+ Summary::Delimiter:
29
+ enabled: true
30
+ exclude: []
31
+ Summary::SingleLine:
32
+ enabled: true
33
+ exclude: []
@@ -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 'easy_axlsx/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'easy_axlsx'
8
+ spec.version = EasyAxlsx::VERSION
9
+ spec.authors = ['Dmitry Silaev']
10
+ spec.email = ['dmsilaev@yandex.ru']
11
+ spec.summary = 'Generate axlsx object of an any class'
12
+ spec.description = 'Generate axlsx object of an any class. After you can generate xlsx file, or change axslx object.'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(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_dependency 'axlsx', '~> 2.0'
24
+ end
@@ -0,0 +1,15 @@
1
+ require 'easy_axlsx/version'
2
+
3
+ module EasyAxlsx
4
+ require 'axlsx'
5
+
6
+ autoload 'Building', 'easy_axlsx/building'
7
+ autoload 'Builder', 'easy_axlsx/builder'
8
+ autoload 'ClassConfig', 'easy_axlsx/class_config'
9
+
10
+ # @api public
11
+ # @return [EasyAxlsx::Building]
12
+ def self.build(objects)
13
+ Builder.build(objects)
14
+ end
15
+ end
@@ -0,0 +1,83 @@
1
+ module EasyAxlsx
2
+ class Builder
3
+ private_class_method :new
4
+
5
+ # @api public
6
+ # @return [EasyAxlsx::Building]
7
+ def self.build(items)
8
+ @row_items = items
9
+
10
+ @class = items.first.class
11
+
12
+ init_package
13
+ init_workbook
14
+ init_workbook_styles
15
+
16
+ fill_package
17
+
18
+ Building.new row_items: @row_items, package: @package
19
+ end
20
+
21
+ # Create @package variable
22
+ # @return [Axlsx::Package]
23
+ def self.init_package
24
+ @package = Axlsx::Package.new
25
+ end
26
+ private_class_method :init_package
27
+
28
+ # Add workbook to package. Create @workbook variable
29
+ # @return [Axlsx::Workbook]
30
+ def self.init_workbook
31
+ @workbook = @package.workbook
32
+ end
33
+ private_class_method :init_workbook
34
+
35
+ # Add styles to workbook
36
+ # @return [Hash] styles
37
+ def self.init_workbook_styles
38
+ @workbook_styles ||= {
39
+ wrap_text: @workbook.styles.add_style(alignment: { horizontal: :left, vertical: :center, wrap_text: true })
40
+ }
41
+ end
42
+ private_class_method :init_workbook_styles
43
+
44
+ def self.init_worksheet
45
+ @worksheet ||= @workbook.add_worksheet(name: "#{@class}") do |sheet|
46
+ sheet.add_row @class.easy_axlsx_fields, style: @workbook_styles.fetch(:wrap_text), height: 60
47
+ sheet.column_widths(*@class.easy_axlsx_widths)
48
+ end
49
+ end
50
+ private_class_method :init_worksheet
51
+
52
+ # Наполняет @package данными
53
+ def self.fill_package
54
+ fill_workbook
55
+
56
+ @package
57
+ end
58
+ private_class_method :fill_package
59
+
60
+ # Наполняет @workbook данными
61
+ def self.fill_workbook
62
+ init_worksheet
63
+ fill_worksheet
64
+
65
+ @workbook
66
+ end
67
+ private_class_method :fill_workbook
68
+
69
+ # Наполняет @worksheet данными
70
+ def self.fill_worksheet
71
+ order_items_rows_params = @row_items.map do |item|
72
+ @class.easy_axlsx_fields.map { |method| item.send(method) }
73
+ end
74
+
75
+ order_items_rows_params.each do |row_params|
76
+ @worksheet.add_row row_params
77
+ end
78
+
79
+ @worksheet
80
+ end
81
+ private_class_method :fill_worksheet
82
+ end
83
+ end
@@ -0,0 +1,13 @@
1
+ module EasyAxlsx
2
+ class Building
3
+ attr_reader :package, :row_items
4
+
5
+ # @api public
6
+ # @param params [Hash] Набор параметров
7
+ # @return [EasyAxlsx::Building]
8
+ def initialize(params = {})
9
+ @package = params.fetch(:package, nil)
10
+ @row_items = params.fetch(:row_items, [])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,51 @@
1
+ require 'pry'
2
+ module EasyAxlsx
3
+ module ClassConfig
4
+ class EasyAxlsxNoMethodError < NoMethodError; end
5
+
6
+ module ClassMethods
7
+ def as_easy_axlsx_fields(*args)
8
+ args.each { |arg| easy_axlsx_check_instance_method(arg) }
9
+
10
+ @easy_axlsx_fields = args
11
+ end
12
+
13
+ def as_easy_axlsx_field(arg)
14
+ easy_axlsx_check_instance_method(arg)
15
+
16
+ @easy_axlsx_fields = easy_axlsx_fields << arg
17
+ end
18
+
19
+ # @return [Array] method names, use for generate axlsx rows
20
+ # @api private
21
+ def easy_axlsx_fields
22
+ Array(@easy_axlsx_fields)
23
+ end
24
+
25
+ def as_easy_axlsx_widths(*args)
26
+ @easy_axlsx_widths = args.map { |arg| Float(arg) }
27
+ end
28
+
29
+ # @return [Array] widths axlsx columns
30
+ # @api private
31
+ def easy_axlsx_widths
32
+ Array(@easy_axlsx_widths)
33
+ end
34
+
35
+ private
36
+
37
+ # check presence method
38
+ def easy_axlsx_check_instance_method(method_name)
39
+ return fail(NoMethodError, "#{method_name}", "#{self}") unless instance_methods.include?(method_name)
40
+ end
41
+ end
42
+
43
+ def self.included(receiver)
44
+ receiver.extend ClassMethods
45
+ end
46
+ end
47
+ end
48
+
49
+ # receiver.send :include, InstanceMethods
50
+ # module InstanceMethods
51
+ # end
@@ -0,0 +1,3 @@
1
+ module EasyAxlsx
2
+ VERSION = '0.1.0'
3
+ end
Binary file
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+ require 'pry'
3
+
4
+ class TestBuilder < Minitest::Test
5
+ def setup
6
+ @row_items = (1...3).map { |i| ClassTest.new(id: i, name: "Name#{i}", last_name: "Last Name #{i}") }
7
+ @created_object = EasyAxlsx::Builder.build @row_items
8
+ end
9
+
10
+ def test_equal_rows
11
+ package = Axlsx::Package.new
12
+ building_object = EasyAxlsx::Building.new row_items: @row_items, package: package
13
+
14
+ # FIXME: assert_equal error
15
+ assert_equal(@created_object.row_items, building_object.row_items)
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class TestBuilding < Minitest::Test
4
+ def setup
5
+ package = Axlsx::Package.new
6
+ row_items = [1, 2]
7
+ @building_object = EasyAxlsx::Building.new row_items: row_items, package: package
8
+ end
9
+
10
+ def test_initialize_object
11
+ assert(@building_object.row_items == [1, 2])
12
+ assert(@building_object.package.is_a? Axlsx::Package)
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ class TestClassConfig < Minitest::Test
4
+ def test_include_easy_axlsx_fields
5
+ assert(ClassTest.easy_axlsx_fields == [:name, :last_name])
6
+ end
7
+
8
+ def test_include_easy_axlsx_field
9
+ assert(ClassTestSecond.easy_axlsx_fields == [:name, :last_name])
10
+ end
11
+
12
+ def test_error_unless_instance_method
13
+ assert_raises NoMethodError do
14
+ self.class.const_set :TestErrorClass, Class.new {
15
+ include EasyAxlsx::ClassConfig
16
+
17
+ as_easy_axlsx_fields :non_existent_method
18
+ }
19
+ end
20
+ end
21
+
22
+ def test_include_easy_axlsx_widths
23
+ assert(ClassTest.easy_axlsx_widths == [1.5, 2.5, 3.5, 4.0])
24
+ end
25
+ end
26
+
27
+ # TODO: Вынести тестовые классы из файлов
28
+ class ClassTestSecond
29
+ include EasyAxlsx::ClassConfig
30
+
31
+ def name
32
+ end
33
+ as_easy_axlsx_field :name
34
+
35
+ def last_name
36
+ end
37
+ as_easy_axlsx_field :last_name
38
+ end
@@ -0,0 +1,15 @@
1
+ Turn.config do |c|
2
+ # use one of output formats:
3
+ # :outline - turn's original case/test outline mode [default]
4
+ # :progress - indicates progress with progress bar
5
+ # :dotted - test/unit's traditional dot-progress mode
6
+ # :pretty - new pretty reporter
7
+ # :marshal - dump output as YAML (normal run mode only)
8
+ # :cue - interactive testing
9
+ c.format = :pretty
10
+ c.trace = true
11
+ c.tests << 'test/**{test,}*{,test}.rb'
12
+ # use humanized test names (works only with :outline format)
13
+ # c.natural = true
14
+ end
15
+ Turn.run
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class TestEasyAxlsx < Minitest::Test
4
+ def setup
5
+ @row_items = (1...3).map { |i| ClassTest.new(id: i, name: "Name#{i}", last_name: "Last Name #{i}") }
6
+ @building_object = EasyAxlsx.build @row_items
7
+ end
8
+
9
+ def test_build_object
10
+ assert(@building_object.is_a? EasyAxlsx::Building)
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'vendor/'
5
+ end
6
+ end
7
+
8
+ require 'bundler/setup'
9
+ Bundler.require
10
+
11
+ if ENV['TRAVIS']
12
+ require 'coveralls'
13
+ Coveralls.wear!
14
+ end
15
+
16
+ require 'minitest/reporters'
17
+
18
+ Minitest::Reporters.use!
19
+ require 'minitest/autorun'
20
+
21
+ class ClassTest
22
+ include EasyAxlsx::ClassConfig
23
+ attr_reader :id, :name, :last_name
24
+
25
+ def initialize(args = {})
26
+ @id = args.fetch(:id)
27
+ @name = args.fetch(:name)
28
+ @last_name = args.fetch(:last_name)
29
+ end
30
+
31
+ def second_name
32
+ end
33
+ as_easy_axlsx_field :second_name
34
+
35
+ as_easy_axlsx_fields :name, :last_name
36
+ as_easy_axlsx_widths 1.5, 2.5, 3.5, 4
37
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy_axlsx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Silaev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-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: axlsx
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ description: Generate axlsx object of an any class. After you can generate xlsx file,
56
+ or change axslx object.
57
+ email:
58
+ - dmsilaev@yandex.ru
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".coveralls.yml"
64
+ - ".gitignore"
65
+ - ".rubocop.yml"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - Gemfile.devtools
69
+ - Guardfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - config/devtools.yml
74
+ - config/flay.yml
75
+ - config/flog.yml
76
+ - config/mutant.yml
77
+ - config/reek.yml
78
+ - config/rubocop.yml
79
+ - config/yardstick.yml
80
+ - easy_axlsx.gemspec
81
+ - lib/easy_axlsx.rb
82
+ - lib/easy_axlsx/builder.rb
83
+ - lib/easy_axlsx/building.rb
84
+ - lib/easy_axlsx/class_config.rb
85
+ - lib/easy_axlsx/version.rb
86
+ - simple.xlsx
87
+ - test/easy_axlsx/test_builder.rb
88
+ - test/easy_axlsx/test_building.rb
89
+ - test/easy_axlsx/test_class_config.rb
90
+ - test/minitest_helper.rb
91
+ - test/test_easy_axlsx.rb
92
+ - test/test_helper.rb
93
+ homepage: ''
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.3
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Generate axlsx object of an any class
117
+ test_files:
118
+ - test/easy_axlsx/test_builder.rb
119
+ - test/easy_axlsx/test_building.rb
120
+ - test/easy_axlsx/test_class_config.rb
121
+ - test/minitest_helper.rb
122
+ - test/test_easy_axlsx.rb
123
+ - test/test_helper.rb
124
+ has_rdoc: