grifter 0.4.2 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4de74bedb4fcbf35e8aa659410106f4ff6ae155c
4
- data.tar.gz: d221fd3def4e4e9983be77816cf8491a04cecb9c
3
+ metadata.gz: d2c54da2e22c05f1fe1e54832443f49690ee3e65
4
+ data.tar.gz: 6a73c714c0feaa35af907459f6c93b2ed7df5aaf
5
5
  SHA512:
6
- metadata.gz: 121cb4b203880a5829eb4b840e0a7b00b52c546ecfa580b31ab9458a79b0c4fcc172f5c3c974e8993f1803841dba8defd25acc99e9d9f6dd11462b5babd5d2d3
7
- data.tar.gz: 2f806a27a2f8e6a9d0d63b239a09b22ca0a4e17bfddcb9c5e4657d5699a3d848d011f1e4c0f1970e4121b003e10a29524422ba2d66c9bd57e984a00d9bc0fd89
6
+ metadata.gz: be801d6213e1e01cf3f773c9394b2d23cf83a6606672dc2479ffb4776a4f616df5a1d241673888091586d91644b172767b40b1944e9334a1b20cf998e8615db5
7
+ data.tar.gz: 887376d1d89aaf420a80d4c5c1a9f7601c7a9d67a275b8ce4d5b1f0ac8e4edeb57d9d116d5d155ff6c86d9c38a7ca4f5567033745eb3bfad48588c6d701094e0
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ group :development do
9
9
  gem 'rspec'
10
10
  gem 'pry'
11
11
  gem 'awesome_print'
12
- gem 'jeweler'
12
+ gem 'jeweler', '~> 2.1.1'
13
13
  end
@@ -1,38 +1,35 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (4.0.4)
5
- i18n (~> 0.6, >= 0.6.9)
6
- minitest (~> 4.2)
7
- multi_json (~> 1.3)
8
- thread_safe (~> 0.1)
9
- tzinfo (~> 0.3.37)
10
- addressable (2.3.6)
11
- atomic (1.1.16)
12
- awesome_print (1.2.0)
4
+ activesupport (4.2.4)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.4.0)
11
+ awesome_print (1.6.1)
13
12
  builder (3.2.2)
14
13
  coderay (1.1.0)
15
14
  descendants_tracker (0.0.4)
16
15
  thread_safe (~> 0.3, >= 0.3.1)
17
16
  diff-lcs (1.2.5)
18
- ethon (0.7.0)
17
+ ethon (0.7.4)
19
18
  ffi (>= 1.3.0)
20
19
  faraday (0.9.0)
21
20
  multipart-post (>= 1.2, < 3)
22
- ffi (1.9.3)
23
- git (1.2.6)
24
- github_api (0.11.3)
25
- addressable (~> 2.3)
26
- descendants_tracker (~> 0.0.1)
21
+ ffi (1.9.8)
22
+ git (1.3.0)
23
+ github_api (0.14.0)
24
+ addressable (~> 2.4.0)
25
+ descendants_tracker (~> 0.0.4)
27
26
  faraday (~> 0.8, < 0.10)
28
- hashie (>= 1.2)
29
- multi_json (>= 1.7.5, < 2.0)
30
- nokogiri (~> 1.6.0)
27
+ hashie (>= 3.4)
31
28
  oauth2
32
- hashie (2.0.5)
33
- highline (1.6.21)
34
- i18n (0.6.9)
35
- jeweler (2.0.1)
29
+ hashie (3.4.4)
30
+ highline (1.7.8)
31
+ i18n (0.7.0)
32
+ jeweler (2.1.1)
36
33
  builder
37
34
  bundler (>= 1.0)
38
35
  git (>= 1.2.5)
@@ -41,45 +38,53 @@ GEM
41
38
  nokogiri (>= 1.5.10)
42
39
  rake
43
40
  rdoc
44
- json (1.8.1)
45
- jwt (0.1.11)
46
- multi_json (>= 1.5)
41
+ semver
42
+ json (1.8.3)
43
+ jwt (1.5.1)
47
44
  method_source (0.8.2)
48
- mini_portile (0.5.3)
49
- minitest (4.7.5)
50
- multi_json (1.9.2)
45
+ mini_portile2 (2.1.0)
46
+ minitest (5.8.0)
47
+ multi_json (1.12.1)
51
48
  multi_xml (0.5.5)
52
49
  multipart-post (2.0.0)
53
- nokogiri (1.6.1)
54
- mini_portile (~> 0.5.0)
55
- oauth2 (0.9.3)
50
+ nokogiri (1.6.8)
51
+ mini_portile2 (~> 2.1.0)
52
+ pkg-config (~> 1.1.7)
53
+ oauth2 (1.1.0)
56
54
  faraday (>= 0.8, < 0.10)
57
- jwt (~> 0.1.8)
55
+ jwt (~> 1.0, < 1.5.2)
58
56
  multi_json (~> 1.3)
59
57
  multi_xml (~> 0.5)
