- 既存のRailsプロジェクトにrubocopを導入する
- rubocopをチームで活用する・・・GitHub Actionsでrubocop自動でチェックする
- 前準備
- rubocop導入
- GitHub Actionsでrubocop
<template> | |
<svg | |
:width="sizeValue" | |
:height="sizeValue" | |
:viewBox="viewboxValue" | |
> | |
<path :d="path" /> | |
</svg> | |
</template> |
default: &default | |
adapter: mysql2 | |
host: <%= ENV['MYSQL_HOST'] || '127.0.0.1' %> | |
port: <%= ENV['MYSQL_PORT'] || 3306 %> | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
timeout: 5000 | |
development: | |
<<: *default | |
database: <%= ENV['MYSQL_DATABASE'] || 'junara_annotate_development' %> |
class BulkUpserter | |
attr_reader :scope, :on_duplicate_key_update, :raise_error, :validate, :batch_size, :reports, :error, :exit_on_error | |
# activerecort-importのon_duplicate_key_updateを使いやすくしたもの | |
# 使い方例 | |
# bulk_upserter = BulkUpserter.new(Blog.limit(100), {'Blog' => [:name], 'Comment' => [:name]}) | |
# bulk_upserter.run {|blog, instances| blog.assign_attributes(name: 'fuga') || instances.add(blog) || blog.comments.build(name: 'piyo') || instances.add(blog)} | |
# | |
# bulk_upserter.reports はactiverecord_importのreportの配列 | |
# => #<BulkUpserter::Reports:0x000055f74b08c4e0 @messages={:Blog=>[#<struct ActiveRecord::Import::Result failed_instances=[#<Blog id: 1, name: nil, edited_at: nil, created_at: "2019-11-23 07:17:30", updated_at: "2019-11-23 10:56:26">], num_inserts=0, ids=[], results=[]>], :Comment=>[#<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=1, ids=[], results=[]>]}> |
gem install levenshtein |
# USAGE | |
# keyword_prediction = KeywordPrediction.new | |
# keyword_prediction.path = './name2prefecture.csv' # set index data | |
# keyword_prediction.load # load index.csv | |
# keyword_prediction.predict('府中市') => [{"name"=>"府中市", "prefecture_name"=>"東京都", "similarity"=>1.0, "keyword"=>"府中市"}, {"name"=>"府中市", "prefecture_name"=>"広島県", "similarword"=>"府中市"}] | |
require 'csv' | |
require 'levenshtein' | |
class KeywordPrediction |