openapply 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +1 -25
- data/README.md +7 -1
- data/lib/openapply/convert.rb +61 -61
- data/lib/openapply/version.rb +1 -1
- data/openapply.gemspec +8 -5
- metadata +2 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7daf1c8615f04294450317b2673835f0861e7fa090677da1ace14d15d11a6eef
|
4
|
+
data.tar.gz: e13d752545d7d5d4b068754ae85fb318982d1b57f06cc86f99865853ebe782b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29abae7f308e955673d1a75d7c43cd8a549fefdfea4b957c461a34dfb15f4f58fc8a3b490be31357dbd1683e039ce819429cdb59c10f010903ee57e1fab3581c
|
7
|
+
data.tar.gz: 75f3cd2d673087d9ef22defbdd2d5066eaae3768ebe861448c0f9fc97baf0a6d507a73b106c2aeb685a8a07e5d128c4357f7efca4bead81b1a91c857a0e2e252
|
data/Gemfile
CHANGED
@@ -7,7 +7,8 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
7
7
|
# ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
|
8
8
|
|
9
9
|
# https://github.com/randym/axlsx/issues/501
|
10
|
-
gem 'axlsx',
|
10
|
+
# gem 'axlsx', git: 'https://github.com/randym/axlsx', branch: 'master'
|
11
|
+
# gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
|
11
12
|
|
12
13
|
# Specify your gem's dependencies in openapply.gemspec
|
13
14
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,11 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/randym/axlsx
|
3
|
-
revision: c8ac844572b25fda358cc01d2104720c4c42f450
|
4
|
-
branch: master
|
5
|
-
specs:
|
6
|
-
axlsx (2.1.0.pre)
|
7
|
-
htmlentities (~> 4.3.4)
|
8
|
-
mimemagic (~> 0.3)
|
9
|
-
nokogiri (>= 1.6.6)
|
10
|
-
rubyzip (>= 1.2.1)
|
11
|
-
|
12
1
|
PATH
|
13
2
|
remote: .
|
14
3
|
specs:
|
15
|
-
openapply (0.2.
|
16
|
-
axlsx
|
4
|
+
openapply (0.2.8)
|
17
5
|
httparty (~> 0.15)
|
18
6
|
json (~> 2.1)
|
19
7
|
net-scp (~> 1.2)
|
20
8
|
net-ssh (~> 4.2)
|
21
|
-
rubyzip (>= 1.2.1)
|
22
9
|
|
23
10
|
GEM
|
24
11
|
remote: https://rubygems.org/
|
@@ -31,27 +18,19 @@ GEM
|
|
31
18
|
diff-lcs (1.3)
|
32
19
|
docile (1.1.5)
|
33
20
|
hashdiff (0.3.7)
|
34
|
-
htmlentities (4.3.4)
|
35
21
|
httparty (0.15.6)
|
36
22
|
multi_xml (>= 0.5.2)
|
37
23
|
json (2.1.0)
|
38
24
|
method_source (0.9.0)
|
39
|
-
mimemagic (0.3.2)
|
40
|
-
mini_portile2 (2.3.0)
|
41
25
|
multi_xml (0.6.0)
|
42
26
|
net-scp (1.2.1)
|
43
27
|
net-ssh (>= 2.6.5)
|
44
28
|
net-ssh (4.2.0)
|
45
|
-
nokogiri (1.8.1)
|
46
|
-
mini_portile2 (~> 2.3.0)
|
47
29
|
pry (0.11.3)
|
48
30
|
coderay (~> 1.1.0)
|
49
31
|
method_source (~> 0.9.0)
|
50
32
|
public_suffix (3.0.1)
|
51
33
|
rake (10.5.0)
|
52
|
-
roo (2.7.1)
|
53
|
-
nokogiri (~> 1)
|
54
|
-
rubyzip (~> 1.1, < 2.0.0)
|
55
34
|
rspec (3.7.0)
|
56
35
|
rspec-core (~> 3.7.0)
|
57
36
|
rspec-expectations (~> 3.7.0)
|
@@ -65,7 +44,6 @@ GEM
|
|
65
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
45
|
rspec-support (~> 3.7.0)
|
67
46
|
rspec-support (3.7.0)
|
68
|
-
rubyzip (1.2.1)
|
69
47
|
safe_yaml (1.0.4)
|
70
48
|
simplecov (0.15.1)
|
71
49
|
docile (~> 1.1.0)
|
@@ -81,12 +59,10 @@ PLATFORMS
|
|
81
59
|
ruby
|
82
60
|
|
83
61
|
DEPENDENCIES
|
84
|
-
axlsx!
|
85
62
|
bundler (~> 1.15)
|
86
63
|
openapply!
|
87
64
|
pry (~> 0.11)
|
88
65
|
rake (~> 10.0)
|
89
|
-
roo (~> 2.7)
|
90
66
|
rspec (~> 3.7)
|
91
67
|
simplecov (~> 0.15)
|
92
68
|
webmock (~> 3.1)
|
data/README.md
CHANGED
@@ -16,11 +16,14 @@ This gem allows ruby access to the OpenApply API v1 - and supports the GET featu
|
|
16
16
|
|
17
17
|
### CHANGE LOG
|
18
18
|
|
19
|
-
* **v0.2.
|
19
|
+
* **v0.2.9** - compatible with 0.2.x - 2017-12-?? *(https://github.com/straydogstudio/axlsx_rails/issues/77)*
|
20
20
|
- allow flattening to work with arrays
|
21
21
|
- allow flattening and reject to work at 2 levels of depth
|
22
22
|
- allow flattening and reject to work at any depth (with recursion?)
|
23
23
|
|
24
|
+
* **v0.2.8** - compatible with 0.2.x - 2017-12-11 *(https://github.com/randym/axlsx/issues/234)*
|
25
|
+
- axlsx - passes tests - but won't run embedded in a rails app - pulling axlsx again!
|
26
|
+
|
24
27
|
* **v0.2.7** - compatible with 0.2.x - 2017-12-10
|
25
28
|
- safely re-enabled axlsx by using the master branch and upgradeing rubyzip
|
26
29
|
|
@@ -176,6 +179,9 @@ csv_string=@oa.students_as_csv_by_statuses(['applied','enrolled'],[:custom_field
|
|
176
179
|
#
|
177
180
|
# send CSV to a remote server as a file - using ssh-keys
|
178
181
|
@oa.send_data_to_remote_server(csv_string, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
|
182
|
+
#
|
183
|
+
# send CSV to a remote server as a file - using ssh-keys - don't check host_key of remote server
|
184
|
+
@oa.send_data_to_remote_server( csv_string, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750', {verify_host_key: false} )
|
179
185
|
|
180
186
|
# Create XLSX file
|
181
187
|
@oa.students_as_xlsx_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {type: :guardians, count: 1, keys: [:id, :name, :address]}, {type: :payments, count: 2, order: :newest, keys: [:date, :amount]} )
|
data/lib/openapply/convert.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'csv'
|
2
|
-
require 'axlsx'
|
2
|
+
# require 'axlsx'
|
3
3
|
require 'net/scp'
|
4
4
|
require 'net/ssh'
|
5
5
|
|
@@ -99,66 +99,66 @@ module Convert
|
|
99
99
|
end
|
100
100
|
|
101
101
|
|
102
|
-
# XLSX CODE
|
103
|
-
###########
|
104
|
-
|
105
|
-
|
106
|
-
# Queries by status to get a list of students details of a given status
|
107
|
-
# and converts the result to a XLSX Object (Axlsx::Package) with headers
|
108
|
-
# (based on keys sent)
|
102
|
+
# # XLSX CODE
|
103
|
+
# ###########
|
109
104
|
#
|
110
|
-
# ==== Attributes
|
111
|
-
# * +status+ - hash to convert to an array
|
112
|
-
# * +flatten_keys+ - an array of keys to bring to the top level
|
113
|
-
# (with this key prepened) -- default (blank does nothing)
|
114
|
-
# * +reject_keys+ - an array of keys to remove from the data -- default (blank does nothing)
|
115
|
-
# * +student_keys+ - [:id, :name] - include student record keys
|
116
|
-
# * +guardian_info+ - include guardian record info {count: 2, keys: [:id, :name]}
|
117
|
-
# * +payment_info+ - include payment info {count: 2, order: :newest, keys: [:date, :amount]}
|
118
|
-
# * guardian & payment info options:
|
119
|
-
# count: 2 -- how many parent or payment records to return)
|
120
|
-
# keys: [:id, :date] -- an array of keys of data to return
|
121
|
-
# order: :newest -- the order to return payments :newest (most recent first - default) or :oldest
|
122
|
-
def students_as_xlsx_by_status( status,
|
123
|
-
flatten_keys=[], reject_keys=[],
|
124
|
-
student_keys=[],
|
125
|
-
guardian_info={}, payment_info={})
|
126
|
-
#
|
127
|
-
check = check_details_keys_validity(flatten_keys, reject_keys)
|
128
|
-
return check unless check.nil? # or check[:error].nil?
|
129
|
-
# check = check_header_keys_validity(student_keys, guardian_info, payment_info)
|
130
|
-
# return check unless check.nil?
|
131
|
-
#
|
132
|
-
students_array = students_as_array_by_status( status,
|
133
|
-
flatten_keys, reject_keys,
|
134
|
-
student_keys, guardian_info, payment_info )
|
135
|
-
#
|
136
|
-
return students_array if students_array.is_a? Hash
|
137
|
-
#
|
138
|
-
students_xlsx = students_array_to_xlsx( students_array )
|
139
|
-
|
140
|
-
# example how to save the xlsx object as a file
|
141
|
-
# students_xlsx.serialize("spec/data/xlsx/students_from_oa.xlsx")
|
142
|
-
|
143
|
-
return students_xlsx
|
144
|
-
end
|
145
|
-
alias_method :students_as_xlsx_by_statuses, :students_as_xlsx_by_status
|
146
|
-
|
147
|
-
|
148
|
-
# Given an array convert to XLSX Object (Axlsx::Package)
|
149
105
|
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
106
|
+
# # Queries by status to get a list of students details of a given status
|
107
|
+
# # and converts the result to a XLSX Object (Axlsx::Package) with headers
|
108
|
+
# # (based on keys sent)
|
109
|
+
# #
|
110
|
+
# # ==== Attributes
|
111
|
+
# # * +status+ - hash to convert to an array
|
112
|
+
# # * +flatten_keys+ - an array of keys to bring to the top level
|
113
|
+
# # (with this key prepened) -- default (blank does nothing)
|
114
|
+
# # * +reject_keys+ - an array of keys to remove from the data -- default (blank does nothing)
|
115
|
+
# # * +student_keys+ - [:id, :name] - include student record keys
|
116
|
+
# # * +guardian_info+ - include guardian record info {count: 2, keys: [:id, :name]}
|
117
|
+
# # * +payment_info+ - include payment info {count: 2, order: :newest, keys: [:date, :amount]}
|
118
|
+
# # * guardian & payment info options:
|
119
|
+
# # count: 2 -- how many parent or payment records to return)
|
120
|
+
# # keys: [:id, :date] -- an array of keys of data to return
|
121
|
+
# # order: :newest -- the order to return payments :newest (most recent first - default) or :oldest
|
122
|
+
# def students_as_xlsx_by_status( status,
|
123
|
+
# flatten_keys=[], reject_keys=[],
|
124
|
+
# student_keys=[],
|
125
|
+
# guardian_info={}, payment_info={})
|
126
|
+
# #
|
127
|
+
# check = check_details_keys_validity(flatten_keys, reject_keys)
|
128
|
+
# return check unless check.nil? # or check[:error].nil?
|
129
|
+
# # check = check_header_keys_validity(student_keys, guardian_info, payment_info)
|
130
|
+
# # return check unless check.nil?
|
131
|
+
# #
|
132
|
+
# students_array = students_as_array_by_status( status,
|
133
|
+
# flatten_keys, reject_keys,
|
134
|
+
# student_keys, guardian_info, payment_info )
|
135
|
+
# #
|
136
|
+
# return students_array if students_array.is_a? Hash
|
137
|
+
# #
|
138
|
+
# students_xlsx = students_array_to_xlsx( students_array )
|
139
|
+
#
|
140
|
+
# # example how to save the xlsx object as a file
|
141
|
+
# # students_xlsx.serialize("spec/data/xlsx/students_from_oa.xlsx")
|
142
|
+
#
|
143
|
+
# return students_xlsx
|
144
|
+
# end
|
145
|
+
# alias_method :students_as_xlsx_by_statuses, :students_as_xlsx_by_status
|
146
|
+
#
|
147
|
+
|
148
|
+
# # Given an array convert to XLSX Object (Axlsx::Package)
|
149
|
+
# #
|
150
|
+
# # ==== Attributes
|
151
|
+
# # +array+ - expects a hash of students_details (should be flattened to use custom fields)
|
152
|
+
# def students_array_to_xlsx(student_array)
|
153
|
+
# xlsx_obj = Axlsx::Package.new do |p|
|
154
|
+
# p.workbook.add_worksheet(:name => "Students from OpenApply") do |sheet|
|
155
|
+
# student_array.each{ |r| sheet.add_row r }
|
156
|
+
# end
|
157
|
+
# # to save the xlsx object as a file
|
158
|
+
# # p.serialize("spec/data/xlsx/students_from_oa.xlsx")
|
159
|
+
# end
|
160
|
+
# return xlsx_obj
|
161
|
+
# end
|
162
162
|
|
163
163
|
|
164
164
|
# ARRAY CODE
|
@@ -307,7 +307,7 @@ module Convert
|
|
307
307
|
# Prep data as necessary for scp
|
308
308
|
# https://www.safaribooksonline.com/library/view/ruby-cookbook/0596523696/ch06s15.html
|
309
309
|
# convert the string to a stringio object (which can act as a file)
|
310
|
-
xfer = data.to_stream() if data.is_a? Axlsx::Package
|
310
|
+
# xfer = data.to_stream() if data.is_a? Axlsx::Package
|
311
311
|
xfer = data if data.is_a? StringIO
|
312
312
|
xfer = StringIO.new( data ) if data.is_a? String
|
313
313
|
xfer = data if data.is_a? File
|
@@ -332,7 +332,7 @@ module Convert
|
|
332
332
|
# === Attributes
|
333
333
|
# * +data+ - is it an Axlsx::Package, Sting, StringIO or a File class?
|
334
334
|
def known_transfer_object?( data )
|
335
|
-
return true if data.is_a? Axlsx::Package
|
335
|
+
# return true if data.is_a? Axlsx::Package
|
336
336
|
return true if data.is_a? StringIO
|
337
337
|
return true if data.is_a? String
|
338
338
|
return true if data.is_a? File
|
data/lib/openapply/version.rb
CHANGED
data/openapply.gemspec
CHANGED
@@ -44,10 +44,13 @@ Gem::Specification.new do |spec|
|
|
44
44
|
# https://github.com/straydogstudio/axlsx_rails/issues/77
|
45
45
|
# gem 'axlsx', git: 'https://github.com/randym/axlsx.git',
|
46
46
|
# ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
|
47
|
-
spec.add_dependency 'axlsx'
|
48
|
-
|
49
|
-
# #
|
50
|
-
|
47
|
+
# spec.add_dependency 'axlsx', "2.1.0.pre"
|
48
|
+
# # https://github.com/randym/axlsx/issues/234
|
49
|
+
# # spec.add_dependency 'zip-zip'
|
50
|
+
#
|
51
|
+
# # # Rubyzip before 1.2.1 has a directory traversal vulnerability: CVE-2017-5946
|
52
|
+
# spec.add_dependency 'rubyzip', '1.2.1'
|
53
|
+
# spec.add_dependency 'rubyzip', '>= 1.2.1'
|
51
54
|
# don't use official release - use above
|
52
55
|
# spec.add_dependency "axlsx", "2.1.0.pre"
|
53
56
|
# spec.add_dependency "rubyzip", "~> 1.2"
|
@@ -58,6 +61,6 @@ Gem::Specification.new do |spec|
|
|
58
61
|
spec.add_development_dependency "rake", "~> 10.0"
|
59
62
|
spec.add_development_dependency "rspec", "~> 3.7"
|
60
63
|
spec.add_development_dependency "pry", "~> 0.11"
|
61
|
-
spec.add_development_dependency "roo", "~> 2.7"
|
64
|
+
# spec.add_development_dependency "roo", "~> 2.7"
|
62
65
|
|
63
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Tihen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -66,34 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.2'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: axlsx
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubyzip
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.2.1
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.2.1
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: simplecov
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,20 +150,6 @@ dependencies:
|
|
178
150
|
- - "~>"
|
179
151
|
- !ruby/object:Gem::Version
|
180
152
|
version: '0.11'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: roo
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '2.7'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '2.7'
|
195
153
|
description:
|
196
154
|
email:
|
197
155
|
- btihen@gmail.com
|