tads6_carlos 0.2.0 → 1.0.1
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 +4 -4
- data/.gitignore +0 -2
- data/README.md +3 -3
- data/lib/tads6_carlos.rb +68 -1
- data/lib/tads6_carlos/version.rb +1 -1
- metadata +3 -4
- data/lib/tads6_carlos/hello_world.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: acf706a892a52eb39fb41621516b55f3c3a44da52e7bad9370e42237192ce9ad
|
|
4
|
+
data.tar.gz: be2ebfa1dad43ee79dd46b2f1e096e03649b0137f4337c54625c232bddc9e534
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ad118dd40ee4e488205e7f9b57f284eb54de0433cf060de75eb78b51135453a5d926b85c8dc1e5fa421f87d6f722bc1625e35981251c05b01c2307876ea5899
|
|
7
|
+
data.tar.gz: bcf7b934651120bf7420540d9c10fe7049479faf0c93d0f4f3ed0e26f53831dc34f3d6f93ff8ffb4a089fd9b7b92f8b0d1428006d5af2627fadc2dd36ec858cb
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Tads6Carlos
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bem vindo a GEM de Carlos In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tads6_carlos`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
4
|
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Instalação
|
|
8
8
|
|
|
9
9
|
Add this line to your application's Gemfile:
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ Or install it yourself as:
|
|
|
24
24
|
|
|
25
25
|
TODO: Write usage instructions here
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## Desenvolvimento
|
|
28
28
|
|
|
29
29
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
30
|
|
data/lib/tads6_carlos.rb
CHANGED
|
@@ -2,5 +2,72 @@ require "tads6_carlos/version"
|
|
|
2
2
|
require "tads6_carlos/hello_world"
|
|
3
3
|
|
|
4
4
|
module Tads6Carlos
|
|
5
|
-
|
|
5
|
+
class ORM
|
|
6
|
+
def self.criar(*atributos)
|
|
7
|
+
id = proximo_id
|
|
8
|
+
File.open("#{path}/#{id}.yml", "a") do |arquivo|
|
|
9
|
+
obj = self.new atributos
|
|
10
|
+
obj.id = id
|
|
11
|
+
arquivo.puts YAML.dump obj
|
|
12
|
+
return id
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.listar
|
|
17
|
+
@objs = []
|
|
18
|
+
$/ = '\n\n'
|
|
19
|
+
|
|
20
|
+
(1..ultimo_id).each do |id|
|
|
21
|
+
_path = "#{path}/#{id}.yml"
|
|
22
|
+
if File.exist?(_path)
|
|
23
|
+
File.open(_path, "r").each do |obj|
|
|
24
|
+
@objs << YAML.load(obj)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
@objs
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.selecionar(id)
|
|
33
|
+
listar.each do |obj|
|
|
34
|
+
return obj if obj.id == id
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.atualizar(obj)
|
|
39
|
+
FileUtils.rm "#{path}/#{obj.id}.yml"
|
|
40
|
+
File.open("#{path}/#{obj.id}.yml", "a") do |arquivo|
|
|
41
|
+
arquivo.puts YAML.dump obj
|
|
42
|
+
return obj.id
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.remove(id)
|
|
47
|
+
FileUtils.rm "#{path}/#{id}.yml"
|
|
48
|
+
return id
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def self.quantidade_registros
|
|
54
|
+
Dir.glob("#{path}/*.yml").size + 1
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.ultimo_id
|
|
58
|
+
files = Dir.entries("#{path}").sort_by do |file|
|
|
59
|
+
File.ctime("#{path}/#{file}")
|
|
60
|
+
end
|
|
61
|
+
File.basename("#{path}/#{files.last}", ".yml").to_i
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.path
|
|
65
|
+
"db/#{self.to_s.downcase}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.proximo_id
|
|
69
|
+
ultimo_id.to_i + 1
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
.
|
|
6
73
|
end
|
data/lib/tads6_carlos/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tads6_carlos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carlos Henrique Ribeiro
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-10-
|
|
11
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -71,7 +71,6 @@ files:
|
|
|
71
71
|
- bin/console
|
|
72
72
|
- bin/setup
|
|
73
73
|
- lib/tads6_carlos.rb
|
|
74
|
-
- lib/tads6_carlos/hello_world.rb
|
|
75
74
|
- lib/tads6_carlos/version.rb
|
|
76
75
|
- tads6_carlos.gemspec
|
|
77
76
|
homepage: http://www.ifms.edu.br
|
|
@@ -95,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
95
94
|
version: '0'
|
|
96
95
|
requirements: []
|
|
97
96
|
rubyforge_project:
|
|
98
|
-
rubygems_version: 2.7.
|
|
97
|
+
rubygems_version: 2.7.6
|
|
99
98
|
signing_key:
|
|
100
99
|
specification_version: 4
|
|
101
100
|
summary: Gem para ORM para aulas de Tópicos Especiais de TI - IFMS
|