60
- rack (~> 1.2)
61
- pry (0.9.12.6)
62
- coderay (~> 1.0)
63
- method_source (~> 0.8)
58
+ rack (>= 1.2, < 3)
59
+ pkg-config (1.1.7)
60
+ pry (0.10.1)
61
+ coderay (~> 1.1.0)
62
+ method_source (~> 0.8.1)
64
63
  slop (~> 3.4)
65
- rack (1.5.2)
66
- rake (10.2.1)
67
- rdoc (4.1.1)
64
+ rack (1.6.4)
65
+ rake (11.1.2)
66
+ rdoc (4.2.2)
68
67
  json (~> 1.4)
69
- rspec (2.14.1)
70
- rspec-core (~> 2.14.0)
71
- rspec-expectations (~> 2.14.0)
72
- rspec-mocks (~> 2.14.0)
73
- rspec-core (2.14.8)
74
- rspec-expectations (2.14.5)
75
- diff-lcs (>= 1.1.3, < 2.0)
76
- rspec-mocks (2.14.6)
77
- slop (3.5.0)
78
- thread_safe (0.3.1)
79
- atomic (>= 1.1.7, < 2)
80
- typhoeus (0.6.8)
81
- ethon (>= 0.7.0)
82
- tzinfo (0.3.39)
68
+ rspec (3.3.0)
69
+ rspec-core (~> 3.3.0)
70
+ rspec-expectations (~> 3.3.0)
71
+ rspec-mocks (~> 3.3.0)
72
+ rspec-core (3.3.2)
73
+ rspec-support (~> 3.3.0)
74
+ rspec-expectations (3.3.1)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.3.0)
77
+ rspec-mocks (3.3.2)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.3.0)
80
+ rspec-support (3.3.0)
81
+ semver (1.0.1)
82
+ slop (3.6.0)
83
+ thread_safe (0.3.5)
84
+ typhoeus (0.6.9)
85
+ ethon (>= 0.7.1)
86
+ tzinfo (1.2.2)
87
+ thread_safe (~> 0.1)
83
88
 
84
89
  PLATFORMS
85
90
  ruby
@@ -88,8 +93,11 @@ DEPENDENCIES
88
93
  activesupport (>= 3.2)
89
94
  awesome_print
90
95
  faraday (= 0.9.0)
91
- jeweler
96
+ jeweler (~> 2.1.1)
92
97
  json
93
98
  pry
94
99
  rspec
95
100
  typhoeus (~> 0.6.8)
101
+
102
+ BUNDLED WITH
103
+ 1.11.2
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: grifter 0.4.2 ruby lib
5
+ # stub: grifter 0.4.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "grifter"
9
- s.version = "0.4.2"
9
+ s.version = "0.4.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Robert Schultheis"]
14
- s.date = "2014-03-28"
14
+ s.date = "2016-06-07"
15
15
  s.description = "convention based approach to interfacing with an HTTP JSON API."
16
16
  s.email = "rob@knewton.com"
17
17
  s.executables = ["grift"]
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  ]
37
37
  s.homepage = "http://github.com/knewton/grifter"
38
38
  s.licenses = ["MIT"]
39
- s.rubygems_version = "2.2.0"
39
+ s.rubygems_version = "2.5.1"
40
40
  s.summary = "Make calls to HTTP JSON APIs with ease and confidence"
41
41
 
42
42
  if s.respond_to? :specification_version then
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
50
50
  s.add_development_dependency(%q<rspec>, [">= 0"])
51
51
  s.add_development_dependency(%q<pry>, [">= 0"])
52
52
  s.add_development_dependency(%q<awesome_print>, [">= 0"])
