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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2741e4732331faba1bc500ad4681072f0869556bf0b0dc8290226fd808019bf0
4
- data.tar.gz: 9d0d851dcbc1d36b679f48684762c82adbda65004a2288bf2433107352eb3cc4
3
+ metadata.gz: acf706a892a52eb39fb41621516b55f3c3a44da52e7bad9370e42237192ce9ad
4
+ data.tar.gz: be2ebfa1dad43ee79dd46b2f1e096e03649b0137f4337c54625c232bddc9e534
5
5
  SHA512:
6
- metadata.gz: c36f7247bb1958698954e470e19bfedde97a2a88c84194f02cd9e70a0cc8360f62de616d3cc136a5fab1979ac44e35c8cad78ea39f96f02397dcf2b3c61d9f81
7
- data.tar.gz: aca050cfd42d5ae6cf6baaf869a3e6c9578d272b5e7acf308b288d963d418ef65ce35b9b7ff33b3aa03594d6877517c3a775d3919938540f0dfd5a9cdfd33265
6
+ metadata.gz: 2ad118dd40ee4e488205e7f9b57f284eb54de0433cf060de75eb78b51135453a5d926b85c8dc1e5fa421f87d6f722bc1625e35981251c05b01c2307876ea5899
7
+ data.tar.gz: bcf7b934651120bf7420540d9c10fe7049479faf0c93d0f4f3ed0e26f53831dc34f3d6f93ff8ffb4a089fd9b7b92f8b0d1428006d5af2627fadc2dd36ec858cb
data/.gitignore CHANGED
@@ -9,5 +9,3 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
-
13
- *.gem
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Tads6Carlos
2
2
 
3
- Welcome to your new gem! 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.
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
- ## Installation
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
- ## Development
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
- # Your code goes here...
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
@@ -1,3 +1,3 @@
1
1
  module Tads6Carlos
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.1"
3
3
  end
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.2.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-02 00:00:00.000000000 Z
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.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
@@ -1,10 +0,0 @@
1
-
2
-
3
- module Tads6Carlos
4
- class HelloWorld
5
-
6
- def diga(palavra)
7
- palavra
8
- end
9
- end
10
- end