Class: Springnote::Configuration
- Inherits:
-
Object
- Object
- Springnote::Configuration
- Defined in:
- lib/springnote/configuration.rb
Constant Summary collapse
- SERVER_URL =
"api.springnote.com"
Instance Attribute Summary collapse
-
#access_secret ⇒ Object
Returns the value of attribute access_secret.
-
#access_token ⇒ Object
Returns the value of attribute access_token.
- #app_key ⇒ Object
-
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
-
#consumer_token ⇒ Object
Returns the value of attribute consumer_token.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#user_key ⇒ Object
writeonly
deprecated.
-
#user_openid ⇒ Object
writeonly
Sets the attribute user_openid.
Instance Method Summary collapse
- #consumer ⇒ Object
- #load(file) ⇒ Object
- #password ⇒ Object
- #set(options = {}) ⇒ Object
- #site ⇒ Object
- #token ⇒ Object
- #username ⇒ Object
Instance Attribute Details
#access_secret ⇒ Object
Returns the value of attribute access_secret.
8 9 10 |
# File 'lib/springnote/configuration.rb', line 8 def access_secret @access_secret end |
#access_token ⇒ Object
Returns the value of attribute access_token.
8 9 10 |
# File 'lib/springnote/configuration.rb', line 8 def access_token @access_token end |
#app_key ⇒ Object
65 66 67 |
# File 'lib/springnote/configuration.rb', line 65 def app_key @app_key end |
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
7 8 9 |
# File 'lib/springnote/configuration.rb', line 7 def consumer_secret @consumer_secret end |
#consumer_token ⇒ Object
Returns the value of attribute consumer_token.
7 8 9 |
# File 'lib/springnote/configuration.rb', line 7 def consumer_token @consumer_token end |
#domain ⇒ Object
Returns the value of attribute domain.
9 10 11 |
# File 'lib/springnote/configuration.rb', line 9 def domain @domain end |
#protocol ⇒ Object
Returns the value of attribute protocol.
9 10 11 |
# File 'lib/springnote/configuration.rb', line 9 def protocol @protocol end |
#user_key=(value) ⇒ Object (writeonly)
deprecated
54 55 56 |
# File 'lib/springnote/configuration.rb', line 54 def user_key=(value) @user_key = value end |
#user_openid=(value) ⇒ Object (writeonly)
Sets the attribute user_openid
55 56 57 |
# File 'lib/springnote/configuration.rb', line 55 def user_openid=(value) @user_openid = value end |
Instance Method Details
#consumer ⇒ Object
49 50 51 |
# File 'lib/springnote/configuration.rb', line 49 def consumer @consumer ||= OAuth::Consumer.new @consumer_token, @consumer_secret, :site => "https://api.openmaru.com" if @consumer_token && @consumer_secret end |
#load(file) ⇒ Object
17 18 19 |
# File 'lib/springnote/configuration.rb', line 17 def load(file) set YAML.load(File.read(file)) end |
#password ⇒ Object
61 62 63 |
# File 'lib/springnote/configuration.rb', line 61 def password @user_key ? [@user_key, app_key].join('.') : app_key end |
#set(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/springnote/configuration.rb', line 21 def set( = {}) #reset @token = nil @consumer = nil .each{|k,v| self.send("#{k}=", v)} Springnote::Base.site = self.site if @app_key && Springnote::Base.respond_to?(:user=) Springnote::Base.user = self.username Springnote::Base.password = self.password end self end |
#site ⇒ Object
39 40 41 42 43 |
# File 'lib/springnote/configuration.rb', line 39 def site @app_key ? "#{protocol}://#{username}:#{password}@#{SERVER_URL}/" : "#{protocol}://#{SERVER_URL}/" end |
#token ⇒ Object
45 46 47 |
# File 'lib/springnote/configuration.rb', line 45 def token @token ||= OAuth::AccessToken.new consumer, @access_token, @access_secret if @access_token && @access_secret end |
#username ⇒ Object
57 58 59 |
# File 'lib/springnote/configuration.rb', line 57 def username CGI.escape(@user_openid || 'anonymous') end |