testLau 0.0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/swapi.json +328 -0
  3. data/lib/test.rb +58 -0
  4. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0d9f0339aa59a8d0a90df7b16188b097216eb704cdb0456fdc98692d37f96788
4
+ data.tar.gz: 852cc4ab866670e4afee61a8ba6862da7b062d45f754ee7aa9beda6f0180192c
5
+ SHA512:
6
+ metadata.gz: d84d86e7cb3aea0e4bb1457c985816b1f3f571c6881c0372ed13230618ea706817903bf5b3408a7e1e1a742e68f7257becb02ebd575df6eabc3e2e33e9860ace
7
+ data.tar.gz: 9cec42a89b2b23062481eb7d76da389a2c212f26fc9ba4ee7488489c687a67b5272b27535fc4ca9b542dfc3bd27c37d65c5f31aa3af26443e87f46b9e2016446
data/lib/swapi.json ADDED
@@ -0,0 +1,328 @@
1
+ {
2
+ "people": [
3
+ {
4
+ "id": 1,
5
+ "name": "Luke Skywalker",
6
+ "height": "172",
7
+ "mass": "77",
8
+ "hair_color": "blond",
9
+ "skin_color": "fair",
10
+ "eye_color": "blue",
11
+ "birth_year": "19BBY",
12
+ "gender": "male",
13
+ "vehicles": [
14
+ 14,
15
+ 30
16
+ ],
17
+ "starships": [
18
+ 12,
19
+ 22
20
+ ]
21
+ },
22
+ {
23
+ "id": 2,
24
+ "name": "C-3PO",
25
+ "height": "167",
26
+ "mass": "75",
27
+ "hair_color": "n/a",
28
+ "skin_color": "gold",
29
+ "eye_color": "yellow",
30
+ "birth_year": "112BBY",
31
+ "gender": "n/a",
32
+ "vehicles": [],
33
+ "starships": []
34
+ },
35
+ {
36
+ "id": 3,
37
+ "name": "R2-D2",
38
+ "height": "96",
39
+ "mass": "32",
40
+ "hair_color": "n/a",
41
+ "skin_color": "white, blue",
42
+ "eye_color": "red",
43
+ "birth_year": "33BBY",
44
+ "gender": "n/a",
45
+ "vehicles": [],
46
+ "starships": []
47
+ },
48
+ {
49
+ "id": 4,
50
+ "name": "Darth Vader",
51
+ "height": "202",
52
+ "mass": "136",
53
+ "hair_color": "none",
54
+ "skin_color": "white",
55
+ "eye_color": "yellow",
56
+ "birth_year": "41.9BBY",
57
+ "gender": "male",
58
+ "vehicles": [],
59
+ "starships": [
60
+ 13
61
+ ]
62
+ },
63
+ {
64
+ "id": 5,
65
+ "name": "Leia Organa",
66
+ "height": "150",
67
+ "mass": "49",
68
+ "hair_color": "brown",
69
+ "skin_color": "light",
70
+ "eye_color": "brown",
71
+ "birth_year": "19BBY",
72
+ "gender": "female",
73
+ "vehicles": [
74
+ 30
75
+ ],
76
+ "starships": []
77
+ },
78
+ {
79
+ "id": 6,
80
+ "name": "Owen Lars",
81
+ "height": "178",
82
+ "mass": "120",
83
+ "hair_color": "brown, grey",
84
+ "skin_color": "light",
85
+ "eye_color": "blue",
86
+ "birth_year": "52BBY",
87
+ "gender": "male",
88
+ "vehicles": [],
89
+ "starships": []
90
+ },
91
+ {
92
+ "id": 7,
93
+ "name": "Beru Whitesun lars",
94
+ "height": "165",
95
+ "mass": "75",
96
+ "hair_color": "brown",
97
+ "skin_color": "light",
98
+ "eye_color": "blue",
99
+ "birth_year": "47BBY",
100
+ "gender": "female",
101
+ "vehicles": [],
102
+ "starships": []
103
+ },
104
+ {
105
+ "id": 8,
106
+ "name": "R5-D4",
107
+ "height": "97",
108
+ "mass": "32",
109
+ "hair_color": "n/a",
110
+ "skin_color": "white, red",
111
+ "eye_color": "red",
112
+ "birth_year": "unknown",
113
+ "gender": "n/a",
114
+ "vehicles": [],
115
+ "starships": []
116
+ },
117
+ {
118
+ "id": 9,
119
+ "name": "Biggs Darklighter",
120
+ "height": "183",
121
+ "mass": "84",
122
+ "hair_color": "black",
123
+ "skin_color": "light",
124
+ "eye_color": "brown",
125
+ "birth_year": "24BBY",
126
+ "gender": "male",
127
+ "vehicles": [],
128
+ "starships": [
129
+ 12
130
+ ]
131
+ },
132
+ {
133
+ "id": 10,
134
+ "name": "Obi-Wan Kenobi",
135
+ "height": "182",
136
+ "mass": "77",
137
+ "hair_color": "auburn, white",
138
+ "skin_color": "fair",
139
+ "eye_color": "blue-gray",
140
+ "birth_year": "57BBY",
141
+ "gender": "male",
142
+ "vehicles": [
143
+ 38
144
+ ],
145
+ "starships": [
146
+ 48,
147
+ 59,
148
+ 64,
149
+ 65,
150
+ 74
151
+ ]
152
+ }
153
+ ],
154
+ "vehicles": [
155
+ {
156
+ "id": 14,
157
+ "name": "Snowspeeder",
158
+ "model": "t-47 airspeeder",
159
+ "manufacturer": "Incom corporation",
160
+ "cost_in_credits": "unknown",
161
+ "length": "4.5",
162
+ "max_atmosphering_speed": "650",
163
+ "crew": "2",
164
+ "passengers": "0",
165
+ "cargo_capacity": "10",
166
+ "consumables": "none",
167
+ "vehicle_class": "airspeeder"
168
+ },
169
+ {
170
+ "id": 30,
171
+ "name": "Imperial Speeder Bike",
172
+ "model": "74-Z speeder bike",
173
+ "manufacturer": "Aratech Repulsor Company",
174
+ "cost_in_credits": "8000",
175
+ "length": "3",
176
+ "max_atmosphering_speed": "360",
177
+ "crew": "1",
178
+ "passengers": "1",
179
+ "cargo_capacity": "4",
180
+ "consumables": "1 day",
181
+ "vehicle_class": "speeder"
182
+ },
183
+ {
184
+ "id": 38,
185
+ "name": "Tribubble bongo",
186
+ "model": "Tribubble bongo",
187
+ "manufacturer": "Otoh Gunga Bongameken Cooperative",
188
+ "cost_in_credits": "unknown",
189
+ "length": "15",
190
+ "max_atmosphering_speed": "85",
191
+ "crew": "1",
192
+ "passengers": "2",
193
+ "cargo_capacity": "1600",
194
+ "consumables": "unknown",
195
+ "vehicle_class": "submarine"
196
+ }
197
+ ],
198
+ "starships": [
199
+ {
200
+ "id": 12,
201
+ "name": "X-wing",
202
+ "model": "T-65 X-wing",
203
+ "manufacturer": "Incom Corporation",
204
+ "cost_in_credits": "149999",
205
+ "length": "12.5",
206
+ "max_atmosphering_speed": "1050",
207
+ "crew": "1",
208
+ "passengers": "0",
209
+ "cargo_capacity": "110",
210
+ "consumables": "1 week",
211
+ "hyperdrive_rating": "1.0",
212
+ "MGLT": "100",
213
+ "starship_class": "Starfighter"
214
+ },
215
+ {
216
+ "id": 13,
217
+ "name": "TIE Advanced x1",
218
+ "model": "Twin Ion Engine Advanced x1",
219
+ "manufacturer": "Sienar Fleet Systems",
220
+ "cost_in_credits": "unknown",
221
+ "length": "9.2",
222
+ "max_atmosphering_speed": "1200",
223
+ "crew": "1",
224
+ "passengers": "0",
225
+ "cargo_capacity": "150",
226
+ "consumables": "5 days",
227
+ "hyperdrive_rating": "1.0",
228
+ "MGLT": "105",
229
+ "starship_class": "Starfighter"
230
+ },
231
+ {
232
+ "id": 22,
233
+ "name": "Imperial shuttle",
234
+ "model": "Lambda-class T-4a shuttle",
235
+ "manufacturer": "Sienar Fleet Systems",
236
+ "cost_in_credits": "240000",
237
+ "length": "20",
238
+ "max_atmosphering_speed": "850",
239
+ "crew": "6",
240
+ "passengers": "20",
241
+ "cargo_capacity": "80000",
242
+ "consumables": "2 months",
243
+ "hyperdrive_rating": "1.0",
244
+ "MGLT": "50",
245
+ "starship_class": "Armed government transport"
246
+ },
247
+ {
248
+ "id": 48,
249
+ "name": "Jedi starfighter",
250
+ "model": "Delta-7 Aethersprite-class interceptor",
251
+ "manufacturer": "Kuat Systems Engineering",
252
+ "cost_in_credits": "180000",
253
+ "length": "8",
254
+ "max_atmosphering_speed": "1150",
255
+ "crew": "1",
256
+ "passengers": "0",
257
+ "cargo_capacity": "60",
258
+ "consumables": "7 days",
259
+ "hyperdrive_rating": "1.0",
260
+ "MGLT": "unknown",
261
+ "starship_class": "Starfighter"
262
+ },
263
+ {
264
+ "id": 59,
265
+ "name": "Trade Federation cruiser",
266
+ "model": "Providence-class carrier/destroyer",
267
+ "manufacturer": "Rendili StarDrive, Free Dac Volunteers Engineering corps.",
268
+ "cost_in_credits": "125000000",
269
+ "length": "1088",
270
+ "max_atmosphering_speed": "1050",
271
+ "crew": "600",
272
+ "passengers": "48247",
273
+ "cargo_capacity": "50000000",
274
+ "consumables": "4 years",
275
+ "hyperdrive_rating": "1.5",
276
+ "MGLT": "unknown",
277
+ "starship_class": "capital ship"
278
+ },
279
+ {
280
+ "id": 64,
281
+ "name": "Naboo star skiff",
282
+ "model": "J-type star skiff",
283
+ "manufacturer": "Theed Palace Space Vessel Engineering Corps/Nubia Star Drives, Incorporated",
284
+ "cost_in_credits": "unknown",
285
+ "length": "29.2",
286
+ "max_atmosphering_speed": "1050",
287
+ "crew": "3",
288
+ "passengers": "3",
289
+ "cargo_capacity": "unknown",
290
+ "consumables": "unknown",
291
+ "hyperdrive_rating": "0.5",
292
+ "MGLT": "unknown",
293
+ "starship_class": "yacht"
294
+ },
295
+ {
296
+ "id": 65,
297
+ "name": "Jedi Interceptor",
298
+ "model": "Eta-2 Actis-class light interceptor",
299
+ "manufacturer": "Kuat Systems Engineering",
300
+ "cost_in_credits": "320000",
301
+ "length": "5.47",
302
+ "max_atmosphering_speed": "1500",
303
+ "crew": "1",
304
+ "passengers": "0",
305
+ "cargo_capacity": "60",
306
+ "consumables": "2 days",
307
+ "hyperdrive_rating": "1.0",
308
+ "MGLT": "unknown",
309
+ "starship_class": "starfighter"
310
+ },
311
+ {
312
+ "id": 74,
313
+ "name": "Belbullab-22 starfighter",
314
+ "model": "Belbullab-22 starfighter",
315
+ "manufacturer": "Feethan Ottraw Scalable Assemblies",
316
+ "cost_in_credits": "168000",
317
+ "length": "6.71",
318
+ "max_atmosphering_speed": "1100",
319
+ "crew": "1",
320
+ "passengers": "0",
321
+ "cargo_capacity": "140",
322
+ "consumables": "7 days",
323
+ "hyperdrive_rating": "6",
324
+ "MGLT": "unknown",
325
+ "starship_class": "starfighter"
326
+ }
327
+ ]
328
+ }
data/lib/test.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'json'
2
+ require 'debug'
3
+
4
+ module Finder
5
+ def find_by_key_value(key, value)
6
+ @data.select { |p| p[key] == value }
7
+ end
8
+
9
+ def find_by_name(value)
10
+ @data.select { |p| p['name'] == value }
11
+ end
12
+ end
13
+
14
+ class Main
15
+ attr_accessor :db
16
+
17
+ include Finder
18
+
19
+ def initialize(json_file)
20
+ @db = JSON.parse(File.read(json_file))
21
+ end
22
+
23
+ def people
24
+ @db['people']
25
+ end
26
+
27
+ def vehicles
28
+ @db['vehicles']
29
+ end
30
+
31
+ def starships
32
+ @db['starships']
33
+ end
34
+ end
35
+
36
+ class Person < Main
37
+ attr_accessor :data
38
+
39
+ def initialize(db)
40
+ @data = db.people
41
+ end
42
+ end
43
+
44
+ class Vehicles < Main
45
+ attr_accessor :data
46
+
47
+ def initialize(db)
48
+ @data = db.vehicles
49
+ end
50
+ end
51
+
52
+ class Starships < Main
53
+ attr_accessor :data
54
+
55
+ def initialize(db)
56
+ @data = db.starships
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testLau
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Lautaro Mastronardi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A test gem
14
+ email: lautaromastronardi@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/swapi.json
20
+ - lib/test.rb
21
+ homepage: https://rubygems.org/gems/testLau
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.3.7
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Primera Gema
44
+ test_files: []