lib/tasks/web.rake in slack-ruby-client-1.1.0 vs lib/tasks/web.rake in slack-ruby-client-2.0.0
- old
+ new
@@ -1,12 +1,13 @@
# frozen_string_literal: true
-# largely from https://github.com/aki017/slack-ruby-gem
+
require 'json-schema'
require 'erubis'
require 'active_support'
require 'active_support/core_ext'
+# largely from https://github.com/aki017/slack-ruby-gem
namespace :slack do
namespace :web do
namespace :api do
desc 'Update Web API.'
task update: [:git_update] do
@@ -37,14 +38,20 @@
end
result[prefix][name] = parsed
end
+ # Start with a fresh slate
+ Dir.glob('lib/slack/web/api/endpoints/*.rb').each { |file| File.delete(file) }
+ Dir.glob('spec/slack/web/api/endpoints/*_spec.rb').each { |file| File.delete(file) }
+ Dir.glob('bin/commands/*.rb').each { |file| File.delete(file) }
+
method_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/method.erb'))
method_spec_template =
Erubis::Eruby.new(File.read('lib/slack/web/api/templates/method_spec.erb'))
command_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/command.erb'))
- data.each_with_index do |(group, names), index|
+
+ data.each.with_index(1) do |(group, names), index|
printf "%2d/%2d %10s %s\n", index, data.size, group, names.keys
# method
snaked_group = group.tr('.', '_')
rendered_method = method_template.result(group: group, names: names)
File.write "lib/slack/web/api/endpoints/#{snaked_group}.rb", rendered_method