sw_info 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: befd3215ad86efdcd0182b084d13bb8e9e2f80c4073598390748dae60e1f8135
4
+ data.tar.gz: dcb9cb1c6ad5e3eefcb2a3a1ab8818d439a91079483f5b24092bb7b1d9f1ab98
5
+ SHA512:
6
+ metadata.gz: a3e4b15a67866debdef2af0496a67a77ed630cbb8c09a452e157da39e97dfec2f32fd1950a2444b80a14f32e279b87d65f9de432ea276ddaa30864954d464196
7
+ data.tar.gz: 722ede6d6be26f6e5dcef51604fba39a9a6f6312b8511e71abbb825afdcddbeab982b486728866940ecd5f97581b7efaa13c7eacaabc2699dca11584c0858993
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
data/bin/sw_info ADDED
File without changes
data/lib/sw_info.rb ADDED
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'debug'
5
+
6
+ # https://ruby-doc.org/core-3.0.3/File.html
7
+ # Read JSON file
8
+
9
+ # https://ruby-doc.org/stdlib-3.0.3/libdoc/json/rdoc/JSON.html
10
+ # Parse JSON content to Hash
11
+
12
+ # https://github.com/ruby/debug
13
+
14
+ #Cargo toda la data de swapi en la variable JSONDATA como hash
15
+ =begin JSONDATA = JSON.load_file('./swapi.json').each_with_object({}) do |(key, value), hash|
16
+ hash[key] = value
17
+ end
18
+ =end
19
+
20
+ JSONDATA = File.expand_path('swapi.json', __dir__)
21
+
22
+ DATA = JSON.load_file(JSONDATA).each_with_object({}) do |(key, value), hash|
23
+ hash[key] = value
24
+ end
25
+
26
+ #En esta clase voy a querer acceder a esa data dependiendo de la key que me pase
27
+ # y mostrar el atributo que se pida según el método llamado
28
+ class Person
29
+ attr_accessor :data
30
+
31
+ def initialize(data)
32
+ @data = data
33
+ end
34
+
35
+ def name
36
+ @data['name']
37
+ end
38
+
39
+ def birth_year
40
+ @data['birth_year']
41
+ end
42
+
43
+ def eye_color
44
+ @data['eye_color']
45
+ end
46
+
47
+ def hair_color
48
+ @data['hair_color']
49
+ end
50
+
51
+ def skin_color
52
+ @data['skin_color']
53
+ end
54
+
55
+ def id
56
+ @data['id']
57
+ end
58
+
59
+ def height
60
+ @data['height']
61
+ end
62
+
63
+ def mass
64
+ @data['mass']
65
+ end
66
+
67
+ def gender
68
+ @data['gender']
69
+ end
70
+
71
+ def vehicles
72
+
73
+
74
+ def self.all
75
+ debugger
76
+ end
77
+ end
78
+
79
+ class Starship
80
+ attr_accessor :data
81
+
82
+ def initialize(data)
83
+ @data = data
84
+ end
85
+
86
+ def star
87
+ @data['starship']
88
+ end
89
+
90
+ end
91
+
92
+ class Vehicle
93
+ attr_accessor :data
94
+
95
+ def initialize(data)
96
+ @data = data
97
+ end
98
+
99
+ def vehicle
100
+ @data['vehicles']
101
+ end
102
+ end
103
+
104
+
105
+ puts "Hi! I'm Luke Skywalker, I'm your SWAPI helper!"
File without changes
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sw_info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Emilio D. Ballardini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem is a simple wrapper that provides information about the Star
14
+ Wars characters stored in the swapi file.
15
+ email: emilio@ballardini.co
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Rakefile
21
+ - bin/sw_info
22
+ - lib/sw_info.rb
23
+ - test/test_sw_info.rb
24
+ homepage: http://rubygems.org/gems/sw_info
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.2.32
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: A simple gem about SW characters.
47
+ test_files:
48
+ - test/test_sw_info.rb