grifter 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f65192478a13844ee1baa9e2b14e643fcf90bf8d
4
- data.tar.gz: 0c77141f8d51cd0e8c7acfcbe1e46989140a5be5
3
+ metadata.gz: 7caca66795a8e7c7d541699b139a092f62023823
4
+ data.tar.gz: fdcd5c5a4a2330b8642b9d98fc2ba10bfe2f48f7
5
5
  SHA512:
6
- metadata.gz: 58e0aa61a159be1e07c07e277cdf45c1c9a492a8bb5b849e1c7595d9e500c0604d12cac1d45594861aef7d96e0fec3000d53c065ccf701338cbfa1d76561d4ba
7
- data.tar.gz: be2d539d498b1236908331f6eef91c9005079f546181e12cffb1a851095af7eb328edf674d945a87821dccbc3b953cc1bf5e328fa416b06c49b55f74dde767bf
6
+ metadata.gz: 714c56a06fae7b392b6f147723afbb08ade3785740d13801492fae1c8638186f3c9db7d21360d293d7ed2a70ce19919d93d7c98426dd9c3b7ca5868823facc88
7
+ data.tar.gz: b9b4f9340ca6e434a52aac9d5d149e08e256f9268ab518003e43602fcf0ba12c0fca55bb64a6c25708d09fe8d282fd91e32ac09079214b5283a5920cfb0846bf
data/Gemfile CHANGED
@@ -1,10 +1,9 @@
1
- source :rubygems
2
-
3
- #gemspec
1
+ source 'https://rubygems.org'
4
2
 
5
3
  gem 'faraday', '0.9.0'
6
4
  gem 'json'
7
5
  gem 'typhoeus', '0.6.4'
6
+ gem 'activesupport', '4.0.3'
8
7
 
9
8
  group :development do
10
9
  gem 'rspec'
data/Gemfile.lock CHANGED
@@ -1,7 +1,14 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
+ activesupport (4.0.3)
5
+ i18n (~> 0.6, >= 0.6.4)
6
+ minitest (~> 4.2)
7
+ multi_json (~> 1.3)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 0.3.37)
4
10
  addressable (2.3.5)
11
+ atomic (1.1.16)
5
12
  awesome_print (1.2.0)
6
13
  builder (3.2.2)
7
14
  coderay (1.1.0)
@@ -24,6 +31,7 @@ GEM
24
31
  oauth2
25
32
  hashie (2.0.5)
26
33
  highline (1.6.20)
34
+ i18n (0.6.9)
27
35
  jeweler (2.0.0)
28
36
  builder
29
37
  bundler (>= 1.0)
@@ -39,6 +47,7 @@ GEM
39
47
  method_source (0.8.2)
40
48
  mime-types (1.25.1)
41
49
  mini_portile (0.5.2)
50
+ minitest (4.7.5)
42
51
  multi_json (1.8.4)
43
52
  multi_xml (0.5.5)
44
53
  multipart-post (2.0.0)
@@ -67,13 +76,17 @@ GEM
67
76
  diff-lcs (>= 1.1.3, < 2.0)
68
77
  rspec-mocks (2.14.4)
69
78
  slop (3.4.7)
79
+ thread_safe (0.3.1)
80
+ atomic (>= 1.1.7, < 2)
70
81
  typhoeus (0.6.4)
71
82
  ethon (~> 0.6.0)
83
+ tzinfo (0.3.39)
72
84
 
73
85
  PLATFORMS
74
86
  ruby
75
87
 
76
88
  DEPENDENCIES
89
+ activesupport (= 4.0.3)
77
90
  awesome_print
78
91
  faraday (= 0.9.0)
79
92
  jeweler
data/Readme.md CHANGED
@@ -1,35 +1,20 @@
1
1
  Grifter
2
2
  =======
