figo-connect / ruby-figo

Ruby binding for the figo Connect API.
http://figo.io
8 stars 15 forks source link

Do not use global variables, use constants #10

Open greyblake opened 9 years ago

greyblake commented 9 years ago

In general it's a bad practise.

require 'figo'

$api_endpoint
 => "api.figo.me" 

$valid_fingerprints
 => ["3A:62:54:4D:86:B4:34:38:EA:34:64:4E:95:10:A9:FF:37:27:69:C0", "CF:C1:BC:7F:6A:16:09:2B:10:83:8A:B0:22:4F:3A:65:D2:70:D7:3E"]

Also the names are not prefixed, some potentially some other libary can introduce $api_endpoint variable, what can result into errors.

It's better to use constants:

module Figo
  API_ENDPOINT = "api.figo.me".freeze
  VALID_FINGERPRINTS = [
    "3A:62:54:4D:86:B4:34:38:EA:34:64:4E:95:10:A9:FF:37:27:69:C0",
    "CF:C1:BC:7F:6A:16:09:2B:10:83:8A:B0:22:4F:3A:65:D2:70:D7:3E"
  ].freeze
end