http://mrubysearch.ongaeshi.me/
RubyKokubanãä½ãã«ããã£ã¦mrubyã®ã½ã¼ã¹ãmgem(mrubyã®RubyGemsã¿ãããªãã¤)ã«ç»é²ãããã½ã¼ã¹ã³ã¼ããç°¡åã«èªããããã«ããããªããã¨æãä½ã£ã¦ã¿ã¾ããã
ä¸æ¥ä¸åã¬ãã¸ããªãææ°ã«æ´æ°ãã¦ã¤ã³ããã¯ã¹ã®åæ§ç¯ãè¡ã£ã¦ãã¾ããæ°ããmgemã追å ãããæã¯ä»ã®ææåã§å¯¾å¿ãã¦ãã¾ã(ãã®ãã¡èªååãããæã§ã)ã
èªåã追å ãã(ãããã¯æ¤ç´¢ããã)mgemã追å ããã¦ããªãï¼ã£ã¦äººã¯ãªã¯ã¨ã¹ãé ããã°è¿½å ããã®ã§æãã¦ä¸ããã mgemãããªãã¦ãmrubyã«é¢ä¿ããããããªã½ã¼ã¹ã³ã¼ãã§ããã追å ãã¾ãã®ã§æ¯éã
â» å人ãµã¤ãã®ããçªç¶åæ¢ãããããããããã¾ããããäºæ¿ä¸ããã
使ãæ¹ã®ä¾1 - "!"ä»ãã®ã¡ã½ããã¯ã©ããã£ã¦ãã¤ã³ãããã®ï¼
ä¾ãã°gsub!
ã®ãããª!ãã¼ã¯ã®ã¤ããã¡ã½ããã¯ã©ããã£ã¦ãã¤ã³ãããã®ãï¼ãç¥ãããã¨ãã¾ããmrubyã§ã¯ ã¡ã½ããåãæååã§æ¸¡ãå¿
è¦ãããã®ã§ãããæãããã«ãã¾ãã!"
ã§æ¤ç´¢ãã¦ã¿ã¾ããã(æååã®çµç«¯ã«å¼ã£ããããã¨ãæå¾
ãã¦ãã¾ã)ã
å°ãä¸ã«è¡ãã¨swapcase!
é¢æ°ããã¤ã³ããã¦ãç®æãè¦ã¤ããã¾ããã
mruby-string-ext/src/string.c#173
mrb_str_swapcase_bang
ã¨ããé¢æ°åã§ãã¤ã³ãããã¦ãã¾ããã!㯠_bangã¨ããååã§ãã¤ã³ãããã¦ããããã§ãã
ä»ã®ã©ã¤ãã©ãªã§ã¯ã©ããªã£ã¦ããã調ã¹ã¦ã¿ã¾ãã
'_bang' in root - mruby search
reverse!
-> mrb_ary_reverse_bangcapitalize!
-> mrb_str_capitalize_bang
ã_bangã¨ããååã«ãªã£ã¦ããã®ã§ããã使ããã¦ããã«ã¼ã«ã ã¨æã£ã¦ããããã§ãã
使ãæ¹ã®ä¾2 - Cã®é¢æ°å ããyieldãããã®ã ãã©
ãããã¯æ§æã使ããããªã£ãã®ã§èª¿ã¹ããã¨ã«ãããããeach
ã¨ããååã®ã¡ã½ããã¯ãããã¯æ§æã使ã£ã¦ããã®ã§ãããæ¢ãã¦ã¿ã¾ãã
'each mrb_define_' in root - mruby search
eachã ãã§ãæ¢ãããã©ããæ¤ç´¢ç²¾åº¦ãä¸ããããã«mrb_define_ãã¼ã¯ã¼ããéãã¦ãã¾ããããã¤ãé¢æ°ãæ¢ãã¦mrb_leapmotion_devicelist_each
é¢æ°ã詳ããèªãäºã«æ±ºãã¾ããã
mruby-leapmotion/src/Leap.cpp#1067
static mrb_value mrb_leapmotion_devicelist_each(mrb_state *mrb, mrb_value self) { mrb_leapmotion_devicelist_t *data = static_cast<mrb_leapmotion_devicelist_t*>(mrb_data_get_ptr(mrb, self, &mrb_leapmotion_devicelist_type)); if (data == NULL) { return mrb_nil_value(); } mrb_value block; mrb_get_args(mrb, "&", &block); std::for_each (data->obj->begin(), data->obj->end(), mrb_each_func_t<Leap::DeviceList::const_iterator::value_type>(mrb, block)); return self; }
mrb_get_args_ã§ãããã¯ããããã®ã"&"
ã§åã£ã¦ããã®ã§ééããªãããã§ããC++ã®ã³ã¼ããªã®ã§STLã使ã£ã¦ãã¾ããmrb_each_func_t
ããå§ã¾ããã³ãã¬ã¼ãé¢æ°ãå¦çã®æ¬ä½ã®ããã§ããmrb_each_func_tã¯åããã¡ã¤ã«å
ã«ããã¾ãã
template <typename T> struct mrb_each_func_t { private: mrb_state *mrb_; mrb_value &block_; public: mrb_each_func_t(mrb_state *mrb, mrb_value &block) : mrb_(mrb), block_(block) {} ~mrb_each_func_t() {} mrb_value operator () (T const &elem) const { return mrb_yield(mrb_, block_, mrb_leapmotion_obj_make(mrb_, elem)); } };
operator ()
å
ã«ãã mrb_yield ããããã¯ãå¼ã³åºãé¢æ°ã®ããã§ãï¼é·ãéã®ãã§ãããã
- mrb_get_args(mrb, "&", &block); ã§ãããã¯ãåãåã
- mrb_yield(mrb, block, value) ã§åãåã£ããããã¯ãå®è¡
ããã°ãããã¨ãmurbyã½ã¼ã¹ã³ã¼ãæ¤ç´¢ã使ã£ã¦åããã¾ããï¼
ãã®ä»ã®åºæ¬çãªä½¿ãæ¹ã¯ãã«ããã©ããã
å é¨ã®è©±
æ§æ
groongaãã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ãå ¼ããã®ã§MySQLçã¯ä½¿ã£ã¦ãã¾ããã
groongaã®CentOSã¸ã®ã¤ã³ã¹ãã¼ã«
å ã«groonga-develãã¤ã³ã¹ãã¼ã«ãã¦ããã¨rroongaã®ã¤ã³ã¹ãã¼ã«ãçãçµããã¾ãã
$ yum install groonga-devel -y $ gem install rroonga
Milkodeã®ãµã¼ãã¼ã¸ã®ã»ããã¢ãã
milkode-webã使ãã¾ãããbundlerã§ç®¡çåºæ¥ãã®ã§ã¨ã£ã¦ã便å©ã§ãã
milkode-web - Milkode web application bundler template for apache passenger https://github.com/y-ken/milkode-web
ããããã¯groonga(rroonga)ãå©ç¨ããã½ã¼ã¹ã³ã¼ãå ¨ææ¤ç´¢ã¨ã³ã¸ã³"Milkode"ãApache Passengerã§è»½å¿«ã«åããæ¹æ³ãã©ããã
ã¬ãã¸ããªä¸è¦§ã®åå¾
mrubyã®ã¬ãã¸ããªã¯GitHubãã追å ãã¾ãã
$ milk add https://github.com/mruby/mruby
mgemã®ã¬ãã¸ããªä¸è¦§ã¯ä»¥ä¸ã®ãããªã¹ã¯ãªããã使ã£ã¦åå¾ãã¦ãã¾ãã
# Create mgem repository list require 'yaml' mgem_dir = File.join(ENV['HOME'], '.mgem') mgem_list = Dir.glob(File.join(mgem_dir, 'mgem-list/*.gem')) repositories = mgem_list.map do |mgem| YAML.load(File.read(mgem))['repository'] end repositories.each do |repo| puts "milk add #{repo} -p git" end
ã³ãã³ãæååãçæãããã®ã§å¾ã¯ã³ãããããªãã·ã§ã«ã¹ã¯ãªããã«ã¾ã¨ãã¦ãµã¼ãã¼ä¸ã§å®è¡ãã¾ãã
$ ruby mklist.rb milk add https://github.com/schmurfy/host-stats.git -p git milk add https://github.com/cremno/mruby-allegro.git -p git milk add https://github.com/ppibburr/mruby-allocate.git -p git . .