Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debrideの解析結果から、監視対象のyamlに追記できるコマンドを提供する。 #12

Closed
shakemurasan opened this issue Sep 21, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@shakemurasan
Copy link
Owner

commented Sep 21, 2016

これは別のgemに切り出してもいいかもしれない。

@shakemurasan

This comment has been minimized.

Copy link
Owner Author

commented Dec 23, 2016

別のgemに切り出す。
以下のような感じでいけそう

require "debride"
require "yaml"

class DebrideToYaml
  def debride_to_hash(debride)
    hash = {}
    debride.missing.each do |klass, methods|
      ary = []
      methods.each do |method|
        if debride.method_locations["#{klass}##{method}"]
          ary << "##{method}"
        elsif debride.method_locations["#{klass}::#{method}"]
          ary << ".#{method}"
        end
      end
      unless ary.empty?
        hash.store(klass, ary)
      end
    end
    hash
  end

  def write_yaml(hash)
    yaml = Psych.dump(hash)
    yaml.gsub!("---\n" , "");
    yaml.gsub!("- " , "  - ");
    f = File.open("hoge.yml", "w")
    f.write(yaml)
    f.close()
  end
end

d = Debride.run(ARGV)
d2y = DebrideToYaml.new
d2y.write_yaml(d2y.debride_to_hash(d))
$ ruby debride_to_yaml.rb --rails app
@shakemurasan

This comment has been minimized.

Copy link
Owner Author

commented Dec 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.