liri 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f9d01b312e692ebf96669a1d18f78501070267492bf4229c499a772e67eacc53
4
+ data.tar.gz: f451d84f478f770f56748beebdb8c16232342625bb9f4157e23edd99acfee2b6
5
+ SHA512:
6
+ metadata.gz: 6a96596f166550291b4b48b24a54a87415d139332f64f0743f8ee4fd48a1fc60fb30f621aff0bd986aca406d03bb541bd8978e35e203b2faa05934cf8505af23
7
+ data.tar.gz: 0a0f39e5aab585905b5e53ba7d1ba49c83a06495e23498abaf9608a0d71a82829a964a72a1f2fbbb1a5aea62a5f72d779250891840d7493373f7043401f4ae9c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.idea
2
+ /liri
3
+
4
+ *.log
5
+ *.gem
6
+ *.zip
7
+ .rspec_status
8
+
9
+ *.odt#
data/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/.rspec ADDED
@@ -0,0 +1,8 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --order rand
5
+
6
+ # Este archivo define ciertos parámetros para la ejecución de las pruebas unitarias con rspec
7
+ # format: define el formato de los resultados
8
+ # order: define el orden en que se ejecutan las pruebas, rand realiza una ejecución aleatoria
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ Includes:
3
+ - Gemfile
4
+ - lib/**
5
+ - spec/**
6
+ Excludes:
7
+ - bin/*
8
+ - exe/*
9
+ Metrics/BlockLength:
10
+ CountComments: false # count full line comments?
11
+ Max: 25
12
+ Exclude:
13
+ - 'Rakefile'
14
+ - '**/*.rake'
15
+ - 'spec/**/*.rb'
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ liri
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.7.2
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rofaccess @gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Obs.: Al agregar nuevas gemas, el formato debe ser el siguiente:
4
+ # gem 'rake', '~> 13'
5
+ # De este modo se asegura que la versión instalada es igua o mayor que 13.0.0 y menor a 14.0.0
6
+ # Se usa este formato porque cuando la versión cambia de 13 a 14, en teoría la compatibilidad se pierde
7
+ # Más info: https://blog.makeitreal.camp/manejo-de-dependencias-en-ruby-con-bundler/
8
+
9
+ source 'https://rubygems.org'
10
+
11
+ # Specify your gem's dependencies in liri.gemspec
12
+ gemspec
13
+
14
+ # Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax. https://github.com/ruby/rake
15
+ # Se usa para compilar la gema Liri
16
+ gem 'rake', '~> 13'
17
+
18
+ # Behaviour Driven Development for Ruby. https://github.com/rspec/rspec
19
+ # Se usa para testear la gema Liri
20
+ gem 'rspec', '~> 3.10.0'
21
+
22
+ # Fast and easy syntax highlighting for selected languages, written in Ruby. https://github.com/rubychan/coderay
23
+ # Usado por rspec para mostrar los resultados resaltados cuando se guarda el resultado de la ejecución de las pruebas en un archivo html
24
+ gem 'coderay', '~>1'
25
+
26
+ group :development do
27
+ # Ruby static code analyzer and formatter, based on the community Ruby style guide. https://github.com/rubocop-hq/rubocop
28
+ gem 'rubocop', '~>0', require: false
29
+
30
+ # A Ruby Documentation Tool. https://github.com/lsegal/yard
31
+ gem 'yard', '~>0'
32
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,76 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ liri (0.1.0)
5
+ commander (~> 4)
6
+ highline (~> 2)
7
+ i18n (~> 1)
8
+ net-scp (~> 3)
9
+ rubyzip (~> 2)
10
+ to_duration (~> 1)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ ast (2.4.2)
16
+ coderay (1.1.3)
17
+ commander (4.6.0)
18
+ highline (~> 2.0.0)
19
+ concurrent-ruby (1.1.9)
20
+ diff-lcs (1.4.4)
21
+ highline (2.0.3)
22
+ i18n (1.10.0)
23
+ concurrent-ruby (~> 1.0)
24
+ net-scp (3.0.0)
25
+ net-ssh (>= 2.6.5, < 7.0.0)
26
+ net-ssh (6.1.0)
27
+ parallel (1.21.0)
28
+ parser (3.0.2.0)
29
+ ast (~> 2.4.1)
30
+ rainbow (3.0.0)
31
+ rake (13.0.6)
32
+ regexp_parser (2.1.1)
33
+ rexml (3.2.5)
34
+ rspec (3.10.0)
35
+ rspec-core (~> 3.10.0)
36
+ rspec-expectations (~> 3.10.0)
37
+ rspec-mocks (~> 3.10.0)
38
+ rspec-core (3.10.1)
39
+ rspec-support (~> 3.10.0)
40
+ rspec-expectations (3.10.1)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.10.0)
43
+ rspec-mocks (3.10.2)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-support (3.10.2)
47
+ rubocop (0.93.1)
48
+ parallel (~> 1.10)
49
+ parser (>= 2.7.1.5)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8)
52
+ rexml
53
+ rubocop-ast (>= 0.6.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 1.4.0, < 2.0)
56
+ rubocop-ast (1.12.0)
57
+ parser (>= 3.0.1.1)
58
+ ruby-progressbar (1.11.0)
59
+ rubyzip (2.3.2)
60
+ to_duration (1.2.1)
61
+ unicode-display_width (1.8.0)
62
+ yard (0.9.26)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ coderay (~> 1)
69
+ liri!
70
+ rake (~> 13)
71
+ rspec (~> 3.10.0)
72
+ rubocop (~> 0)
73
+ yard (~> 0)
74
+
75
+ BUNDLED WITH
76
+ 2.2.30
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Rodrigo Fernández - Leslie López
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # Liri
2
+
3
+ Sistema que ejecuta pruebas unitarias de manera distribuida dentro de una red de computadoras a fin de aumentar la
4
+ velocidad de ejecución.
5
+
6
+ El sistema Liri está compuesto por dos aplicaciones que están empaquetadas dentro de la gema Liri.
7
+
8
+ Esta gema es compatible con proyectos Ruby o Ruby on Rails que utilicen la gema RSpec.
9
+
10
+ Este es un repositorio que contiene la documentación y el código fuente de un proyecto desarrollado en el contexto de un Trabajo Final de Grado
11
+ para la carrera Ingeniería Informática de la Universidad Nacional de Itapúa con sede en Encarnación - Itapúa - Paraguay.
12
+
13
+ Se recomienda tener las debidas precauciones al momento de utilizar los datos de este proyecto ya que todavía no es una versión final
14
+ estable y no es seguro que algún día llegue a ser estable.
15
+
16
+ ## Instalación
17
+
18
+ Agregar la siguiente línea al Gemfile de su aplicación:
19
+
20
+ ```ruby
21
+ gem 'liri'
22
+ ```
23
+
24
+ y ejecute:
25
+
26
+ $ bundle install
27
+
28
+ o instale la gema:
29
+
30
+ $ gem install liri
31
+
32
+ ## Uso
33
+ Esta gema esta compuesta por dos aplicaciones: una Aplicación Coordinadora y una Aplicación Agente.
34
+
35
+ La Aplicación Coordinadora, coordina la ejecución de las pruebas conectandose con las Aplicaciones Agente.
36
+
37
+ La Aplicación Coordinadora se ejecuta desde la raiz de un proyecto Ruby o Ruby on Rails a través del siguiente comando:
38
+
39
+ $ liri m
40
+
41
+ La Aplicación Agente se encarga de ejecutar las pruebas y enviar los resultados a la Aplicación Coordinadora. Se pueden
42
+ tener tantas Aplicaciones Agente como se desee en un red de computadoras.
43
+
44
+ La Aplicación Coordinadora se puede ejecutar de manera manual cada vez que se desee a través del siguiente comando:
45
+
46
+ $ liri a
47
+
48
+ o bien, se puede instalar como un servicio del sistema, a través del archivo comprimido liriagent.zip que se encuentra
49
+ en la carpeta /installers dentro de este repositorio. Este instalador sólo funciona en sistemas operativos Linux.
50
+
51
+ Una vez descargado el instalador, se debe descomprimir e ingresar desde linea de comandos a la carpeta /bin de la carpeta
52
+ descomprimida y ejecutar el comando:
53
+
54
+ $ ./install.sh
55
+
56
+ Para que funcione el Sistema Liri, las computadoras en donde esten ejecutandose la Aplicación Coordinadora y la Aplicación
57
+ Agente, deben tener configuradas todos los requisitos de la aplicación a probar, por ejemplo, si se va a ejecutar las pruebas
58
+ unitarias de una gema X, si esta gema X requiere una versión específica de Ruby o una conexión a base de datos, este tipo
59
+ de cosas deben configurarse de manera manual.
60
+
61
+ ## Desarrollo
62
+
63
+ ### Pruebas Unitarias
64
+
65
+ Para ejecutar las pruebas unitarias del proyecto, ejecute el comando:
66
+
67
+ $ rake spec
68
+
69
+ Consultar las siguientes fuentes para la implementación de pruebas unitarias:
70
+
71
+ - https://code.tutsplus.com/es/articles/rspec-testing-for-beginners-part-1--cms-26716
72
+ - https://code.tutsplus.com/es/articles/rspec-testing-for-beginners-02--cms-26720
73
+ - https://code.tutsplus.com/articles/rspec-testing-for-beginners-03--cms-26728
74
+ - https://www.betterspecs.org/
75
+
76
+ ### Compilación
77
+ Para compilar la gema:
78
+
79
+ $ rake build
80
+
81
+ Para instalar la gema:
82
+
83
+ $ rake install
84
+
85
+ Para publicar la gema en RubyGems.org
86
+
87
+ $ rake publish
88
+ Antes de publicar la gema se debe actualizar la versión de la misma en el archivo /lib/liri.rb
89
+
90
+ Para realizar un proceso completo:
91
+
92
+ $ rake
93
+
94
+ Este comando compila e instala la gema, además crea una nueva versión del instalador agente dentro de la carpeta /installers
95
+
96
+ ### Detalles de estructura e implementación
97
+ La configuración de las tareas para manejar la gema están dentro del archivo Rakefile.
98
+
99
+ La configuración de los comandos disponibles de la gema están dentro del archivo /exe/liri.
100
+
101
+ Las clases main o clases principales están en los archivos lib/manager/manager.rb y lib/agent/agent.rb
102
+
103
+ ## Buenas Prácticas
104
+ ### Rubocop
105
+ Rubocop es un analizador de código estáticos para user las mejores prácticas al escribir el código.
106
+ Para usar Rubocop, ejecutar el siguiente comando en la terminal:
107
+
108
+ $ rubocop
109
+
110
+ Más información sobre Rubocop en: https://danielcastanera.com/anadir-rubocop-proyecto-rails/
111
+
112
+ ### Documentación
113
+ Para la documentación se usa la gema Yard según las pautas indicadas en:
114
+
115
+ - https://rubydoc.info/gems/yard/file/docs/GettingStarted.md
116
+
117
+ Para generar la documentación ejecutar el comando:
118
+
119
+ $ yard
120
+
121
+ El comando anterior crea una carpeta /doc del cual se tiene que abrir el archivo index.html
122
+ en un navegador
123
+
124
+ Una alternativa a yard es la gema Rdoc que al parecer también es utilizada por Yard:
125
+
126
+ - http://blog.firsthand.ca/2010/09/ruby-rdoc-example.html
127
+ - https://gist.github.com/hunj/f89cabc10c155f06cc3e
128
+
129
+ Para generar la documentación ejecutar comando:
130
+
131
+ $ rdoc
132
+
133
+ El comando anterior crea una carpeta /doc del cual se tiene que abrir el archivo index.html
134
+ en un navegador
135
+
136
+ ## Manejo de dependencias
137
+ Todas las gemas agregadas al Gemfile deben tener el siguiente formato para la versión:
138
+
139
+ $ gem 'rubyzip', '~>2.2'
140
+
141
+ Con el formato especificado, la versión de rubyzip instalada será igual o mayor a 2.2.0 y menor a 3.0.0, porque
142
+ cuando el primer dígito se cambia de 2 a 3, los cambios entre versiones son incompatibles.
143
+ Más información en: https://blog.makeitreal.camp/manejo-de-dependencias-en-ruby-con-bundler/
144
+
145
+ ## Contribución
146
+
147
+ Esta gema no acepta contribuciones porque se encuentra en desarrollo en el contexto de un Trabajo Final de Grado Universitario.
148
+
149
+ ## Licencia
150
+
151
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
152
+
153
+ No nos hacemos responsables de los perjuicios que pueda causar el uso de la información de las documentaciones compartidas y del código
154
+ fuente compartido en este repositorio. Tener en cuenta que toda la información disponible en este repositorio está en proceso de cambio constante.
155
+
156
+ Cualquier uso que se le dé a a los datos contenidos de este repositorio debe ir con la correspondiente referencia hacia este repositorio.
157
+
158
+ ## Código de conducta
159
+
160
+ Everyone interacting in the Liri project's codebases, issue trackers, chat rooms and mailing lists is expected to
161
+ follow the [code of conduct](https://github.com/[USERNAME]/liri/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ # Define la tarea por defecto, esto hace que se ejecute el comando 'rake install' cuando se ejecuta 'rake' en linea de comandos
7
+ # De:
8
+ # - https://medium.com/@stephenagrice/making-a-command-line-ruby-gem-write-build-and-push-aec24c6c49eb
9
+ task :default => :install
10
+
11
+ Rake::Task["build"].clear # Borra la implementación por defecto de build
12
+ # Compila la gema
13
+ # > rake build
14
+ task :build do
15
+ system "gem build " + Liri::NAME + ".gemspec"
16
+ end
17
+
18
+ # El instalador del agente se encuentra en la carpeta /installers/liriagent
19
+ # Esta tarea copia la gema compilada dentro de la carpeta liriagent/lib
20
+ task :update_agent_installer do
21
+ # Obtiene la ubicación en donde se enviará la gema compilada
22
+ liriagent_lib_path = File.expand_path("./installers/liriagent/lib")
23
+ # Escribe un archivo con la versión actual de Liri, la versión indicada en este archivo se usará para instalar y actualizar el agente
24
+ system("echo '#{Liri::VERSION}' > ./installers/liriagent/bin/.liri-version")
25
+ # Obtiene la dirección de la gema compilada
26
+ compiled_gem_file_path = File.join(Dir.pwd,"/#{Liri::NAME}-#{Liri::VERSION}.gem")
27
+ # Se copia la gema compilada a la ubicación deseada
28
+ system "cp #{compiled_gem_file_path} #{liriagent_lib_path}"
29
+ end
30
+
31
+ # El instalador del agente se encuentra en una carpeta llamada liriagent que está en la carpeta que contiene a la carpeta actual del proyecto
32
+ # Esta tarea comprime la carpeta liriagent en un archivo zip
33
+ task :compress_agent_installer do
34
+ # Define el nombre del archivo comprimido
35
+ zip_name = 'liriagent.zip'
36
+ agent_installer_compressed_path = File.expand_path("./installers")
37
+ Dir.chdir(agent_installer_compressed_path) do
38
+ system "zip -r #{zip_name} liriagent/"
39
+ end
40
+ end
41
+
42
+ Rake::Task["install"].clear # Borra la implementación por defecto de install
43
+ # Instala la gema después de compilar
44
+ # > rake install
45
+ # Esta tarea compila la gema, copia la gema en el instalador del agente y crea un nuevo comprimido zip del instalador del agente
46
+ task :install => [:build, :update_agent_installer, :compress_agent_installer] do
47
+ system "gem install " + Liri::NAME + "-" + Liri::VERSION + ".gem"
48
+ end
49
+
50
+ # Publica la gema después de compilar.
51
+ # > rake publish
52
+ task :publish => :build do
53
+ system 'gem push ' + Liri::NAME + "-" + Liri::VERSION + ".gem"
54
+ end
55
+
56
+ Rake::Task["clean"].clear # Borra la implementación por defecto de clean
57
+ # Borra la gema compilada
58
+ # > rake clean
59
+ task :clean do
60
+ system "rm *.gem"
61
+ end
data/bin/bundle ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
data/bin/coderay ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'coderay' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("coderay", "coderay")
data/bin/commander ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'commander' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("commander", "commander")