Module: AdmqrKnife
- Defined in:
- lib/admqr_knife.rb,
lib/admqr_knife/version.rb,
lib/admqr_knife/cube_service.rb
Defined Under Namespace
Classes: CubeService, Error
Constant Summary collapse
- VERSION =
"0.2.0"
Class Attribute Summary collapse
-
.knife_base_uri ⇒ Object
Returns the value of attribute knife_base_uri.
-
.knife_client_key ⇒ Object
Returns the value of attribute knife_client_key.
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
- .client_key ⇒ Object
- .init(client_key = nil, options = {}) ⇒ Object
- .visit(unique_code:, **options) ⇒ Object
Class Attribute Details
.knife_base_uri ⇒ Object
Returns the value of attribute knife_base_uri.
12 13 14 |
# File 'lib/admqr_knife.rb', line 12 def knife_base_uri @knife_base_uri end |
.knife_client_key ⇒ Object
Returns the value of attribute knife_client_key.
12 13 14 |
# File 'lib/admqr_knife.rb', line 12 def knife_client_key @knife_client_key end |
.logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/admqr_knife.rb', line 12 def logger @logger end |
Class Method Details
.client_key ⇒ Object
20 21 22 |
# File 'lib/admqr_knife.rb', line 20 def client_key @knife_client_key end |
.init(client_key = nil, options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/admqr_knife.rb', line 14 def init(client_key = nil, = {}) @knife_client_key = client_key || ENV['ADMQR_KNIFE_CLIENT_KEY'] @knife_base_uri = ENV['KNIFE_BASE_URI'] || 'https://www.maolvdl.com/apic/v1/' @logger = [:logger] || select_logger end |
.visit(unique_code:, **options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/admqr_knife.rb', line 24 def visit(unique_code:, **) raise 'unique_code 不能为空' if unique_code.to_s == '' ua = [:ua] || [:client_ua] referer = [:referer] tag = [:tag] new_to_visit = [:new_to_visit] remote_ip = [:remote_ip] extra = [:extra] CubeService.post('/api/knifes/statis', { unique_code: unique_code, client_ua: ua, referer: referer, tag: tag, extra: extra, new_to_visit: new_to_visit, remote_ip: remote_ip }.reject { |_k, v| v.nil? }) rescue StandardError => e logger.error "AdmqrKnife Gem Error: #{e.}" end |