3
- Grifter makes it smooth to work with JSON HTTP APIs with confidence
4
-
5
- Intro
6
- --------
7
- Grifter allows creating a DSL for working with any HTTP JSON RESTy API.
8
- You can GET, POST and otherwise interact with any set of APIs through
9
- high level methods you define, allowing your code to ignore all the
10
- details around the mechanics of connecting to the API, executing the
11
- request, and turning JSON into native ruby objects.
12
-
13
- Using grifter gets you for free:
14
- - a cmd line interface for your json http apis
15
- - a ruby scripting language for interacting with your json http apis
16
- - An object you can use in any kind of ruby program for easily sending
17
- API requests
18
- - An RSpec Helper that makes testing Rest APIs painless
19
-
20
- Grifter relies heavily on the 'convention over configuration' approach,
21
- which means for less code, you get more.
22
-
23
-
24
- Features
25
- --------
26
- - Work with multiple APIs
27
- - Work with multiple deployment environments (Staging, Production, etc.)
28
- - Script calls to API(s)
29
- - Command line calls to API(s)
30
- - Craft clean API tests using the included RSPec helper
31
- - Unified approach to handling request errors
32
- - Convention over configuration approach to defining the API interface
3
+ Do cool stuff with HTTP JSON APIs. Designed for the real world of developing systems based on service-oriented-architecture.
4
+
5
+ What is Grifter?
6
+ ----------------
7
+ Grifter is primarily designed to be used by software teams that build HTTP JSON services.
8
+ Grifter makes it easy to:
9
+ * Define "macro" methods that accomplish high level goals through service calls.
10
+ * Call services or macro methods from the command line, adhoc scripts, or programtically within any Ruby program.
11
+ * Test services using RSpec or other testing frameworks
12
+ * "Point" at different environments (eg. QA, Staging, Production)
13
+
14
+ Grifter relies heavily on the 'convention over configuration' approach. For very little code, you
15
+ get a lot of functionality.
16
+
17
+ Grifter is based on [Faraday](https://github.com/lostisland/faraday), thus there is basic support for making requests concurrently, and for swapping out the HTTP "adapter".
33
18
 
34
19
  Getting Started
35
20
  ---------------
@@ -133,7 +118,12 @@ And get back:
133
118
  1 example, 0 failures
134
119
 
135
120
 
121
+ Further Information
122
+ -------------------
123
+
124
+ Checkout out the [Wiki](https://github.com/Knewton/grifter/wiki) for info on configuration, authentication, and more.
125
+
126
+
136
127
  Copyright
137
128
  ---------
138
- Copyright (c) 2013 Knewton. See LICENSE.txt for
139
- further details.
129
+ Copyright (c) 2013 Knewton. See LICENSE.txt for further details.
data/grifter.gemspec CHANGED
@@ -2,14 +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.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "grifter"
8
- s.version = "0.3.2"
9
+ s.version = "0.4.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Robert Schultheis"]
12
- s.date = "2014-01-26"
14
+ s.date = "2014-03-24"
13
15
  s.description = "convention based approach to interfacing with an HTTP JSON API."
14
16
  s.email = "rob@knewton.com"
15
17
  s.executables = ["grift"]
@@ -34,8 +36,7 @@ Gem::Specification.new do |s|
34
36
  ]
35
37
  s.homepage = "http://github.com/knewton/grifter"
36
38
  s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "2.0.3"
39
+ s.rubygems_version = "2.2.0"
39
40
  s.summary = "Make calls to HTTP JSON APIs with ease and confidence"
40
41
 
41
42
  if s.respond_to? :specification_version then
@@ -45,6 +46,7 @@ Gem::Specification.new do |s|
45
46
  s.add_runtime_dependency(%q<faraday>, ["= 0.9.0"])
46
47
  s.add_runtime_dependency(%q<json>, [">= 0"])
47
48
  s.add_runtime_dependency(%q<typhoeus>, ["= 0.6.4"])
49
+ s.add_runtime_dependency(%q<activesupport>, ["= 4.0.3"])
48
50
  s.add_development_dependency(%q<rspec>, [">= 0"])
49
51
  s.add_development_dependency(%q<pry>, [">= 0"])
50
52
  s.add_development_dependency(%q<awesome_print>, [">= 0"])
@@ -53,6 +55,7 @@ Gem::Specification.new do |s|
53
55
  s.add_dependency(%q<faraday>, ["= 0.9.0"])
54
56
  s.add_dependency(%q<json>, [">= 0"])
55
57
  s.add_dependency(%q<typhoeus>, ["= 0.6.4"])
58
+ s.add_dependency(%q<activesupport>, ["= 4.0.3"])
56
59
  s.add_dependency(%q<rspec>, [">= 0"])
57
60
  s.add_dependency(%q<pry>, [">= 0"])
58
61
  s.add_dependency(%q<awesome_print>, [">= 0"])
