Skip to content

Instantly share code, notes, and snippets.

View pocke's full-sized avatar
⌨️
Pocke is typing...

Masataka Pocke Kuwabara pocke

⌨️
Pocke is typing...
View GitHub Profile
module PrivateBlock
def private(*args, &block)
return super unless block_given?
begin
methods = []
mod = Module.new do
define_method :method_added do |name|
super(name).tap do
methods << name
diff --git a/autoload/iro/ruby.vim.rb b/autoload/iro/ruby.vim.rb
index 9bb1d7b..a638d01 100644
--- a/autoload/iro/ruby.vim.rb
+++ b/autoload/iro/ruby.vim.rb
@@ -11,6 +11,9 @@ module IroVim
source = Vim.evaluate("getbufline(#{bufnr}, 1, '$')").join("\n")
result = Iro::Ruby::Parser.tokens(source)
Vim.command 'let s:result = ' + JSON.generate(result)
+ rescue => ex
+ puts ex.backtrace
diff --git a/imagemagick/trunk/PKGBUILD b/imagemagick/trunk/PKGBUILD
index 4c48742f627..38e36e4ac08 100644
--- a/imagemagick/trunk/PKGBUILD
+++ b/imagemagick/trunk/PKGBUILD
@@ -1,9 +1,9 @@
# $Id$
# Maintainer: Eric Bélanger <[email protected]>
-pkgbase=imagemagick
-pkgname=('imagemagick' 'imagemagick-doc')
#!/usr/bin/env ruby
require 'pathname'
require 'optparse'
$LOAD_PATH.unshift(Pathname(__dir__).join('../lib/').realpath)
require 'rubocop'
pattern, ruby, version = ARGV.options do |opt|
version = RUBY_VERSION
# Requirements: ghq, hub
# Usage: ruby ghq_clone.rb YOUR_ACCOUNT_NAME
gem 'psych', '>= 3.0.1'
require 'octokit'
require 'psych'
require 'pathname'
def token
hub = Pathname(File.expand_path('~/.config/hub'))
class A
using(Module.new do
refine A do
def private_hello
puts 'Hello, real private method!'
end
end
end)
def public_hello
@pocke
pocke / atasgn.rb
Created November 3, 2017 14:08
Automatically assign arguments to instance variables
module Atasgn
def atasgn(method_name)
parameters = instance_method(method_name).parameters
if parameters.any?{|type, _name| type == :opt || type == :key}
raise 'Can not use a parameter with default value'
end
prepend(Module.new do
eval <<~RUBY
def #{method_name}(#{parameters.map do |type, name|
diff --git a/lib/rubocop/node_pattern.rb b/lib/rubocop/node_pattern.rb
index 10da0350..9638590f 100644
--- a/lib/rubocop/node_pattern.rb
+++ b/lib/rubocop/node_pattern.rb
@@ -98,7 +98,7 @@ module RuboCop
# @private
# Builds Ruby code which implements a pattern
class Compiler
- SYMBOL = %r{:(?:[\w+@*/?!<>=~|%^-]+|\[\]=?)}
+ SYMBOL = %r{:(?:[\w+@*/?!<>=~|%^$-]+|\[\]=?)}
diff --git a/lib/rubocop/cop/rails/blank.rb b/lib/rubocop/cop/rails/blank.rb
index 119eed2b..ae2a8e36 100644
--- a/lib/rubocop/cop/rails/blank.rb
+++ b/lib/rubocop/cop/rails/blank.rb
@@ -52,8 +52,7 @@ module RuboCop
(send $_ :!)
(send $_ :nil?)
(send $_ :== (:nil))
- (send nil $_)
- (send (:nil) :== $_)
def foo
return 1
42
# ^^ Lint/UnreachableCode: Unreachable code detected.
end