В Ruby, как вы получаете отправителя, а точнее переменную экземпляра, для которой вызывается метод? - PullRequest
0 голосов
/ 05 июля 2018

Контекст

*ue - это игрушечный проект, который позволяет мне узнать больше о Ruby через интересную задачу использования черт эсперанто.

Проблема

Текущий вызов: сделать respondo iĝu 42 таким же, как respondo = 42.

Текущий заход на посадку

Поскольку = является ключевым словом, оно не может быть псевдонимом (на самом деле на самом деле не является объектом в Ruby). Таким образом, подход, который пришел мне в голову, заключался в том, чтобы уловить немного контекста и заставить iĝu полагаться на переменную экземпляра, которая вызвала метод. Так что в основном то, что по духу делает следующее

def iĝu(value)
  sender = get_sender_by_some_mean
  sender = value
end

Проблема с установкой sender gem

gem sender , похоже, предназначен именно для того, что было описано. Но, к сожалению, мне не удалось установить его из коробки в системе Fedora 28.

gem_make.out:

current directory: /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/sender-1.5.10/ext/sender
/home/psychoslave/.rbenv/versions/2.6.0-preview2/bin/ruby -r ./siteconf20180705-19818-165jcvq.rb extconf.rb
checking for vm_core.h... no
checking for iseq.h... no
checking for eval_intern.h... no
checking for version.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/psychoslave/.rbenv/versions/2.6.0-preview2/bin/$(RUBY_BASE_NAME)
/home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/net/http.rb:938:in `rescue in block in connect': Failed to open TCP connection to cloud.github.com:80 (getaddrinfo: Name or service not known) (SocketError)
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/net/http.rb:935:in `block in connect'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/timeout.rb:103:in `timeout'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/net/http.rb:934:in `connect'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/net/http.rb:919:in `do_start'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/net/http.rb:908:in `start'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/net/http.rb:1454:in `request'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/core-source-0.2.7/lib/contrib/uri_ext.rb:241:in `block in read'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/core-source-0.2.7/lib/contrib/uri_ext.rb:288:in `connect'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/core-source-0.2.7/lib/contrib/uri_ext.rb:236:in `read'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/core-source-0.2.7/lib/contrib/uri_ext.rb:130:in `download'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/core-source-0.2.7/lib/core-source.rb:26:in `block in ensure_core_headers'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/2.6.0/tempfile.rb:295:in `open'
    from /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/gems/core-source-0.2.7/lib/core-source.rb:23:in `ensure_core_headers'
    from extconf.rb:16:in `<main>'
Requesting http://cloud.github.com/downloads/mark-moseley/ruby_core_source/preview_revision.yml

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/psychoslave/.rbenv/versions/2.6.0-preview2/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/sender-1.5.10/mkmf.log

extconf failed, exit code 1

mkmf.log:

have_header: checking for vm_core.h... -------------------- no

"gcc -o conftest -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/x86_64-linux -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/ruby/backward -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0 -I. -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wno-cast-function-type -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -Werror=misleading-indentation -Wno-overlength-strings -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wmissing-noreturn -Wimplicit-fallthrough=0 -Werror=duplicated-cond -Werror=restrict conftest.c  -L. -L/home/psychoslave/.rbenv/versions/2.6.0-preview2/lib -Wl,-rpath,/home/psychoslave/.rbenv/versions/2.6.0-preview2/lib -L. -L/home/psychoslave/.rbenv/versions/2.6.0-preview2/lib  -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/home/psychoslave/.rbenv/versions/2.6.0-preview2/lib -L/home/psychoslave/.rbenv/versions/2.6.0-preview2/lib -lruby-static -lpthread -ldl -lcrypt -lm   -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

"gcc -E -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/x86_64-linux -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/ruby/backward -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0 -I. -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wno-cast-function-type -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -Werror=misleading-indentation -Wno-overlength-strings -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wmissing-noreturn -Wimplicit-fallthrough=0 -Werror=duplicated-cond -Werror=restrict  conftest.c -o conftest.i"
conftest.c:3:10: erreur fatale: vm_core.h : No such file or directory
 #include <vm_core.h>
          ^~~~~~~~~~~
compilation terminée.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <vm_core.h>
/* end */

--------------------

have_header: checking for iseq.h... -------------------- no

"gcc -E -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/x86_64-linux -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/ruby/backward -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0 -I. -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wno-cast-function-type -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -Werror=misleading-indentation -Wno-overlength-strings -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wmissing-noreturn -Wimplicit-fallthrough=0 -Werror=duplicated-cond -Werror=restrict  conftest.c -o conftest.i"
conftest.c:3:10: erreur fatale: iseq.h : No such file or directory
 #include <iseq.h>
          ^~~~~~~~
compilation terminée.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <iseq.h>
/* end */

--------------------

have_header: checking for eval_intern.h... -------------------- no

"gcc -E -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/x86_64-linux -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/ruby/backward -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0 -I. -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wno-cast-function-type -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -Werror=misleading-indentation -Wno-overlength-strings -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wmissing-noreturn -Wimplicit-fallthrough=0 -Werror=duplicated-cond -Werror=restrict  conftest.c -o conftest.i"
conftest.c:3:10: erreur fatale: eval_intern.h : No such file or directory
 #include <eval_intern.h>
          ^~~~~~~~~~~~~~~
compilation terminée.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <eval_intern.h>
/* end */

--------------------

have_header: checking for version.h... -------------------- no

"gcc -E -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/x86_64-linux -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0/ruby/backward -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include/ruby-2.6.0 -I. -I/home/psychoslave/.rbenv/versions/2.6.0-preview2/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wno-cast-function-type -Wunused-variable -Werror=implicit-int -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=deprecated-declarations -Werror=misleading-indentation -Wno-overlength-strings -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wmissing-noreturn -Wimplicit-fallthrough=0 -Werror=duplicated-cond -Werror=restrict  conftest.c -o conftest.i"
conftest.c:3:10: erreur fatale: version.h : No such file or directory
 #include <version.h>
          ^~~~~~~~~~~
compilation terminée.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <version.h>
/* end */

--------------------

Кажется, мне не хватает некоторых библиотек, но я не знаю, как их правильно загрузить. dnf provides не найдено ни одного совпадения, и я не знаю ни gem, ни rbenv, чтобы определить, могут ли они помочь мне найти эти недостающие компоненты.

...