sinatra-writeexcel 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +46 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/sinatra/writeexcel/version.rb +5 -0
- data/lib/sinatra/writeexcel.rb +57 -0
- data/sinatra-writeexcel.gemspec +28 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3389473a22ea215e7455899279aa2912d9dc09d8
|
4
|
+
data.tar.gz: 27ebb146a34c3c000bc4c7f1b4652100831e1251
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a60992745b339b73de3c3ef34c2fe0a96a41b17251b69c55b2377ccc6db29ecb80c6282513417dd55dd00cc7d4bd3d5faede547e1caccc684d1ee45c05bebbd
|
7
|
+
data.tar.gz: 73054a7787660cb27c9ecbd5406421e1db5f1f760f150b7d6b57bf946e1701e62c3f77d4472e96d4ad4b40f47c77b028c1be0cefae47187650e153c9e5ca703c
|
data/.gitignore
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
|
24
|
+
|
25
|
+
# Exclude OSX
|
26
|
+
.DS_Store
|
27
|
+
.AppleDouble
|
28
|
+
.LSOverride
|
29
|
+
|
30
|
+
# Icon must end with two \r
|
31
|
+
Icon
|
32
|
+
|
33
|
+
|
34
|
+
# Thumbnails
|
35
|
+
._*
|
36
|
+
|
37
|
+
# Files that might appear on external disk
|
38
|
+
.Spotlight-V100
|
39
|
+
.Trashes
|
40
|
+
|
41
|
+
# Directories potentially created on remote AFP share
|
42
|
+
.AppleDB
|
43
|
+
.AppleDesktop
|
44
|
+
Network Trash Folder
|
45
|
+
Temporary Items
|
46
|
+
.apdisk
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Lincoln Lee
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Sinatra::Writeexcel
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sinatra-writeexcel'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sinatra-writeexcel
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/sinatra-writeexcel/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'sinatra/writeexcel/version'
|
2
|
+
require 'sinatra/base'
|
3
|
+
|
4
|
+
module Sinatra
|
5
|
+
module WriteExcel
|
6
|
+
module Helpers
|
7
|
+
def writeexcel(template = nil, options = {}, locals = {}, &block)
|
8
|
+
headers(
|
9
|
+
'Content-Type' => 'application/vnd.ms-excel',
|
10
|
+
'Content-Disposition' => "attachment; filename=#{template}.xls"
|
11
|
+
)
|
12
|
+
options, template = template, nil if template.is_a?(Hash)
|
13
|
+
template = -> { block } if template.nil?
|
14
|
+
options[:layout] = false
|
15
|
+
render :rxls, template, options, locals
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.registered(app)
|
20
|
+
app.helpers WriteExcel::Helpers
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
register WriteExcel
|
25
|
+
end
|
26
|
+
|
27
|
+
module Tilt
|
28
|
+
class WriteexcelTemplate < Template
|
29
|
+
def initialize_engine
|
30
|
+
return if defined? ::Writeexcel::Workbook
|
31
|
+
require_template_library 'writeexcel'
|
32
|
+
end
|
33
|
+
|
34
|
+
def prepare
|
35
|
+
end
|
36
|
+
|
37
|
+
def evaluate(scope, locals, &block)
|
38
|
+
blob = StringIO.new('')
|
39
|
+
workbook = WriteExcel.new(blob)
|
40
|
+
|
41
|
+
if data.respond_to?(:to_str)
|
42
|
+
locals[:workbook] = workbook
|
43
|
+
super(scope, locals, &block)
|
44
|
+
elsif data.is_a?(Proc)
|
45
|
+
data.call(workbook)
|
46
|
+
end
|
47
|
+
workbook.close
|
48
|
+
blob.string
|
49
|
+
end
|
50
|
+
|
51
|
+
def precompiled_template(_locals)
|
52
|
+
data.to_str
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
register 'rxls', WriteexcelTemplate
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sinatra/writeexcel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sinatra-writeexcel"
|
8
|
+
spec.version = Sinatra::Writeexcel::VERSION
|
9
|
+
spec.authors = ["Lincoln Lee"]
|
10
|
+
spec.email = ["git@lincoln.hk"]
|
11
|
+
spec.summary = "Support for XLS based views"
|
12
|
+
spec.description = "A gem to generate xls documents by using templates."
|
13
|
+
spec.homepage = "https://github.com/linc01n/sinatra-writeexcel"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "sinatra", "~> 1.4"
|
22
|
+
spec.add_dependency "writeexcel", "~> 1.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "rubocop", "~> 0.25"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-writeexcel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lincoln Lee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: writeexcel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.25'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.25'
|
97
|
+
description: A gem to generate xls documents by using templates.
|
98
|
+
email:
|
99
|
+
- git@lincoln.hk
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/sinatra/writeexcel.rb
|
110
|
+
- lib/sinatra/writeexcel/version.rb
|
111
|
+
- sinatra-writeexcel.gemspec
|
112
|
+
homepage: https://github.com/linc01n/sinatra-writeexcel
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.2.2
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Support for XLS based views
|
136
|
+
test_files: []
|