53
- s.add_development_dependency(%q<jeweler>, [">= 0"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 2.1.1"])
54
54
  else
55
55
  s.add_dependency(%q<faraday>, ["= 0.9.0"])
56
56
  s.add_dependency(%q<json>, [">= 0"])
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.add_dependency(%q<rspec>, [">= 0"])
60
60
  s.add_dependency(%q<pry>, [">= 0"])
61
61
  s.add_dependency(%q<awesome_print>, [">= 0"])
62
- s.add_dependency(%q<jeweler>, [">= 0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 2.1.1"])
63
63
  end
64
64
  else
65
65
  s.add_dependency(%q<faraday>, ["= 0.9.0"])
@@ -69,7 +69,7 @@ Gem::Specification.new do |s|
69
69
  s.add_dependency(%q<rspec>, [">= 0"])
70
70
  s.add_dependency(%q<pry>, [">= 0"])
71
71
  s.add_dependency(%q<awesome_print>, [">= 0"])
72
- s.add_dependency(%q<jeweler>, [">= 0"])
72
+ s.add_dependency(%q<jeweler>, ["~> 2.1.1"])
73
73
  end
74
74
  end
75
75
 
@@ -49,7 +49,7 @@ class Grifter
49
49
  self.grifter_authenticate_do
50
50
  end
51
51
 
52
- start_instrumentation if @config[:instrumentation] = true
52
+ start_instrumentation if @config[:instrumentation]
53
53
  end
54
54
 
55
55
  attr_reader :services
@@ -10,6 +10,10 @@ class Grifter
10
10
  h[k.intern] = case v
11
11
  when Hash
12
12
  recursive_symbolize v
13
+ when Array # this only handles list of strings, which is good enough
14
+ v.map do |item|
15
+ item.to_sym
16
+ end
13
17
  else
14
18
  v
15
19
  end
@@ -34,7 +38,7 @@ class Grifter
34
38
 
35
39
  def load_config_file options={}
36
40
  options = {
37
- config_file: ENV['GRIFTER_CONFIG_FILE'] ? ENV['GRIFTER_CONFIG_FILE'] : 'grifter.yml',
41
+ config_file: ENV.fetch('GRIFTER_CONFIG_FILE', 'grifter.yml'),
38
42
  environment: ENV['GRIFTER_ENVIRONMENT'],
39
43
  }.merge(options)
40
44
  Grifter::Log.debug "Loading config file '#{options[:config_file]}'"
@@ -73,12 +77,35 @@ class Grifter
73
77
 
74
78
  #merge any environment overrides into the service block
75
79
  if options[:environment]
76
- config[:environment] = options[:environment].to_sym
77
- unless config[:environments] && config[:environments][config[:environment]]
78
- raise GrifterConfigurationError.new "No such environment specified in config: '#{config[:environment]}'"
80
+
81
+ unless config[:environments]
82
+ raise GrifterConfigurationError.new "You specified a grifter environment, but there is no environments section in the grifter configuration"
83
+ end
84
+
85
+ requested_environment_name = options[:environment].to_sym
86
+ if config[:environments].has_key? requested_environment_name
87
+ # the environment was literally specified
88
+ env_config = config[:environments][options[:environment].to_sym]
89
+ config[:environment] = options[:environment].to_sym
90
+ else
91
+ # the environment may be an alias
92
+ config[:environments].each_pair do |env_name, env_overrides|
93
+ if env_overrides[:aliases] and
94
+ env_overrides[:aliases].include? requested_environment_name
95
+ env_config = env_overrides
96
+ config[:environment] = env_name
97
+ break
98
+ end
99
+ end
79
100
  end
80
101
 
81
- config[:environments][config[:environment]].each_pair do |service_name, service_overrides|
102
+ if env_config.nil? || config[:environment].nil?
103
+ raise GrifterConfigurationError.new "No such environment or environment alias specified in config: '#{requested_environment_name.to_s}'"
104
+ end
105
+
106
+ env_config.delete :aliases
107
+
108
+ env_config.each_pair do |service_name, service_overrides|
82
109
  service_overrides.merge!(get_service_config_from_url(service_overrides.delete(:url)))
83
110
  config[:services][service_name].merge! service_overrides
84
111
  end
@@ -109,8 +109,8 @@ class Grifter
109
109
 
110
110
  #doing it this way avoids problem with OPTIONS method: https://github.com/lostisland/faraday/issues/305
111
111
  response = nil
112
- metrics_obj = { method: method, service: @name, path: path }
113
- ActiveSupport::Notifications.instrument('request.grifter', metrics_obj) do
112
+ metrics_obj = { method: method, service: @name, path: path, request_body: body, request_headers: req_headers }
113
+ ActiveSupport::Notifications.instrument(Grifter::Instrumentation::InstrumentationQueueName, metrics_obj) do
114
114
  response = @conn.run_request(method, nil, nil, nil) do |req|
115
115
  req.path = parsed.path
116
116
  req.params = metrics_obj[:params] = query_hash if query_hash
@@ -2,11 +2,13 @@ require 'active_support/notifications'
2
2
  class Grifter
3
3
  module Instrumentation
4
4
 
5
+ InstrumentationQueueName = 'request.grifter'
6
+
5
7
  Sample = Struct.new(:service_name, :method, :path, :status, :duration_ms, :end_time)
6
8
 
7
9
  def start_instrumentation
8
10
  @all_requests ||= []
9
- ActiveSupport::Notifications.subscribe('request.grifter') do |name, start_time, end_time, _, data|
11
+ ActiveSupport::Notifications.subscribe(InstrumentationQueueName) do |name, start_time, end_time, _, data|
10
12
  #do nothing if exception happened, else we might interfere with exception handling
11
13
  unless data[:exception]
12
14
  duration_ms = ((end_time.to_f - start_time.to_f) * 1000).to_i
@@ -24,6 +26,9 @@ class Grifter
24
26
  end
25
27
 
26
28
  def metrics_all_requests
29
+ if @all_requests.nil?
30
+ raise "Grifter instrumentation was not enabled. Set instrumentation: true in grifter.yml, or call start_instrumentation"
31
+ end
27
32
  @all_requests
28
33
  end
29
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grifter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Schultheis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-28 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: jeweler
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 2.1.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.1.1
125
125
  description: convention based approach to interfacing with an HTTP JSON API.
126
126
  email: rob@knewton.com
127
127
  executables:
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.2.0
167
+ rubygems_version: 2.5.1
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Make calls to HTTP JSON APIs with ease and confidence