Class: Minisky
- Inherits:
-
Object
- Object
- Minisky
- Includes:
- Requests
- Defined in:
- lib/minisky/errors.rb,
lib/minisky/minisky.rb,
lib/minisky/version.rb,
lib/minisky/requests.rb
Defined Under Namespace
Modules: Requests Classes: AuthError, BadResponse, ClientErrorResponse, Error, ExpiredTokenError, FieldNotSetError, ServerErrorResponse, UnexpectedRedirect, User
Constant Summary collapse
- VERSION =
"0.5.0"- NSID_REGEXP =
/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z]{0,61}[a-zA-Z])?)$/
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Attributes included from Requests
#auto_manage_tokens, #default_progress, #send_auth_headers
Instance Method Summary collapse
- #active_repl? ⇒ Boolean
-
#initialize(host, config_file, options = {}) ⇒ Minisky
constructor
A new instance of Minisky.
- #save_config ⇒ Object
Methods included from Requests
#access_token_expired?, #base_url, #check_access, #fetch_all, #get_request, #log_in, #perform_token_refresh, #post_request, #reset_tokens, #token_expiration_date, #user
Constructor Details
#initialize(host, config_file, options = {}) ⇒ Minisky
Returns a new instance of Minisky.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/minisky/minisky.rb', line 6 def initialize(host, config_file, = {}) @host = host @config_file = config_file if @config_file @config = YAML.load(File.read(@config_file)) if user.id.nil? || user.pass.nil? raise AuthError, "Missing user id or password in the config file #{@config_file}" end else @config = {} @send_auth_headers = false @auto_manage_tokens = false end if active_repl? @default_progress = '.' end if .each do |k, v| self.send("#{k}=", v) end end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/minisky/minisky.rb', line 4 def config @config end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/minisky/minisky.rb', line 4 def host @host end |
Instance Method Details
#active_repl? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/minisky/minisky.rb', line 33 def active_repl? return true if defined?(IRB) && IRB.respond_to?(:CurrentContext) && IRB.CurrentContext return true if defined?(Pry) && Pry.respond_to?(:cli) && Pry.cli false end |
#save_config ⇒ Object
39 40 41 |
# File 'lib/minisky/minisky.rb', line 39 def save_config File.write(@config_file, YAML.dump(@config)) if @config_file end |