bright 1.0 → 1.1

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: 21ec0c637efbc8a7cf6f4089fc7e5357dc9e0a40616164058ca09b75183b420f
4
- data.tar.gz: f20c064ba1a5a3aa292874b2ae2ce82274e5b426cdd3f71c8d705e93c4c73b65
3
+ metadata.gz: dd99510122d136894a8e1ba1fdfb6bea0c424f355624ca2c68178143fcd7965d
4
+ data.tar.gz: 16b8599ad55c91cf1f925a76da5d49690c49e2315ca63b925b71d31e421de45c
5
5
  SHA512:
6
- metadata.gz: 57e8c1aa2f91505b5d51c2c6b5d0b19502517a9990095904f96f8c4e9b6870b7ae701f8c6d6a9bb750d829dce4341facfcf80be19018dae1633b4296fd5c1376
7
- data.tar.gz: 2260684a855a642a93688037db1ceaa521f6e7f33615c77b95d8e440cd68aad25e5f78073ed170275f22dac779846488e7ba3a51948fa348d8954754608c2884
6
+ metadata.gz: e4499da391786116fef2ef77fbf283fd67f4c4f26f84277f2bf75825d9b2444712f7df8b7bb99ba3279f4c10612addbaaa47dda84ffda2f8e9b4240539d80939
7
+ data.tar.gz: b544283e756c7114aac543d7b7a3c4d6acf87de7b5c58593a96bcafa619628444a7eaa91b0256dada1e28519914d381fc022563dce10814b5e8d0dbccca74736
data/bright.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "bright"
8
8
  spec.version = Bright::VERSION
9
9
  spec.authors = ["Arux Software"]
10
- spec.email = ["sheuer@aruxsoftware.com"]
10
+ spec.email = ["hello@arux.software"]
11
11
  spec.summary = "Framework and tools for dealing with Student Information Systems"
12
12
  spec.description = "Bright is a simple Student Information System API abstraction library used in and sponsored by Arux Software. It is written by Stephen Heuer, Steven Novotny, and contributors. The aim of the project is to abstract as many parts as possible away from the user to offer a consistent interface across all supported Student Information System APIs."
13
13
  spec.homepage = ""
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency "httpi", "~> 2.1"
22
22
  spec.add_runtime_dependency "json", ">= 0"
23
- spec.add_runtime_dependency 'oauth', ">= 0.5.4"
23
+ spec.add_runtime_dependency "oauth", ">= 0.5.4"
24
+ spec.add_runtime_dependency "parallel", "~> 1.2"
24
25
 
25
26
  spec.add_development_dependency "bundler", ">= 2.2.10"
26
27
  spec.add_development_dependency "rake", "~> 12.3.3"
@@ -1,3 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ class Object
4
+ def blank?
5
+ respond_to?(:empty?) ? !!empty? : !self
6
+ end
7
+
8
+ def present?
9
+ !blank?
10
+ end
11
+
12
+ def presence
13
+ self if present?
14
+ end
15
+ end
16
+
17
+ class NilClass
18
+ def blank?
19
+ true
20
+ end
21
+ end
22
+
1
23
  class FalseClass
2
24
  def blank?
3
25
  true
@@ -10,8 +32,24 @@ class TrueClass
10
32
  end
11
33
  end
12
34
 
13
- class Object
35
+ class Array
36
+ alias_method :blank?, :empty?
37
+ end
38
+
39
+ class Hash
40
+ alias_method :blank?, :empty?
41
+ end
42
+
43
+ class String
44
+ BLANK_RE = /\A[[:space:]]*\z/
45
+
46
+ def blank?
47
+ BLANK_RE === self
48
+ end
49
+ end
50
+
51
+ class Numeric
14
52
  def blank?
15
- respond_to?(:empty?) ? empty? : !self
53
+ false
16
54
  end
17
55
  end
@@ -1,3 +1,5 @@
1
+ require 'parallel'
2
+
1
3
  class ResponseCollection
2
4
  include Enumerable
3
5
 
@@ -6,6 +8,8 @@ class ResponseCollection
6
8
  attr_accessor :per_page
7
9
  attr_accessor :load_more_call
8
10
 
11
+ DEFAULT_NO_THREADS = 4
12
+
9
13
  # seed_page, total, per_page, load_more_call
10
14
  def initialize(options = {})
11
15
  @paged_objects = {0 => options[:seed_page]}
@@ -13,24 +17,21 @@ class ResponseCollection
13
17
  @per_page = options[:per_page].to_i
14
18
  @pages = @per_page > 0 ? (@total.to_f / @per_page.to_f).ceil : 0
15
19
  @load_more_call = options[:load_more_call]
20
+ @no_threads = options[:no_threads] || DEFAULT_NO_THREADS
16
21
  end
17
22
 
18
23
  def each
19
- current_page = -1
20
- while (current_page += 1) < @pages do
21
- objects = [@paged_objects[current_page]].flatten.compact
22
- next_page_no = current_page + 1
23
- if load_more_call and @paged_objects[next_page_no].nil? and next_page_no < @pages
24
- next_page_thread = Thread.new do
25
- load_more_call.call(next_page_no)
26
- end
27
- else
28
- next_page_thread = nil
29
- end
24
+ Parallel.each(0..@pages, in_threads: @no_threads) do |current_page|
25
+ objects = if @paged_objects[current_page].present?
26
+ @paged_objects[current_page]
27
+ else
28
+ load_more_call.call(current_page)
29
+ end
30
+ objects = [objects].flatten.compact
31
+ @paged_objects[current_page] = objects if objects.present?
30
32
  objects.each do |obj|
