Class: ShopifyCLI::Shopifolk
- Inherits:
-
Object
- Object
- ShopifyCLI::Shopifolk
- Defined in:
- lib/shopify_cli/shopifolk.rb
Overview
ShopifyCLI::Shopifolk contains the logic to determine if the user appears to be a Shopify staff
The Shopifolk Feature flag will persist between runs so if the flag is enabled or disabled, it will still be in that same state until the next class invocation.
Constant Summary collapse
- GCLOUD_CONFIG_FILE =
File.("~/.config/gcloud/configurations/config_default")
- DEV_PATH =
"/opt/dev"
- SECTION =
"core"
- FEATURE_NAME =
"shopifolk"
Class Method Summary collapse
- .act_as_shopify_organization ⇒ Object
- .acting_as_shopify_organization? ⇒ Boolean
-
.check ⇒ Object
will return if the user appears to be a Shopify employee, based on several heuristics.
- .reset ⇒ Object
Instance Method Summary collapse
-
#shopifolk? ⇒ Boolean
will return if the user is a Shopify employee.
Class Method Details
.act_as_shopify_organization ⇒ Object
29 30 31 |
# File 'lib/shopify_cli/shopifolk.rb', line 29 def act_as_shopify_organization DB.set(acting_as_shopify_organization: true) end |
.acting_as_shopify_organization? ⇒ Boolean
33 34 35 36 |
# File 'lib/shopify_cli/shopifolk.rb', line 33 def acting_as_shopify_organization? !!(DB.get(:acting_as_shopify_organization) || (Project.has_current? && Project.current.config["shopify_organization"])) end |
.check ⇒ Object
will return if the user appears to be a Shopify employee, based on several heuristics
#### Returns
-
‘is_shopifolk` - returns true if the user is a Shopify Employee
#### Example
ShopifyCLI::Shopifolk.check
25 26 27 |
# File 'lib/shopify_cli/shopifolk.rb', line 25 def check ShopifyCLI::Shopifolk.new.shopifolk? end |
Instance Method Details
#shopifolk? ⇒ Boolean
will return if the user is a Shopify employee
#### Returns
-
‘is_shopifolk` - returns true if the user has `dev` installed and
a valid google cloud config file with email ending in “@shopify.com”
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/shopify_cli/shopifolk.rb', line 51 def shopifolk? return true if Feature.enabled?(FEATURE_NAME) if shopifolk_by_gcloud? && shopifolk_by_dev? ShopifyCLI::Feature.enable(FEATURE_NAME) true else ShopifyCLI::Feature.disable(FEATURE_NAME) false end end |