openapply 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b93c4f55575610cef31739e94b05342210d4b84ab3a83aab348731dd972610b
4
- data.tar.gz: 6bd9b5abecfd5fe56da2c840ddee1de81b177a89b2dc24eed9c415a4e75b85b1
3
+ metadata.gz: 7b0c0c8d58f1cd650e0ce2d45e87fb8f66a5e25cc8796214838a9b2bda42b52d
4
+ data.tar.gz: d7405bd5b47e826348cbfd2d39d8f16cd0f5fb2ca7b7c9186ffb4a4c7231e2d2
5
5
  SHA512:
6
- metadata.gz: ee824ba665e7e30e061443bfa4a464e2549390b332dff591ca4b1c9f58ac68b7aff89ef7f1e554fe90fee57be1ddcd79c767e6618e842a971d76aace88304530
7
- data.tar.gz: ea96157ed83ba97ae242adcf6c73592d515bf37b4c73b2ef9b061e2642c633e915d40e959736bb554e9225685bdea6fcba64cd219c74f0c1e0ea3b9330593874
6
+ metadata.gz: 344ce55394f520ed227b31d3e0e78d747b7b3a1001f605502df853951e4cec6f9d70fc9b945c76dca45aa3dc3588fb449676e3d874a93dad27ad70d7789bac14
7
+ data.tar.gz: a500846657c599050a2b6f72e8581e794c85822bc207a2f87c652ce6b6f4d256645dd049e3bbc23d8f90b3865ce6909314a7aa5d15c5510362984c1f4438ea9d
data/Gemfile CHANGED
@@ -2,5 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
+ # # https://github.com/straydogstudio/axlsx_rails/issues/77
6
+ # gem 'axlsx', git: 'https://github.com/randym/axlsx.git',
7
+ # ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
8
+
9
+ # https://github.com/randym/axlsx/issues/501
10
+ gem 'axlsx', git: 'https://github.com/randym/axlsx', branch: 'master'
11
+
5
12
  # Specify your gem's dependencies in openapply.gemspec
6
13
  gemspec
data/Gemfile.lock CHANGED
@@ -1,11 +1,24 @@
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
+
1
12
  PATH
2
13
  remote: .
3
14
  specs:
4
- openapply (0.2.6)
15
+ openapply (0.2.7)
16
+ axlsx
5
17
  httparty (~> 0.15)
6
18
  json (~> 2.1)
7
19
  net-scp (~> 1.2)
8
20
  net-ssh (~> 4.2)
21
+ rubyzip (>= 1.2.1)
9
22
 
10
23
  GEM
11
24
  remote: https://rubygems.org/
@@ -18,19 +31,27 @@ GEM
18
31
  diff-lcs (1.3)
19
32
  docile (1.1.5)
20
33
  hashdiff (0.3.7)
34
+ htmlentities (4.3.4)
21
35
  httparty (0.15.6)
22
36
  multi_xml (>= 0.5.2)
23
37
  json (2.1.0)
24
38
  method_source (0.9.0)
39
+ mimemagic (0.3.2)
40
+ mini_portile2 (2.3.0)
25
41
  multi_xml (0.6.0)
26
42
  net-scp (1.2.1)
27
43
  net-ssh (>= 2.6.5)
28
44
  net-ssh (4.2.0)
45
+ nokogiri (1.8.1)
46
+ mini_portile2 (~> 2.3.0)
29
47
  pry (0.11.3)
30
48
  coderay (~> 1.1.0)
31
49
  method_source (~> 0.9.0)
32
50
  public_suffix (3.0.1)
33
51
  rake (10.5.0)
52
+ roo (2.7.1)
53
+ nokogiri (~> 1)
54
+ rubyzip (~> 1.1, < 2.0.0)
34
55
  rspec (3.7.0)
35
56
  rspec-core (~> 3.7.0)
36
57
  rspec-expectations (~> 3.7.0)
@@ -44,6 +65,7 @@ GEM
44
65
  diff-lcs (>= 1.2.0, < 2.0)
45
66
  rspec-support (~> 3.7.0)
46
67
  rspec-support (3.7.0)
68
+ rubyzip (1.2.1)
47
69
  safe_yaml (1.0.4)
48
70
  simplecov (0.15.1)
49
71
  docile (~> 1.1.0)
@@ -59,10 +81,12 @@ PLATFORMS
59
81
  ruby
60
82
 
61
83
  DEPENDENCIES
84
+ axlsx!
62
85
  bundler (~> 1.15)