@@ -62,6 +65,7 @@ Gem::Specification.new do |s|
62
65
  s.add_dependency(%q<faraday>, ["= 0.9.0"])
63
66
  s.add_dependency(%q<json>, [">= 0"])
64
67
  s.add_dependency(%q<typhoeus>, ["= 0.6.4"])
68
+ s.add_dependency(%q<activesupport>, ["= 4.0.3"])
65
69
  s.add_dependency(%q<rspec>, [">= 0"])
66
70
  s.add_dependency(%q<pry>, [">= 0"])
67
71
  s.add_dependency(%q<awesome_print>, [">= 0"])
data/lib/grifter.rb CHANGED
@@ -8,16 +8,18 @@ class Grifter
8
8
  include Grifter::Configuration
9
9
  include Grifter::Instrumentation
10
10
 
11
- DefaultConfigOptions = {
12
- #TODO: service_config: nil,
13
- grift_globs: ['*_grifts/**/*_grifts.rb'],
14
- authenticate: false,
15
- load_from_config_file: true,
16
- services: {},
17
- instrumentation: false,
18
- }
11
+ def default_options
12
+ {
13
+ grift_globs: ['*_grifts/**/*_grifts.rb'],
14
+ authenticate: false,
15
+ load_from_config_file: true,
16
+ services: {},
17
+ instrumentation: false,
18
+ }
19
+ end
20
+
19
21
  def initialize options={}
20
- options = DefaultConfigOptions.merge(options)
22
+ options = default_options.merge(options)
21
23
  @config = if options[:load_from_config_file]
22
24
  options.merge load_config_file(options)
23
25
  else
@@ -86,7 +88,7 @@ class Grifter
86
88
  end
87
89
  end
88
90
 
89
- private
91
+ private
90
92
  def with_local_load_path load_path, &block
91
93
  $: << load_path
92
94
  rtn = yield block
@@ -101,10 +101,12 @@ class Grifter
101
101
  service_config[:faraday_url] = "#{service_config[:ssl] ? 'https':'http'}://#{service_config[:hostname]}:#{service_config[:port].to_s}"
102
102
  end
103
103
 
104
- #join the grift globs with the relative path to config file
105
- if config[:grift_globs] && options[:config_file]
106
- config_file_dir = File.dirname options[:config_file]
107
- config[:grift_globs].map! {|glob| config_file_dir + '/' + glob.sub(/^\//,'')}
104
+ #setup the grift globs, and this seems more sloppy than it should be
105
+ glob_base_dir = options[:config_file] ? File.dirname(options[:config_file]) : Dir.pwd
106
+ glob_base_dir = File.expand_path(glob_base_dir)
107
+ config[:grift_globs] ||= options[:grift_globs]
108
+ if config[:grift_globs]
109
+ config[:grift_globs].map! {|glob| glob_base_dir + '/' + glob.sub(/^\//,'')}
108
110
  end
109
111
 
110
112
  return config
@@ -1,7 +1,8 @@
1
1
  require 'faraday'
2
2
  require 'typhoeus'
3
3
  require 'typhoeus/adapters/faraday' #https://github.com/typhoeus/typhoeus/issues/226#issuecomment-9919517
4
- #Faraday.require_libs 'parameters'
4
+ require 'active_support/notifications'
5
+ require 'securerandom'
5
6
 
6
7
  require_relative 'json_helpers'
7
8
  require_relative 'log'
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.3.2
4
+ version: 0.4.0
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-01-26 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -52,60 +52,74 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.6.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 4.0.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 4.0.3
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: pry
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: awesome_print
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: jeweler
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '>='
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '>='
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  description: convention based approach to interfacing with an HTTP JSON API.
@@ -140,17 +154,17 @@ require_paths:
140
154
  - lib
141
155
  required_ruby_version: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - '>='
157
+ - - ">="
144
158
  - !ruby/object:Gem::Version
145
159
  version: '0'
146
160
  required_rubygems_version: !ruby/object:Gem::Requirement
147
161
  requirements:
148
- - - '>='
162
+ - - ">="
149
163
  - !ruby/object:Gem::Version
150
164
  version: '0'
151
165
  requirements: []
152
166
  rubyforge_project:
153
- rubygems_version: 2.0.3
167
+ rubygems_version: 2.2.0
154
168
  signing_key:
155
169
  specification_version: 4
156
170
  summary: Make calls to HTTP JSON APIs with ease and confidence