Skip to content

Commit

Permalink
プラグインをインポート
Browse files Browse the repository at this point in the history
  • Loading branch information
jageishi committed Aug 19, 2021
1 parent d448120 commit 06584f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 49 deletions.
24 changes: 4 additions & 20 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
message("message-1")
message("message-2")
message("message-3")
message("message")
danger.import_plugin("test.rb")

warn("warm-1")
warn("warm-2")
warn("warm-3")
warn("warn")

fail("fail-1")
fail("fail-2")
fail("fail-3")
fail("fail")

markdown("## h2")
markdown("### h3")

table_header = "|テーブル|\n| --- |\n"
table_body = ["aaa", "bbb", "ccc"].map { |s| "| #{s} |\n"}.join
markdown(table_header + table_body)
image_resource_checker.target_densities = ["ldpi"]
image_resource_checker.target_extensions = ["xml"]
image_resource_checker.check
31 changes: 2 additions & 29 deletions test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,8 @@ def target_extensions
end

def check
renamed_files = git.renamed_files
target_files = git.added_files \
+ git.modified_files \
+ renamed_files.map { |f| f[:after] } \
- git.deleted_files \
- renamed_files.map { |f| f[:before] }

regex = /drawable-(#{target_densities.join("|") })\/.*\.(#{target_extensions.join("|")})$/
target_image_files = target_files.filter { |f| regex.match?(f) }

checked_files = []
missing_density_files = []

target_image_files.each do |f|
next if checked_files.include?(f)
target_densities.each do |d|
image_file = f.gsub(/drawable-(#{target_densities.join("|")})/, "drawable-#{d}")
missing_density_files << image_file unless File.exists?(image_file)
checked_files << image_file
end
end

unless missing_density_files.empty?
header = "### 画像ファイルを追加してください:pray:\n"
header << "| ファイル |\n"
header << "| --- |\n"
message = missing_density_files.map { |f| "| `#{f}` |\n" }.join
markdown(header + message)
end
puts target_densities
puts target_extensions
end
end
end

0 comments on commit 06584f9

Please sign in to comment.