ruby 1.9 上的砂砾警告

发布于 2024-11-16 10:34:45 字数 1845 浏览 1 评论 0原文

我正在学习grit(版本2.4.1)。这是我的基本代码:

#!/usr/bin/env ruby -wKU

require "grit"
repo = Grit::Repo.new("./myproject")

p repo.commits

运行此代码给了我很多警告。正如用户 @Dogbert 所指出的,此 GitHub diff 提供了帮助我删除了其中一些,现在我只得到以下内容:

更新

更改hunk = hunk.map { |block|让块 } 进入 hunk = hunk.map { |blk| yield block } 位于 diff-lcs (v1.1.2) 的第 266 行和第 303 行)删除了这两个警告:

/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/diff-lcs-1.1.2/lib/diff/lcs.rb:266: warning: shadowing outer local variable - block
/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/diff-lcs-1.1.2/lib/diff/lcs.rb:303: warning: shadowing outer local variable - block

更新 2

正如用户 @injekt 所说 此处 process.rb 将在下一个版本中删除。这将消除:

/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/grit-2.4.1/lib/grit/process.rb:289: warning: method redefined; discarding old spawn
/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/grit-2.4.1/lib/grit/process.rb:221: warning: previous definition of spawn was here

UPDATE 3

THX to user @DogBert...

/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/diff-lcs-1.1.2/lib/diff/lcs/hunk.rb:69: warning: method redefined; discarding old flag_context=

...通过将 hunk.rb 的第 68 行从 :attr_accessor 更改为 来消失:attr_reader inside diff-lcs gem

现在我有一个“stackoverflow meta”问题: 这个问题与我有什么关系?

I'm learning grit (version 2.4.1). Here is my basic code:

#!/usr/bin/env ruby -wKU

require "grit"
repo = Grit::Repo.new("./myproject")

p repo.commits

Running this code gave me a lot of warnings. This GitHub diff, as pointed out by user @Dogbert, helped me removing some of them and now I get the only the following:

UPDATE

changing hunk = hunk.map { |block| yield block } into hunk = hunk.map { |blk| yield block } both at lines 266 and 303 of diff-lcs (v1.1.2) removed this two warnings:

/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/diff-lcs-1.1.2/lib/diff/lcs.rb:266: warning: shadowing outer local variable - block
/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/diff-lcs-1.1.2/lib/diff/lcs.rb:303: warning: shadowing outer local variable - block

UPDATE 2

As user @injekt says here process.rb will be removed in the next release. This will get rid of:

/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/grit-2.4.1/lib/grit/process.rb:289: warning: method redefined; discarding old spawn
/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/grit-2.4.1/lib/grit/process.rb:221: warning: previous definition of spawn was here

UPDATE 3

THX to user @DogBert...

/Users/mircospino/.rvm/gems/ruby-1.9.2-p180/gems/diff-lcs-1.1.2/lib/diff/lcs/hunk.rb:69: warning: method redefined; discarding old flag_context=

...Disappeared by changing line 68 of hunk.rb, from :attr_accessor to :attr_reader inside the diff-lcs gem

Now I have a "stackoverflow meta" question:
what I have to do with this question?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年慕年 2024-11-23 10:34:46

我设法通过以下方式删除警告:

This GitHub diff, thx @DogBert

更改了 hunk = hunk.map { |block|让块 } 进入 hunk = hunk.map { |blk| diff-lcs (v1.1.2) 第 266 行和第 303 行的yield block }

正如用户 @injekt 所说,process.rb 将在下一个版本中删除。这将消除此警告:

warning: method redefined; discarding old spawn
warning: previous definition of spawn was here

正如用户 @DogBert 所说,将 hunk.rb 的第 68 行从 :attr_accessor 更改为 diff-lcs gem 内的 :attr_reader 删除警告:方法重新定义;丢弃旧的 flag_context=...

I managed to remove the warnings by:

This GitHub diff, thx to @DogBert

changed hunk = hunk.map { |block| yield block } into hunk = hunk.map { |blk| yield block } both at lines 266 and 303 of diff-lcs (v1.1.2)

As user @injekt says here process.rb will be removed in the next release. This will get rid of this warnings:

warning: method redefined; discarding old spawn
warning: previous definition of spawn was here

As user @DogBert said changing line 68 of hunk.rb, from :attr_accessor to :attr_reader inside the diff-lcs gem removed warning: method redefined; discarding old flag_context=...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文