Class: GoogleFT
- Inherits:
-
Object
- Object
- GoogleFT
- Defined in:
- lib/google-ft.rb,
lib/google-ft/table.rb,
lib/google-ft/table/column.rb,
lib/google-ft/table/permission.rb
Defined Under Namespace
Classes: Table
Instance Attribute Summary collapse
-
#authorization ⇒ Object
Returns the value of attribute authorization.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
-
.get_and_parse_response(args) ⇒ Object
Quick wrapper method for utilizing curb-fu.
-
.to_google_ft_format(value) ⇒ Object
Method to convert values into google-compatible format.
Instance Method Summary collapse
- #create_table(args) ⇒ Object
- #delete_table(table_id) ⇒ Object
- #get_auth_token(args) ⇒ Object
- #get_table(table_id) ⇒ Object
- #show_tables ⇒ Object
Instance Attribute Details
#authorization ⇒ Object
Returns the value of attribute authorization.
48 49 50 |
# File 'lib/google-ft.rb', line 48 def @authorization end |
#token ⇒ Object
Returns the value of attribute token.
48 49 50 |
# File 'lib/google-ft.rb', line 48 def token @token end |
Class Method Details
.get_and_parse_response(args) ⇒ Object
Quick wrapper method for utilizing curb-fu.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/google-ft.rb', line 30 def get_and_parse_response(args) response = GoogleSAAuth::Client.run(args) # Make sure we get a 20* status. unless response.status.to_s =~ /^20/ puts response.body.to_s raise RuntimeError end # Return the symbolized hash of the response body. begin JSON.parse(response.body).symbolize rescue response.body end end |
.to_google_ft_format(value) ⇒ Object
Method to convert values into google-compatible format.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/google-ft.rb', line 18 def to_google_ft_format(value) if value.class == String bytes = value.bytes.each.collect {|l| l.chr.gsub(/\\|'/) { |c| "\\#{c}" }.gsub('&', '%26').gsub("\b", '\\b').gsub("\f", '\\f').gsub("\n", '\\n').gsub("\r", '\\r').gsub("\t",'\\t')} "'#{bytes.join}'" elsif value.class == Array "'#{value.first} #{value.last}'" else value.to_json end end |
Instance Method Details
#create_table(args) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/google-ft.rb', line 67 def create_table(args) require_auth # Create the table and save it. args[:token] = @authorization.token_string table = GoogleFT::Table.new(args) table.save table end |
#delete_table(table_id) ⇒ Object
77 78 79 80 |
# File 'lib/google-ft.rb', line 77 def delete_table(table_id) require_auth GoogleFT::Table.get_table_by_id(table_id, @authorization.token_string).delete end |
#get_auth_token(args) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/google-ft.rb', line 50 def get_auth_token(args) # Make sure the token wasn't already set and hasn't yet expired. @authorization = nil unless has_auth? # (Re)create the authorization. @authorization ||= GoogleSAAuth.new(args) # Save the token. @token = @authorization.token @authorization end |
#get_table(table_id) ⇒ Object
82 83 84 85 |
# File 'lib/google-ft.rb', line 82 def get_table(table_id) require_auth GoogleFT::Table.get_table_by_id(table_id, @authorization.token_string) end |
#show_tables ⇒ Object
62 63 64 65 |
# File 'lib/google-ft.rb', line 62 def show_tables require_auth GoogleFT::Table.show_tables(@authorization.token_string) end |