31
33
  yield obj
32
34
  end
33
- @paged_objects[next_page_no] = next_page_thread.value if next_page_thread
34
35
  end
35
36
  end
36
37
 
@@ -55,7 +55,8 @@ module Bright
55
55
  :seed_page => students,
56
56
  :total => total_results,
57
57
  :per_page => params[:limit],
58
- :load_more_call => load_more_call
58
+ :load_more_call => load_more_call,
59
+ :no_threads => options[:no_threads]
59
60
  })
60
61
  else
61
62
  students
@@ -92,7 +93,8 @@ module Bright
92
93
  :seed_page => schools,
93
94
  :total => total_results,
94
95
  :per_page => params[:limit],
95
- :load_more_call => load_more_call
96
+ :load_more_call => load_more_call,
97
+ :no_threads => options[:no_threads]
96
98
  })
97
99
  else
98
100
  schools
@@ -75,7 +75,8 @@ module Bright
75
75
  :seed_page => students,
76
76
  :total => total_results,
77
77
  :per_page => params[:limit],
78
- :load_more_call => load_more_call
78
+ :load_more_call => load_more_call,
79
+ :no_threads => options[:no_threads]
79
80
  })
80
81
  else
81
82
  students
@@ -121,7 +122,8 @@ module Bright
121
122
  :seed_page => schools,
122
123
  :total => total_results,
123
124
  :per_page => params[:limit],
124
- :load_more_call => load_more_call
125
+ :load_more_call => load_more_call,
126
+ :no_threads => options[:no_threads]
125
127
  })
126
128
  else
127
129
  schools
@@ -61,7 +61,8 @@ module Bright
61
61
  :seed_page => students,
62
62
  :total => total_results,
63
63
  :per_page => params[:pagesize],
64
- :load_more_call => load_more_call
64
+ :load_more_call => load_more_call,
65
+ :no_threads => options[:no_threads]
65
66
  })
66
67
  else
67
68
  students
@@ -132,7 +133,8 @@ module Bright
132
133
  :seed_page => schools,
133
134
  :total => total_results,
134
135
  :per_page => params[:pagesize],
135
- :load_more_call => load_more_call
136
+ :load_more_call => load_more_call,
137
+ :no_threads => options[:no_threads]
136
138
  })
137
139
  else
138
140
  schools
@@ -1,3 +1,3 @@
1
1
  module Bright
2
- VERSION = "1.0"
2
+ VERSION = "1.1"
3
3
  end
data/lib/bright.rb CHANGED
@@ -1,30 +1,31 @@
1
- require "bright/version"
2
- require "bright/errors"
1
+ require_relative "bright/version"
2
+ require_relative "bright/errors"
3
3
 
4
- require "bright/helpers/blank_helper.rb"
5
- require "bright/helpers/boolean_parser_helper.rb"
4
+ require_relative "bright/helpers/blank_helper.rb"
5
+ require_relative "bright/helpers/boolean_parser_helper.rb"
6
6
 
7
- require "bright/model"
8
- require "bright/student"
9
- require "bright/address"
10
- require "bright/phone_number"
11
- require "bright/email_address"
12
- require "bright/enrollment"
13
- require "bright/school"
14
- require "bright/contact"
7
+ require_relative "bright/model"
8
+ require_relative "bright/student"
9
+ require_relative "bright/address"
10
+ require_relative "bright/phone_number"
11
+ require_relative "bright/email_address"
12
+ require_relative "bright/enrollment"
13
+ require_relative "bright/school"
14
+ require_relative "bright/contact"
15
15
 
16
16
 
17
- require "bright/connection"
18
- require "bright/response_collection"
19
- require "bright/cursor_response_collection"
17
+ require_relative "bright/connection"
18
+ require_relative "bright/response_collection"
19
+ require_relative "bright/cursor_response_collection"
20
20
 
21
- require "bright/sis_apis/base.rb"
22
- require "bright/sis_apis/tsis.rb"
23
- require "bright/sis_apis/power_school.rb"
24
- require "bright/sis_apis/aeries.rb"
25
- require "bright/sis_apis/infinite_campus.rb"
26
- require "bright/sis_apis/skyward.rb"
27
- require "bright/sis_apis/bright_sis.rb"
21
+ require_relative "bright/sis_apis/base.rb"
22
+ require_relative "bright/sis_apis/tsis.rb"
23
+ require_relative "bright/sis_apis/power_school.rb"
24
+ require_relative "bright/sis_apis/aeries.rb"
25
+ require_relative "bright/sis_apis/infinite_campus.rb"
26
+ require_relative "bright/sis_apis/skyward.rb"
27
+ require_relative "bright/sis_apis/bright_sis.rb"
28
+ require_relative "bright/sis_apis/synergy.rb"
28
29
 
29
30
  module Bright
30
31
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bright
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arux Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpi
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.5.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: parallel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,7 +100,7 @@ description: Bright is a simple Student Information System API abstraction libra
86
100
  away from the user to offer a consistent interface across all supported Student
87
101
  Information System APIs.
88
102
  email:
89
- - sheuer@aruxsoftware.com
103
+ - hello@arux.software
90
104
  executables: []
91
105
  extensions: []
92
106
  extra_rdoc_files: []
@@ -140,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
154
  - !ruby/object:Gem::Version
141
155
  version: '0'
142
156
  requirements: []
143
- rubygems_version: 3.2.3
157
+ rubygems_version: 3.3.7
144
158
  signing_key:
145
159
  specification_version: 4
146
160
  summary: Framework and tools for dealing with Student Information Systems