Class: Hatenablog::Configuration
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Hatenablog::Configuration
- Defined in:
- lib/hatenablog/configuration.rb
Constant Summary collapse
- OAUTH_KEYS =
%i(consumer_key consumer_secret access_token access_token_secret user_id blog_id)
- BASIC_KEYS =
%i(api_key user_id blog_id)
Class Method Summary collapse
-
.create(config_file) ⇒ Hatenablog::Configuration
Create a new configuration.
Instance Method Summary collapse
Class Method Details
.create(config_file) ⇒ Hatenablog::Configuration
Create a new configuration.
13 14 15 16 17 |
# File 'lib/hatenablog/configuration.rb', line 13 def self.create(config_file) loaded_config = YAML.load(ERB.new(File.read(config_file)).result) config = new(loaded_config) config.check_valid_or_raise end |
Instance Method Details
#check_valid_or_raise ⇒ Object
19 20 21 22 23 24 |
# File 'lib/hatenablog/configuration.rb', line 19 def check_valid_or_raise unless (lacking_keys = self.send(:lacking_keys)).empty? raise ConfigurationError, "Following keys are not setup. #{lacking_keys.map(&:to_s)}" end self end |