sigaedu_api 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9f748204477d9ca683bec64537a701603d19d0bb5a32e6fcc635213572ae8989
4
+ data.tar.gz: 233bdda4e51c808e9014534ed6706b9cbad168d7a248337103d87fca74a00520
5
+ SHA512:
6
+ metadata.gz: c7ac77291345ca1d7cf4510a873b59967785de55021ee6097025240ce3a141cc0b0d92fb1f267faef2cb0f14f4304c34f98e4aa28f1630a30ded1f416bdf706d
7
+ data.tar.gz: de03006a88ed748281145f07eba62c70e8db26033cb40ab86c2a547cb21d44035063823e9a7dc354cb53ed022dd2fb6c8be24aed5fed1d6ff83ce007f1540c39
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "09:00"
8
+ open-pull-requests-limit: 10
@@ -0,0 +1,20 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ spec:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby: ["4.0"]
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ bundler-cache: true
20
+ - run: bundle exec rake spec
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /bin/exec
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.7
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at luizpicolo@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in sigaedu_api.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,259 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sigaedu_api (2.1.0)
5
+ json (>= 2.6, < 3.0)
6
+ mechanize (>= 2.9, < 3.0)
7
+ nokogiri (>= 1.15, < 2.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ action_text-trix (2.1.19)
13
+ railties
14
+ actioncable (8.1.4)
15
+ actionpack (= 8.1.4)
16
+ activesupport (= 8.1.4)
17
+ nio4r (~> 2.0)
18
+ websocket-driver (>= 0.6.1)
19
+ zeitwerk (~> 2.6)
20
+ actionmailbox (8.1.4)
21
+ actionpack (= 8.1.4)
22
+ activejob (= 8.1.4)
23
+ activerecord (= 8.1.4)
24
+ activestorage (= 8.1.4)
25
+ activesupport (= 8.1.4)
26
+ mail (>= 2.8.0)
27
+ actionmailer (8.1.4)
28
+ actionpack (= 8.1.4)
29
+ actionview (= 8.1.4)
30
+ activejob (= 8.1.4)
31
+ activesupport (= 8.1.4)
32
+ mail (>= 2.8.0)
33
+ rails-dom-testing (~> 2.2)
34
+ actionpack (8.1.4)
35
+ actionview (= 8.1.4)
36
+ activesupport (= 8.1.4)
37
+ nokogiri (>= 1.8.5)
38
+ rack (>= 2.2.4)
39
+ rack-session (>= 1.0.1)
40
+ rack-test (>= 0.6.3)
41
+ rails-dom-testing (~> 2.2)
42
+ rails-html-sanitizer (~> 1.6)
43
+ useragent (~> 0.16)
44
+ actiontext (8.1.4)
45
+ action_text-trix (~> 2.1.15)
46
+ actionpack (= 8.1.4)
47
+ activerecord (= 8.1.4)
48
+ activestorage (= 8.1.4)
49
+ activesupport (= 8.1.4)
50
+ globalid (>= 0.6.0)
51
+ nokogiri (>= 1.8.5)
52
+ actionview (8.1.4)
53
+ activesupport (= 8.1.4)
54
+ builder (~> 3.1)
55
+ erubi (~> 1.11)
56
+ rails-dom-testing (~> 2.2)
57
+ rails-html-sanitizer (~> 1.6)
58
+ activejob (8.1.4)
59
+ activesupport (= 8.1.4)
60
+ globalid (>= 0.3.6)
61
+ activemodel (8.1.4)
62
+ activesupport (= 8.1.4)
63
+ activerecord (8.1.4)
64
+ activemodel (= 8.1.4)
65
+ activesupport (= 8.1.4)
66
+ timeout (>= 0.4.0)
67
+ activestorage (8.1.4)
68
+ actionpack (= 8.1.4)
69
+ activejob (= 8.1.4)
70
+ activerecord (= 8.1.4)
71
+ activesupport (= 8.1.4)
72
+ marcel (~> 1.0)
73
+ activesupport (8.1.4)
74
+ base64
75
+ bigdecimal
76
+ concurrent-ruby (~> 1.0, >= 1.3.1)
77
+ connection_pool (>= 2.2.5)
78
+ drb
79
+ i18n (>= 1.6, < 2)
80
+ json
81
+ logger (>= 1.4.2)
82
+ minitest (>= 5.1)
83
+ securerandom (>= 0.3)
84
+ tzinfo (~> 2.0, >= 2.0.5)
85
+ uri (>= 0.13.1)
86
+ addressable (2.9.0)
87
+ public_suffix (>= 2.0.2, < 8.0)
88
+ base64 (0.3.0)
89
+ bigdecimal (4.1.3)
90
+ builder (3.3.0)
91
+ concurrent-ruby (1.3.8)
92
+ connection_pool (3.0.2)
93
+ crass (1.0.7)
94
+ date (3.6.0)
95
+ diff-lcs (1.6.2)
96
+ domain_name (0.7.20261007)
97
+ drb (2.2.3)
98
+ erb (6.0.7)
99
+ erubi (1.13.1)
100
+ globalid (1.4.0)
101
+ activesupport (>= 6.1)
102
+ http-cookie (1.1.6)
103
+ domain_name (~> 0.5)
104
+ i18n (1.15.2)
105
+ concurrent-ruby (~> 1.0)
106
+ io-console (0.9.4)
107
+ irb (1.18.0)
108
+ pp (>= 0.6.0)
109
+ prism (>= 1.3.0)
110
+ rdoc (>= 4.0.0)
111
+ reline (>= 0.4.2)
112
+ json (2.21.2)
113
+ logger (1.7.0)
114
+ loofah (2.25.2)
115
+ crass (~> 1.0.2)
116
+ nokogiri (>= 1.12.0)
117
+ mail (2.9.1)
118
+ logger
119
+ mini_mime (>= 0.1.1)
120
+ net-imap
121
+ net-pop
122
+ net-smtp
123
+ marcel (1.2.1)
124
+ mechanize (2.14.1)
125
+ addressable (~> 2.8)
126
+ base64
127
+ domain_name (~> 0.5, >= 0.5.20190701)
128
+ http-cookie (~> 1.0, >= 1.0.3)
129
+ mime-types (~> 3.3)
130
+ net-http-digest_auth (~> 1.4, >= 1.4.1)
131
+ net-http-persistent (>= 2.5.2, < 5.0.dev)
132
+ nkf
133
+ nokogiri (~> 1.11, >= 1.11.2)
134
+ rubyntlm (~> 0.6, >= 0.6.3)
135
+ webrick (~> 1.7)
136
+ webrobots (~> 0.1.2)
137
+ mime-types (3.7.0)
138
+ logger
139
+ mime-types-data (~> 3.2025, >= 3.2025.0507)
140
+ mime-types-data (3.2026.1006)
141
+ mini_mime (1.1.5)
142
+ minitest (6.0.6)
143
+ drb (~> 2.0)
144
+ prism (~> 1.5)
145
+ net-http-digest_auth (1.4.1)
146
+ net-http-persistent (4.0.8)
147
+ connection_pool (>= 2.2.4, < 4)
148
+ net-imap (0.6.8)
149
+ date
150
+ net-protocol
151
+ net-pop (0.1.2)
152
+ net-protocol
153
+ net-protocol (0.4.0)
154
+ timeout
155
+ net-smtp (0.5.2)
156
+ net-protocol
157
+ nio4r (2.7.5)
158
+ nkf (0.3.0)
159
+ nokogiri (1.19.4-arm64-darwin)
160
+ racc (~> 1.4)
161
+ pp (0.6.4)
162
+ prettyprint
163
+ prettyprint (0.2.1)
164
+ prism (1.9.0)
165
+ public_suffix (7.0.5)
166
+ racc (1.8.1)
167
+ rack (3.2.7)
168
+ rack-session (2.1.2)
169
+ base64 (>= 0.1.0)
170
+ rack (>= 3.0.0)
171
+ rack-test (2.2.0)
172
+ rack (>= 1.3)
173
+ rackup (2.3.1)
174
+ rack (>= 3)
175
+ rails (8.1.4)
176
+ actioncable (= 8.1.4)
177
+ actionmailbox (= 8.1.4)
178
+ actionmailer (= 8.1.4)
179
+ actionpack (= 8.1.4)
180
+ actiontext (= 8.1.4)
181
+ actionview (= 8.1.4)
182
+ activejob (= 8.1.4)
183
+ activemodel (= 8.1.4)
184
+ activerecord (= 8.1.4)
185
+ activestorage (= 8.1.4)
186
+ activesupport (= 8.1.4)
187
+ bundler (>= 1.15.0)
188
+ railties (= 8.1.4)
189
+ rails-dom-testing (2.3.0)
190
+ activesupport (>= 5.0.0)
191
+ minitest
192
+ nokogiri (>= 1.6)
193
+ rails-html-sanitizer (1.7.1)
194
+ loofah (~> 2.25, >= 2.25.2)
195
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
196
+ railties (8.1.4)
197
+ actionpack (= 8.1.4)
198
+ activesupport (= 8.1.4)
199
+ irb (~> 1.13)
200
+ rackup (>= 1.0.0)
201
+ rake (>= 12.2)
202
+ thor (~> 1.0, >= 1.2.2)
203
+ tsort (>= 0.2)
204
+ zeitwerk (~> 2.6)
205
+ rake (13.4.2)
206
+ rbs (4.2.0)
207
+ logger
208
+ prism (>= 1.6.0)
209
+ tsort
210
+ rdoc (8.1.0)
211
+ erb
212
+ prism (>= 1.6.0)
213
+ rbs (>= 4.0.0)
214
+ tsort
215
+ reline (0.7.0)
216
+ io-console (~> 0.5)
217
+ rspec (3.13.2)
218
+ rspec-core (~> 3.13.0)
219
+ rspec-expectations (~> 3.13.0)
220
+ rspec-mocks (~> 3.13.0)
221
+ rspec-core (3.13.6)
222
+ rspec-support (~> 3.13.0)
223
+ rspec-expectations (3.13.5)
224
+ diff-lcs (>= 1.2.0, < 2.0)
225
+ rspec-support (~> 3.13.0)
226
+ rspec-mocks (3.13.8)
227
+ diff-lcs (>= 1.2.0, < 2.0)
228
+ rspec-support (~> 3.13.0)
229
+ rspec-support (3.13.7)
230
+ rubyntlm (0.6.8)
231
+ base64
232
+ securerandom (0.4.1)
233
+ thor (1.5.0)
234
+ timeout (0.6.1)
235
+ tsort (0.2.0)
236
+ tzinfo (2.0.6)
237
+ concurrent-ruby (~> 1.0)
238
+ uri (1.1.2)
239
+ useragent (0.16.11)
240
+ webrick (1.9.2)
241
+ webrobots (0.1.2)
242
+ websocket-driver (0.8.2)
243
+ base64
244
+ websocket-extensions (>= 0.1.0)
245
+ websocket-extensions (0.1.5)
246
+ zeitwerk (2.8.3)
247
+
248
+ PLATFORMS
249
+ arm64-darwin-23
250
+
251
+ DEPENDENCIES
252
+ bundler (>= 4.0, < 5.0)
253
+ rails (~> 8.1.4)
254
+ rake (>= 13.0, < 14.0)
255
+ rspec (~> 3.13)
256
+ sigaedu_api!
257
+
258
+ BUNDLED WITH
259
+ 4.0.20
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Luiz Picolo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # SigaeduApi
2
+
3
+ Cliente Ruby para consultar dados acadêmicos do SIGA Edu do IFMS.
4
+
5
+ ## Requisitos
6
+
7
+ - Ruby 4.0 ou superior
8
+
9
+ ## Instalação
10
+
11
+ Adicione a gem ao `Gemfile` da aplicação:
12
+
13
+ ```ruby
14
+ gem "sigaedu_api"
15
+ ```
16
+
17
+ Em seguida, execute `bundle install`.
18
+
19
+ ## Uso
20
+
21
+ ```ruby
22
+ require "sigaedu_api"
23
+
24
+ courses = SigaeduApi::AcademicRegistry::Course.new(login, password)
25
+ courses.get_data("Campo Grande")
26
+
27
+ students = SigaeduApi::AcademicRegistry::Student.new(login, password)
28
+ students.get_data("Campo Grande")
29
+
30
+ student_data = SigaeduApi::AcademicRegistry::StudentData.new(login, password)
31
+ student_data.get_data(student_id)
32
+ ```
33
+
34
+ As credenciais são usadas somente para autenticar a sessão no SIGA Edu. Os testes automatizados não acessam o sistema acadêmico.
35
+
36
+ ## Desenvolvimento
37
+
38
+ Depois de clonar o repositório, instale as dependências com `bundle install` e rode a suíte com:
39
+
40
+ ```sh
41
+ bundle exec rake spec
42
+ ```
43
+
44
+ O CI executa os specs em Ruby 4.0 e instala Rails 8.1 como dependência de desenvolvimento para validar a compatibilidade da gem.
45
+
46
+ ## Licença
47
+
48
+ Distribuída sob a licença MIT. Consulte [LICENSE.txt](LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sigaedu_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ require "sigaedu_api/api"
2
+ require "open-uri"
3
+
4
+ module SigaeduApi
5
+ module AcademicRegistry
6
+ class Course
7
+ def initialize(login, password)
8
+ @uri = 'https://academico.ifms.edu.br/administrativo/alunos/panorama'
9
+ @login = login
10
+ @password = password
11
+ @api = SigaeduApi::Api.new
12
+ @api.form(login, password)
13
+ end
14
+
15
+ def get_data(campus = nil)
16
+ array = []
17
+ page = @api.mechanize.get(@uri)
18
+ page.body.scan(/<option value="(\d+)">(.*?)<\/option>/m).each do |id, option|
19
+ campus_name, course_details = option.force_encoding("UTF-8").split("&gt;", 2)
20
+ next if campus && campus_name&.strip != campus
21
+
22
+ course_name, offer_type = course_details.to_s.split(";", 2).last.to_s.split(" - ", 2)
23
+ next if course_name.empty? || offer_type.nil?
24
+
25
+ array << {
26
+ id: id,
27
+ curso: course_name.strip,
28
+ tipo_oferta: offer_type.strip
29
+ }
30
+ end
31
+
32
+ array
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,66 @@
1
+ require 'sigaedu_api/api'
2
+ require 'sigaedu_api/academic_registry/course'
3
+
4
+ module SigaeduApi
5
+ module AcademicRegistry
6
+ class Student
7
+ def initialize(login, password)
8
+ @uri = 'https://academico.ifms.edu.br/administrativo/alunos/panorama'
9
+ @login = login
10
+ @password = password
11
+ @api = SigaeduApi::Api.new
12
+ @api.form(login, password)
13
+ end
14
+
15
+ def attribute_by_position(data, i)
16
+ !data.nil? ? data[i] : ''
17
+ end
18
+
19
+ def get_name(data, i)
20
+ !data.nil? ? attribute_by_position(data, i).scan(/>([^>]*)</)[0][0] : ''
21
+ end
22
+
23
+ def get_id(data, i)
24
+ !data.nil? ? attribute_by_position(data, i).scan(/href\s*=\s*"([^"]*)"/)[0][0].split('/')[3] : ''
25
+ end
26
+
27
+ def get_image(data)
28
+ "https://academico.ifms.edu.br/administrativo/pessoa_fisicas/foto/#{attribute_by_position(data, 7).to_i}"
29
+ end
30
+
31
+ def get_data(campus = nil)
32
+ students = []
33
+ courses = SigaeduApi::AcademicRegistry::Course.new(@login, @password)
34
+ courses.get_data(campus).each do |course|
35
+ uri = "#{@uri}/datatable_lista_estudante_por_campus/#{course[:id]}"
36
+ page = @api.mechanize.get(uri)
37
+ _data = JSON.parse(page.body)['aaData']
38
+ _data.each do |data|
39
+ if attribute_by_position(data, 0) != ""
40
+ students << {
41
+ 'id': get_id(data, 8),
42
+ 'ingresso': attribute_by_position(data, 0),
43
+ 'curso': attribute_by_position(data, 1) ,
44
+ 'identificador_curso': course[:id],
45
+ 'campus': attribute_by_position(data, 2),
46
+ 'polo': attribute_by_position(data, 3),
47
+ 'tipo_oferta': attribute_by_position(data, 4),
48
+ 'turno': attribute_by_position(data, 5),
49
+ 'matricula': attribute_by_position(data, 6),
50
+ 'ra': attribute_by_position(data, 7).to_i,
51
+ 'estudante': get_name(data, 8),
52
+ 'foto': get_image(data),
53
+ 'cpf': attribute_by_position(data, 9),
54
+ 'data_de_nascimento': attribute_by_position(data, 10),
55
+ 'telefone': attribute_by_position(data, 12),
56
+ 'situacao_no_curso': attribute_by_position(data, 13)
57
+ }
58
+ end
59
+ end
60
+ end
61
+
62
+ students
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,30 @@
1
+ require 'sigaedu_api/api'
2
+ require 'sigaedu_api/academic_registry/course'
3
+
4
+ module SigaeduApi
5
+ module AcademicRegistry
6
+ class StudentData
7
+ def initialize(login, password)
8
+ @uri = 'https://academico.ifms.edu.br/administrativo/alunos/ficha_estudante'
9
+ @login = login
10
+ @password = password
11
+ @api = SigaeduApi::Api.new
12
+ @api.form(login, password)
13
+ end
14
+
15
+ def attribute_by_position(data, i)
16
+ doc = Nokogiri::HTML(data.body)
17
+ doc.css('table.table tbody td')[i].text
18
+ end
19
+
20
+ def get_data(student_id = nil)
21
+ uri = "#{@uri}/#{student_id}/dados_academicos"
22
+ page = @api.mechanize.get(uri)
23
+ [{
24
+ 'id_estudante': student_id,
25
+ 'turma': attribute_by_position(page, 1)
26
+ }]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ module SigaeduApi
2
+ class Api
3
+ BASE_URL = "https://academico.ifms.edu.br/administrativo/".freeze
4
+
5
+ def initialize(mechanize: Mechanize.new)
6
+ @mechanize = mechanize
7
+ @mechanize.get(BASE_URL)
8
+ end
9
+
10
+ attr_reader :mechanize
11
+
12
+ def form(login, password)
13
+ form = @mechanize.page.forms.first
14
+ raise "Login form not found" unless form
15
+
16
+ form.field_with(name: "data[Usuario][login]").value = login
17
+ form.field_with(name: "data[Usuario][senha]").value = password
18
+ form.method = "POST"
19
+ form.submit
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module SigaeduApi
2
+ VERSION = "2.1.0"
3
+ end
@@ -0,0 +1,9 @@
1
+ require "mechanize"
2
+ require "open-uri"
3
+ require "json"
4
+ require 'nokogiri'
5
+
6
+ require "sigaedu_api/version"
7
+ require "sigaedu_api/academic_registry/student"
8
+ require "sigaedu_api/academic_registry/course"
9
+ require "sigaedu_api/academic_registry/student_data"
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sigaedu_api/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sigaedu_api"
8
+ spec.version = SigaeduApi::VERSION
9
+ spec.authors = ["Luiz Picolo"]
10
+ spec.email = ["luizpicolo@gmail.com"]
11
+
12
+ spec.summary = "SigaEdu API"
13
+ spec.description = "Gem para gerar uma API com o objetivo de consumir dados do sistemas acadêmico do IFMS"
14
+ spec.homepage = "https://github.com/luizpicolo/sigaedu_api"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match?(%r{^(test|spec|features)/}) || !File.file?(f)
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.required_ruby_version = ">= 4.0"
24
+
25
+ spec.add_dependency "json", ">= 2.6", "< 3.0"
26
+ spec.add_dependency "mechanize", ">= 2.9", "< 3.0"
27
+ spec.add_dependency "nokogiri", ">= 1.15", "< 2.0"
28
+
29
+ spec.add_development_dependency "bundler", ">= 4.0", "< 5.0"
30
+ spec.add_development_dependency "rake", ">= 13.0", "< 14.0"
31
+ spec.add_development_dependency "rails", "~> 8.1.4"
32
+ spec.add_development_dependency "rspec", "~> 3.13"
33
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sigaedu_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Luiz Picolo
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: json
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.6'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '2.6'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3.0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: mechanize
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '2.9'
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.0'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '2.9'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '3.0'
52
+ - !ruby/object:Gem::Dependency
53
+ name: nokogiri
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '1.15'
59
+ - - "<"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '1.15'
69
+ - - "<"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: bundler
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '4.0'
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '5.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '4.0'
89
+ - - "<"
90
+ - !ruby/object:Gem::Version
91
+ version: '5.0'
92
+ - !ruby/object:Gem::Dependency
93
+ name: rake
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '13.0'
99
+ - - "<"
100
+ - !ruby/object:Gem::Version
101
+ version: '14.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '13.0'
109
+ - - "<"
110
+ - !ruby/object:Gem::Version
111
+ version: '14.0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rails
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: 8.1.4
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: 8.1.4
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.13'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '3.13'
140
+ description: Gem para gerar uma API com o objetivo de consumir dados do sistemas acadêmico
141
+ do IFMS
142
+ email:
143
+ - luizpicolo@gmail.com
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".github/dependabot.yml"
149
+ - ".github/workflows/ci.yml"
150
+ - ".gitignore"
151
+ - ".rspec"
152
+ - ".ruby-version"
153
+ - CODE_OF_CONDUCT.md
154
+ - Gemfile
155
+ - Gemfile.lock
156
+ - LICENSE.txt
157
+ - README.md
158
+ - Rakefile
159
+ - bin/console
160
+ - bin/setup
161
+ - lib/sigaedu_api.rb
162
+ - lib/sigaedu_api/academic_registry/course.rb
163
+ - lib/sigaedu_api/academic_registry/student.rb
164
+ - lib/sigaedu_api/academic_registry/student_data.rb
165
+ - lib/sigaedu_api/api.rb
166
+ - lib/sigaedu_api/version.rb
167
+ - sigaedu_api.gemspec
168
+ homepage: https://github.com/luizpicolo/sigaedu_api
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '4.0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubygems_version: 4.0.20
187
+ specification_version: 4
188
+ summary: SigaEdu API
189
+ test_files: []