Module: CFO
- Defined in:
- lib/cfo/cfo.rb,
lib/cfo/service.rb,
lib/cfo/version.rb,
lib/cfo/record_filter.rb,
lib/cfo/record_grouper.rb,
lib/cfo/resources/report.rb,
lib/cfo/resources/account.rb,
lib/cfo/resources/cloud_resource.rb
Defined Under Namespace
Modules: RecordFilter, RecordGrouper Classes: Account, CloudResource, Report, Service
Constant Summary collapse
- PROJECT_DIR =
File.(File.join(File.dirname(__FILE__), '..', '..'))
- VERSION =
The version of this CFO Gem / Library.
"0.1.2"- API_VERSION =
This library’s version of the CFO REST API.
"1"
Class Method Summary collapse
-
.connect_to_database(db_file = ENV['DB_CONFIG_FILE']) ⇒ Hash
Connects to the database defined in db_file.
-
.env ⇒ String
Returns the current RACK_ENV, or ‘development’ if not set.
-
.force_timezone ⇒ Object
Forces the ActiveRecord timezone settings, which normally defaults to :local.
-
.read_accounts(account_file = ENV['ACCOUNT_FILE']) ⇒ Array<Account>
Loads account information defined in account_file.
-
.root ⇒ String
Defines the root URI path of the CFO service.
Class Method Details
.connect_to_database(db_file = ENV['DB_CONFIG_FILE']) ⇒ Hash
Connects to the database defined in db_file. Uses the YAML section indexed by CloudCostTracker#env.
13 14 15 |
# File 'lib/cfo/cfo.rb', line 13 def self.connect_to_database(db_file = ENV['DB_CONFIG_FILE']) ::CloudCostTracker.connect_to_database(db_file) end |
.env ⇒ String
Returns the current RACK_ENV, or ‘development’ if not set
7 |
# File 'lib/cfo/cfo.rb', line 7 def self.env ; ::CloudCostTracker.env end |
.force_timezone ⇒ Object
Forces the ActiveRecord timezone settings, which normally defaults to :local. Uncomment the code in this function ONLY if you’re using this CFO as a standalone application, and need to force the time zone. See: api.rubyonrails.org/classes/ActiveRecord/Timestamp.html
40 41 42 |
# File 'lib/cfo/cfo.rb', line 40 def self.force_timezone #ActiveRecord::Base.default_timezone = :utc end |
.read_accounts(account_file = ENV['ACCOUNT_FILE']) ⇒ Array<Account>
Loads account information defined in account_file.
20 21 22 23 24 25 |
# File 'lib/cfo/cfo.rb', line 20 def self.read_accounts(account_file = ENV['ACCOUNT_FILE']) account_hash = ::CloudCostTracker.read_accounts(account_file) account_hash.map do |(account_name, account_info)| account = Account.new(account_info.merge(:name => account_name)) end end |
.root ⇒ String
Defines the root URI path of the CFO service.
31 32 33 |
# File 'lib/cfo/cfo.rb', line 31 def self.root "/api/v#{CFO::API_VERSION}" end |