Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/parser.rb
Overview
- Author
-
Murali Raju (<[email protected]>)
- Copyright
-
Copyright © 2011 Murali Raju.
- License
-
Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
-
#list_auth_configs ⇒ Object
Parse swift-manager configs (JSON).
- #show_auth_config(auth_json) ⇒ Object
Instance Method Details
#list_auth_configs ⇒ Object
Parse swift-manager configs (JSON)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/parser.rb', line 22 def list_auth_configs auth_config_path = Dir.home + "/.swift-manager/authentication/*.json" auth_configs = Dir.glob(auth_config_path) #Display table output using the terminal-table gem table = Terminal::Table.new :headings => ['Auth Config'] unless auth_configs.empty? auth_configs.each do |row| @row = [] @row << "#{File.basename(row, '.*').chomp(File.extname(row))}".bright table << @row end end puts table.to_s puts '' end |
#show_auth_config(auth_json) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/parser.rb', line 41 def show_auth_config(auth_json) auth_config = File.read(Dir.home + "/.swift-manager/authentication/#{auth_json}.json") auth_params = JSON.parse(auth_config) #Display table output using the terminal-table gem table = Terminal::Table.new :headings => [ 'Tag', 'Provider', 'Service', 'Secret Access Key', 'Access Key ID', 'Auth URL IP'] auth_params.each do |row| @row = [] @row << auth_params["tag"] @row << auth_params["provider"] @row << auth_params["service"] @row << auth_params["keys"]["secret_access_key"] @row << auth_params["keys"]["access_key_id"] @row << auth_params["url_ip"] end table << @row puts table.to_s puts '' end |