Files
ubicloud/bin/pry
Jeremy Evans 4b819d3cb2 Change all create_with_id to create
It hasn't been necessary to use create_with_id since
ebc79622df, in December 2024.

I have plans to introduce:

```ruby
def create_with_id(id, values)
  obj = new(values)
  obj.id = id
  obj.save_changes
end
```

This will make it easier to use the same id when creating
multiple objects.  The first step is removing the existing
uses of create_with_id.
2025-08-06 01:55:51 +09:00

95 lines
2.1 KiB
Ruby
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env ruby
# frozen_string_literal: true
REPL = true
require_relative "../loader"
if Config.production? && ENV["INGEST_KEY"].nil?
puts "INGEST_KEY is not set in production environment. This is not allowed for auditing purposes."
exit(1)
end
require "pry"
if Config.development?
require "awesome_print"
require "awesome_print/ext/sequel"
module AwesomePrint::Sequel
remove_method(:awesome_sequel_document)
def awesome_sequel_document(object)
"#{object} #{awesome_hash(object.values)}"
end
end
end
def dev_project
return unless Config.development?
ac = Account[email: "dev@ubicloud.com"] || Account.create(email: "dev@ubicloud.com")
ac.projects.first || ac.create_project_with_default_policy("default")
end
def udec(*)
UBID.decode(*)
end
opts = Pry::CLI.parse_options
Pry.config.prompt_name = if Config.production?
"\e[41m⚠ %s\e[0m" % "clover-#{Config.rack_env}"
else
"clover-#{Config.rack_env}"
end
if Config.development?
module PryReloader
def evaluate_ruby(code)
begin
Unreloader.reload!
rescue StandardError, ScriptError => e
puts "#{e.class}: #{e.message}"
puts e.backtrace[0...5]
end
super
end
end
Pry.prepend(PryReloader)
end
if ENV["INGEST_KEY"]
PRY_LOGGER = LogDnaBatcher.new(ENV["INGEST_KEY"])
module PryLogger
def evaluate_ruby(code)
@counter ||= 0
@counter += 1
PRY_LOGGER.log("$> #{code.strip}", app: "pry", level: "info", type: "pry_input", counter: @counter)
# Evaluate and capture result
begin
result = super
# Log output
output = result.inspect
output = "#{output[0..500]}..." if output.length > 500
PRY_LOGGER.log(output, app: "pry", level: "info", type: "pry_output", counter: @counter)
result
rescue => e
PRY_LOGGER.log("#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}", app: "pry", level: "error", type: "eval_error", counter: @counter)
raise
end
end
end
at_exit do
PRY_LOGGER.stop
end
Pry.prepend(PryLogger)
end
Pry::CLI.start(opts)