63
86
  openapply!
64
87
  pry (~> 0.11)
65
88
  rake (~> 10.0)
89
+ roo (~> 2.7)
66
90
  rspec (~> 3.7)
67
91
  simplecov (~> 0.15)
68
92
  webmock (~> 3.1)
data/README.md CHANGED
@@ -6,7 +6,6 @@ This gem allows ruby access to the OpenApply API v1 - and supports the GET featu
6
6
  ### Still TODO
7
7
 
8
8
  * **add google sheets to convert**
9
- * **update axlsx with rubyzip 1.2.1**
10
9
  * make tests for scp / ssh (at least data type conversions)
11
10
  * allow csv and xlsx reports with default summary info only?
12
11
  * write PUTS methods - *currently api only allows status update*
@@ -17,11 +16,14 @@ This gem allows ruby access to the OpenApply API v1 - and supports the GET featu
17
16
 
18
17
  ### CHANGE LOG
19
18
 
20
- * **v0.2.7** - compatible with 0.2.x - 2017-12-xx
19
+ * **v0.2.8** - compatible with 0.2.x - 2017-12-?? *(https://github.com/straydogstudio/axlsx_rails/issues/77)*
21
20
  - allow flattening to work with arrays
22
21
  - allow flattening and reject to work at 2 levels of depth
23
22
  - allow flattening and reject to work at any depth (with recursion?)
24
23
 
24
+ * **v0.2.7** - compatible with 0.2.x - 2017-12-10
25
+ - safely re-enabled axlsx by using the master branch and upgradeing rubyzip
26
+
25
27
  * **v0.2.6** - compatible with 0.2.x - 2017-12-08
26
28
  - allow ssh/scp options to be passed
27
29
 
@@ -176,13 +178,12 @@ csv_string=@oa.students_as_csv_by_statuses(['applied','enrolled'],[:custom_field
176
178
  @oa.send_data_to_remote_server(csv_string, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
177
179
 
178
180
  # Create XLSX file
179
- # XLSX features DISABLED UNTIL AXLSX can work with RubyZip 1.2.1
180
- # @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]} )
181
+ @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]} )
181
182
  # # multiple status into
182
- # xlsx_obj=@oa.students_as_xlsx_by_statuses(['applied','enrolled'],[:custom_fields], [:parent_guardian], [:id, :name], {type: :guardians, count: 1, keys: [:id, :name, :address]}, {type: :payments, count: 2, order: :newest, keys: [:date, :amount]} )
183
+ xlsx_obj=@oa.students_as_xlsx_by_statuses(['applied','enrolled'],[:custom_fields], [:parent_guardian], [:id, :name], {type: :guardians, count: 1, keys: [:id, :name, :address]}, {type: :payments, count: 2, order: :newest, keys: [:date, :amount]} )
183
184
  # #
184
185
  # # send XLSX to a remote server as a file - using ssh-keys
185
- # @oa.send_data_to_remote_server(xlsx, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.xlsx', '0750')
186
+ @oa.send_data_to_remote_server(xlsx_obj, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.xlsx', '0750')
186
187
  ```
187
188
 
188
189
  #### INDIVIDUAL STUDENT QUERIES
@@ -259,15 +260,13 @@ csv=@oa.students_as_csv_by_status('applied',[:custom_fields], [:parent_guardian]
259
260
  @oa.send_data_to_remote_server(csv, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
260
261
  #
261
262
  # # Create a XLSX package
262
- # disabled until axlsx works with rubyzip 1.2.1
263
- #
264
- # @oa.students_as_xlsx_by_status('applied', nil, nil, [:id, :name], nil, {count: 2, order: :newest, keys: [:date, :amount]} )
263
+ @oa.students_as_xlsx_by_status('applied', nil, nil, [:id, :name], nil, {count: 2, order: :newest, keys: [:date, :amount]} )
265
264
  # # all options
266
- # xlsx=@oa.students_as_xlsx_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
265
+ xlsx_obj=@oa.students_as_xlsx_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
267
266
  # #
268
267
  # # send CSV to a remote server as a file - using ssh-keys
269
268
  # # attributes: csv_string, srv_hostname, srv_username, srv_path_file, file_permissions(0750 - default if not specified)
270
- # @oa.send_data_to_remote_server(xlsx, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
269
+ @oa.send_data_to_remote_server(xlsx_obj, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
271
270
  ```
272
271
 
273
272
  #### CUSTOM GROUP QUERIES - summary data
@@ -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)
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
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)
146
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)
147
149
  #
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
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
@@ -301,24 +301,16 @@ module Convert
301
301
  srv_path_file, srv_file_permissions="0750",
302
302
  ssl_options={}
303
303
  )
304
+ # be sure its a file type that can be sent
305
+ return "Unrecognized Object" unless known_transfer_object?(data)
306
+
307
+ # Prep data as necessary for scp
304
308
  # https://www.safaribooksonline.com/library/view/ruby-cookbook/0596523696/ch06s15.html
305
309
  # convert the string to a stringio object (which can act as a file)
306
-
307
- # just move the file via SCP
308
- xfer = data if data.is_a? File
309
- # convert string into a SteamIO - "FILE" like object
310
+ xfer = data.to_stream() if data.is_a? Axlsx::Package
310
311
  xfer = data if data.is_a? StringIO
311
- # convert string into a SteamIO - "FILE" like object
312
312
  xfer = StringIO.new( data ) if data.is_a? String
313
- # disabled until AXLSX can use rubyzip 1.2.1
314
- # # convert Axlsx object into a SteamIO - "FILE" like object
315
- # xfer = data.to_stream() if data.is_a? Axlsx::Package
316
-
317
- # be sure its a file type that can be sent
318
- return "Unrecognized Object" unless known_transfer_object?(data)
319
-
320
- # verify_host_key = {verify_host_key: false} if options[:verify_host_key].eql? false
321
- # verify_host_key ||= {verify_host_key: true}
313
+ xfer = data if data.is_a? File
322
314
 
323
315
  # http://www.rubydoc.info/github/delano/net-scp/Net/SCP
324
316
  # send the stringio object to the remote host via scp
@@ -340,8 +332,10 @@ module Convert
340
332
  # === Attributes
341
333
  # * +data+ - is it an Axlsx::Package, Sting, StringIO or a File class?
342
334
  def known_transfer_object?( data )
343
- return true if data.is_a? String or data.is_a? Axlsx::Package or
344
- data.is_a? File or data.is_a? StringIO
335
+ return true if data.is_a? Axlsx::Package
336
+ return true if data.is_a? StringIO
337
+ return true if data.is_a? String
338
+ return true if data.is_a? File
345
339
  return false
346
340
  end
347
341
 
@@ -1,3 +1,3 @@
1
1
  module Openapply
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
data/openapply.gemspec CHANGED
@@ -38,9 +38,19 @@ Gem::Specification.new do |spec|
38
38
  # # need this version of axlsx to match roo's rubyzip needs
39
39
  # # axlsx 2.1.0.pre uses rubyzip 1.1.7 - which has a security flaw
40
40
  # # using the newest version of rubyzip 1.2.1 or larger
41
+ # # https://github.com/randym/axlsx/issues/501
42
+ # gem 'axlsx', git: 'https://github.com/randym/axlsx',
43
+ # branch: 'master'
44
+ # https://github.com/straydogstudio/axlsx_rails/issues/77
45
+ # gem 'axlsx', git: 'https://github.com/randym/axlsx.git',
46
+ # ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
47
+ spec.add_dependency 'axlsx'
48
+
49
+ # # Rubyzip before 1.2.1 has a directory traversal vulnerability: CVE-2017-5946
50
+ spec.add_dependency 'rubyzip', '>= 1.2.1'
51
+ # don't use official release - use above
41
52
  # spec.add_dependency "axlsx", "2.1.0.pre"
42
53
  # spec.add_dependency "rubyzip", "~> 1.2"
43
- # spec.add_development_dependency "roo", "~> 2.7"
44
54
 
45
55
  spec.add_development_dependency "simplecov", "~> 0.15"
46
56
  spec.add_development_dependency "webmock" , "~> 3.1"
@@ -48,4 +58,6 @@ Gem::Specification.new do |spec|
48
58
  spec.add_development_dependency "rake", "~> 10.0"
49
59
  spec.add_development_dependency "rspec", "~> 3.7"
50
60
  spec.add_development_dependency "pry", "~> 0.11"
61
+ spec.add_development_dependency "roo", "~> 2.7"
62
+
51
63
  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.6
4
+ version: 0.2.7
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-08 00:00:00.000000000 Z
11
+ date: 2017-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -66,6 +66,34 @@ 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
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: simplecov
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +178,20 @@ dependencies:
150
178
  - - "~>"
151
179
  - !ruby/object:Gem::Version
152
180
  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'
153
195
  description:
154
196
  email:
155
197
  - btihen@gmail.com