barretina 0.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 +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +42 -0
- data/LICENSE +21 -0
- data/README.md +40 -0
- data/bin/bcm +40 -0
- data/lib/barretina/vector_space/extenders.rb +11 -0
- data/lib/barretina/vector_space/vector.rb +57 -0
- data/lib/barretina/vector_space.rb +5 -0
- data/lib/barretina/version.rb +5 -0
- data/lib/barretina.rb +1 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64f8031d289be9f2bff30c99bda0e544fd27f4bb8ff025bfb44e6509bbe9a996
|
4
|
+
data.tar.gz: 9c53a15091e5d3b943a2da39f6ef4ab22eda8744434b68a79098177a93be632d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7fea04d045bf2df3762176110880d17eb4c5110b0a66a2aaf06d587db601e8f1a4d6adf0fee2a67efb1b47f1a18e3c95eb6970f1840bd967189b65eaa51ea2de
|
7
|
+
data.tar.gz: d88e8c6968a659cc6441fc540b70e772bd9d03fbd0d4672ac7ec226dc96fb56c7409ba4bc24d7224bc8b397f9b98a9e8b536d2df975eae03268b192cb705f849
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
barretina (0.1.0)
|
5
|
+
irb (~> 1.15)
|
6
|
+
ruby2d (~> 0.12.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
date (3.4.1)
|
12
|
+
erb (5.0.1)
|
13
|
+
io-console (0.8.0)
|
14
|
+
irb (1.15.2)
|
15
|
+
pp (>= 0.6.0)
|
16
|
+
rdoc (>= 4.0.0)
|
17
|
+
reline (>= 0.4.2)
|
18
|
+
pp (0.6.2)
|
19
|
+
prettyprint
|
20
|
+
prettyprint (0.2.0)
|
21
|
+
psych (5.2.6)
|
22
|
+
date
|
23
|
+
stringio
|
24
|
+
rdoc (6.14.0)
|
25
|
+
erb
|
26
|
+
psych (>= 4.0.0)
|
27
|
+
reline (0.6.1)
|
28
|
+
io-console (~> 0.5)
|
29
|
+
ruby2d (0.12.1)
|
30
|
+
stringio (3.1.7)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
x86_64-linux
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
barretina!
|
38
|
+
irb (~> 1.15)
|
39
|
+
ruby2d (~> 0.12.1)
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
2.6.9
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Ricard Ferrero
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Barretina
|
2
|
+
=========
|
3
|
+
**WORK IN PROGRESS**
|
4
|
+
|
5
|
+
A 2D and 3D figure modeler.
|
6
|
+
|
7
|
+
Or, in other words: my own Blender.
|
8
|
+
|
9
|
+
## Why?
|
10
|
+
|
11
|
+
Well, it's a good question. But maybe the answer isn't good enough: _just for fun_.
|
12
|
+
|
13
|
+
It's a fun, chill and cozy project thah I enjoy doing, and an awesome way to learn while playing on my computer!
|
14
|
+
|
15
|
+
### My diary
|
16
|
+
|
17
|
+
I write in a diary every big commit, and I summarize the evolution of the project.
|
18
|
+
|
19
|
+
[If you feel some interest, take a look to it now: it's free!](diary.md)
|
20
|
+
|
21
|
+
## BCM: Barretina Console Mode
|
22
|
+
|
23
|
+
BCM is a way to run all Barretina's code without the graphic interface. I created with the intention to test while I work on this project.
|
24
|
+
|
25
|
+
Actually, it's IRB but with a particular configuration.
|
26
|
+
|
27
|
+
### Run BCM
|
28
|
+
|
29
|
+
You can run BCM with the `bin/bcm` file:
|
30
|
+
|
31
|
+
```
|
32
|
+
$ bin/bcm
|
33
|
+
BCM - Barretina Console Mode
|
34
|
+
bcm:001:0> p = VectorSpace::Vector.new 1, 5
|
35
|
+
-> #<Vector (1, 5)>
|
36
|
+
bcm:002:0> q = VectorSpace::Vector.new 2, -3
|
37
|
+
-> #<Vector (2, -3)>
|
38
|
+
bcm:003:0> p + q
|
39
|
+
-> #<Vector (3, 2)>
|
40
|
+
```
|
data/bin/bcm
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'barretina'
|
6
|
+
require 'irb'
|
7
|
+
|
8
|
+
|
9
|
+
puts "\e[1mBCM\e[0m - Barretina Console Mode"
|
10
|
+
|
11
|
+
IRB.setup(nil) # El argumento 'nil' es para la ruta de la aplicación, generalmente no es necesaria aquí
|
12
|
+
|
13
|
+
# Ahora puedes configurar IRB.conf
|
14
|
+
IRB.conf[:PROMPT_MODE] = :BCM
|
15
|
+
IRB.conf[:PROMPT] ||= {} # Asegúrate de que el hash de prompts existe
|
16
|
+
IRB.conf[:PROMPT][:BCM] = {
|
17
|
+
:PROMPT_I => "%N:%03n:%i> ", # Prompt para entrada (input)
|
18
|
+
:PROMPT_N => "%N:%03n:%i> ", # Prompt para entrada subsiguiente (next)
|
19
|
+
:PROMPT_S => "%N:%03n:%i%l ", # Prompt para cadenas largas (string)
|
20
|
+
:PROMPT_C => "%N:%03n:%i* ", # Prompt para continuaciones (continuation)
|
21
|
+
:RETURN => "-> %s\n" # Formato de retorno de valores
|
22
|
+
}
|
23
|
+
# IRB.conf[:AP_NAME] = 'bcm'
|
24
|
+
IRB.conf[:IRB_NAME] = 'bcm'
|
25
|
+
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.barretina/bcm/.bcm-history"
|
26
|
+
IRB.conf[:SAVE_HISTORY] = 1000
|
27
|
+
# Opcional: Desactivar la carga de .irbrc si quieres un control total
|
28
|
+
# IRB.conf[:RC] = false
|
29
|
+
|
30
|
+
|
31
|
+
# IRB.start
|
32
|
+
|
33
|
+
workspace = IRB::WorkSpace.new(binding)
|
34
|
+
irb = IRB::Irb.new(workspace)
|
35
|
+
|
36
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
37
|
+
trap("SIGINT") { irb.signal_handle }
|
38
|
+
|
39
|
+
# # Comenzar la consola interactiva
|
40
|
+
catch(:IRB_EXIT) { irb.eval_input }
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VectorSpace
|
4
|
+
class Vector
|
5
|
+
attr_accessor :coordenates
|
6
|
+
|
7
|
+
def initialize *args
|
8
|
+
@coordenates = args
|
9
|
+
end
|
10
|
+
|
11
|
+
def dimension
|
12
|
+
coordenates.count
|
13
|
+
end
|
14
|
+
|
15
|
+
def + vector
|
16
|
+
add(vector, &:sum)
|
17
|
+
end
|
18
|
+
|
19
|
+
def - vector
|
20
|
+
add(vector) { |array| array.inject(:-) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def * scalar
|
24
|
+
Vector.new *coordenates.map { |c| c * scalar }
|
25
|
+
rescue => e
|
26
|
+
raise "Scalar value must be a Numeric instance (recomended Integer or Float), not a #{scalar.class}" unless scalar.is_a? Numeric
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
|
30
|
+
def == vector
|
31
|
+
coordenates == vector.coordenates
|
32
|
+
rescue => e
|
33
|
+
raise "Impossible compare a #{vector.class} to a SpaceVector::Vector" unless vector.is_a? Vector
|
34
|
+
raise e
|
35
|
+
end
|
36
|
+
|
37
|
+
def != vector
|
38
|
+
!(self==vector)
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
"(#{coordenates.join(', ')})"
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def inspect
|
47
|
+
"#<Vector #{self}>"
|
48
|
+
end
|
49
|
+
|
50
|
+
def add vector, &block
|
51
|
+
Vector.new *[coordenates, vector.coordenates].transpose.map(&block)
|
52
|
+
rescue => e
|
53
|
+
raise "Impossible add or substract a #{vector.class} to a SpaceVector::Vector" unless vector.is_a? Vector
|
54
|
+
raise e
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/barretina.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'barretina/vector_space'
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: barretina
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ricard Ferrero
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: ruby2d
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.12.1
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.12.1
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: irb
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.15'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.15'
|
40
|
+
description: |
|
41
|
+
A 2D and 3D figure modeler. Or, in other words: my own Blender.
|
42
|
+
|
43
|
+
It's a fun, chill and cozy project thah I enjoy doing,
|
44
|
+
and an awesome way to learn while playing on my computer!
|
45
|
+
email:
|
46
|
+
- ricard.ferrero.dev@gmail.com
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- bin/bcm
|
56
|
+
- lib/barretina.rb
|
57
|
+
- lib/barretina/vector_space.rb
|
58
|
+
- lib/barretina/vector_space/extenders.rb
|
59
|
+
- lib/barretina/vector_space/vector.rb
|
60
|
+
- lib/barretina/version.rb
|
61
|
+
homepage: https://github.com/ricard-ferrero/barretina
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata:
|
65
|
+
homepage_uri: https://github.com/ricard-ferrero/barretina
|
66
|
+
source_code_uri: https://github.com/ricard-ferrero/barretina
|
67
|
+
documentation_uri: https://github.com/ricard-ferrero/barretina
|
68
|
+
post_install_message: Enjoy Barretina!
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.4.0
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.6.7
|
84
|
+
specification_version: 4
|
85
|
+
summary: A 2D and 3D figure modeler.
|
86
|
+
test_files: []
|