Commit 17886113 by John Doe

added rake task for adding NilmDB nodes

parent c599153e
Showing with 18 additions and 0 deletions
require 'factory_bot_rails'
namespace :nilm do
desc "Add a nilmdb database"
task :add, [:email, :name, :url] => [:environment] do |t, args|
adapter = Nilmdb::Adapter.new(args[:url])
service = CreateNilm.new(adapter)
service.run(name: args[:name], url: args[:url],
owner: User.find_by_email(args[:email]))
if service.success?
puts "created Nilm #{args[:name]} with owner #{args[:email]}"
else
puts args.warnings
puts args.errors
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment