Class: PasteHub::Config
- Inherits:
-
Object
- Object
- PasteHub::Config
- Includes:
- Singleton
- Defined in:
- lib/pastehub/config.rb
Instance Attribute Summary collapse
-
#localDbPath ⇒ Object
readonly
Returns the value of attribute localDbPath.
-
#localSyncPath ⇒ Object
readonly
Returns the value of attribute localSyncPath.
-
#notifyMessageMax ⇒ Object
readonly
Returns the value of attribute notifyMessageMax.
-
#publicPath ⇒ Object
readonly
Returns the value of attribute publicPath.
Class Method Summary collapse
Instance Method Summary collapse
- #getHomeDirectory ⇒ Object
- #getVerbose ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #loadClient ⇒ Object
- #reinitialize ⇒ Object
- #setupClient(hash) ⇒ Object
- #setVerbose(verbose_flag) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
45 46 47 48 49 |
# File 'lib/pastehub/config.rb', line 45 def initialize( ) self.setupClient( {} ) @verbose_flag = false @notifyMessageMax = 100 end |
Instance Attribute Details
#localDbPath ⇒ Object (readonly)
Returns the value of attribute localDbPath.
102 103 104 |
# File 'lib/pastehub/config.rb', line 102 def localDbPath @localDbPath end |
#localSyncPath ⇒ Object (readonly)
Returns the value of attribute localSyncPath.
102 103 104 |
# File 'lib/pastehub/config.rb', line 102 def localSyncPath @localSyncPath end |
#notifyMessageMax ⇒ Object (readonly)
Returns the value of attribute notifyMessageMax.
102 103 104 |
# File 'lib/pastehub/config.rb', line 102 def notifyMessageMax @notifyMessageMax end |
#publicPath ⇒ Object (readonly)
Returns the value of attribute publicPath.
102 103 104 |
# File 'lib/pastehub/config.rb', line 102 def publicPath @publicPath end |
Class Method Details
.instance ⇒ Object
41 42 43 |
# File 'lib/pastehub/config.rb', line 41 def self.instance @@instance ||= new end |
Instance Method Details
#getHomeDirectory ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/pastehub/config.rb', line 55 def getHomeDirectory( ) if ENV[ 'HOME' ] return ENV[ 'HOME' ] else return "~/" end end |
#getVerbose ⇒ Object
67 68 69 |
# File 'lib/pastehub/config.rb', line 67 def getVerbose( ) @verbose_flag end |
#loadClient ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/pastehub/config.rb', line 90 def loadClient() name = File.( "~/.pastehub.conf" ) if File.exist?( name ) open( name ) { |f| json = JSON.parse( f.read ) self.setupClient( { :localDbPath => json[ 'localDbPath' ], :localSyncPath => json[ 'localSyncPath' ], } ) } end end |
#reinitialize ⇒ Object
51 52 53 |
# File 'lib/pastehub/config.rb', line 51 def reinitialize() initialize() end |
#setupClient(hash) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pastehub/config.rb', line 71 def setupClient( hash ) @localDbPath = if hash[ :localDbPath ] hash[ :localDbPath ] else File.( sprintf( "%s/.pastehub/", getHomeDirectory() )) + "/" end @localSyncPath = if hash[ :localSyncPath ] hash[ :localSyncPath ] else File.( sprintf( "%s/Dropbox/pastehub/", getHomeDirectory() )) + "/" end @publicPath = if hash[ :publicPath ] hash[ :publicPath ] else File.( sprintf( "%s/Dropbox/Public/", getHomeDirectory() )) + "/" end end |
#setVerbose(verbose_flag) ⇒ Object
63 64 65 |
# File 'lib/pastehub/config.rb', line 63 def setVerbose( verbose_flag ) @verbose_flag = verbose_flag end |