itamae 1.9.0 → 1.9.1

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: be707f952f0626bb44b015cee0d20e52458d732e
4
- data.tar.gz: 1c12830f1a14ce7dacc5c10bf90f33e1cae17398
3
+ metadata.gz: 1922ba87b574d058801766b1b549a9a26e9b9b20
4
+ data.tar.gz: ddf59e714b58036d98cc1e11510adb54e41fb6eb
5
5
  SHA512:
6
- metadata.gz: 052278ea06cccc8065d3452fec345eead2ff9ca5dd0a77bc447d9bb699f5c4de8efb20ca5648a36ef73a70e96eec3788895d1ef12053f920e92b046819905bef
7
- data.tar.gz: d52c51210ae9ae7b6a99ee1c14be97a2f0fea28ceb596fc8bb66eee2b7668d21bcdb183100a597ba39852bb75fd283aa17ecd59c77e39c9bed28cd3e0c1124a3
6
+ metadata.gz: 7d44161aadb0e9a388e14668fbedb08ef4bf3e585f95347e529751a2b6a98f6949c1f41c2d940c485b8db95df0bcb50504d8b7f43c3ba1b00c8ee6e2141761dd
7
+ data.tar.gz: bde120804a97c6109a37ceece9667d17214c1f1cb155b69938ded9c43b5be181e5932c0e548bc9c7429d98b008d70cd52ff756a571e49a8360a2d7e9425658e6
@@ -1,3 +1,9 @@
1
+ ## v1.9.1
2
+
3
+ Features
4
+
5
+ - [Add `get`, `post`, `put`, `delete` and `options` actions to `http_request` resource](https://github.com/itamae-kitchen/itamae/pull/184)
6
+
1
7
  ## v1.9.0
2
8
 
3
9
  Features
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in itamae.gemspec
4
4
  gemspec
5
5
 
6
- gem 'vagrant', github: 'mitchellh/vagrant'
6
+ gem 'vagrant', github: 'ryotarai/vagrant', branch: 'latest-bundler'
7
7
  gem 'vagrant-digitalocean'
8
8
 
9
9
  path = Pathname.new("Gemfile.local")
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Itamae [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![wercker status](https://app.wercker.com/status/3e7be3b982d3671940a07e3ef45d9f5f/s/master "wercker status")](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [![Slack](https://img.shields.io/badge/slack-join-blue.svg)](https://itamae-slackin.herokuapp.com/)
1
+ # [![](https://raw.githubusercontent.com/itamae-kitchen/itamae-logos/master/small/FA-Itamae-horizontal-01-180x72.png)](https://github.com/itamae-kitchen/itamae)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![wercker status](https://app.wercker.com/status/3e7be3b982d3671940a07e3ef45d9f5f/s/master "wercker status")](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [![Slack](https://img.shields.io/badge/slack-join-blue.svg)](https://itamae-slackin.herokuapp.com/)
2
4
 
3
5
  Simple and lightweight configuration management tool inspired by Chef.
4
6
 
@@ -1,19 +1,53 @@
1
1
  require 'itamae'
2
- require 'open-uri'
2
+ require 'uri'
3
+ require 'net/http'
3
4
 
4
5
  module Itamae
5
6
  module Resource
6
7
  class HttpRequest < File
7
8
  UrlNotFoundError = Class.new(StandardError)
8
9
 
10
+ define_attribute :action, default: :get
9
11
  define_attribute :headers, type: Hash, default: {}
12
+ define_attribute :message, type: String, default: ""
10
13
  define_attribute :url, type: String, required: true
11
14
 
12
15
  def pre_action
13
- attributes.content = open(attributes.url, attributes.headers).read
16
+ uri = URI.parse(attributes.url)
17
+ http = Net::HTTP.new(uri.host, uri.port)
18
+ http.use_ssl = true if uri.scheme == "https"
19
+
20
+ case attributes.action
21
+ when :delete, :get, :options
22
+ response = http.method(attributes.action).call(uri.request_uri, attributes.headers)
23
+ when :post, :put
24
+ response = http.method(attributes.action).call(uri.request_uri, attributes.message, attributes.headers)
25
+ end
26
+
27
+ attributes.content = response.body
14
28
 
15
29
  super
16
30
  end
31
+
32
+ def action_delete(options)
33
+ action_create(options)
34
+ end
35
+
36
+ def action_get(options)
37
+ action_create(options)
38
+ end
39
+
40
+ def action_options(options)
41
+ action_create(options)
42
+ end
43
+
44
+ def action_post(options)
45
+ action_create(options)
46
+ end
47
+
48
+ def action_put(options)
49
+ action_create(options)
50
+ end
17
51
  end
18
52
  end
19
53
  end
@@ -1 +1 @@
1
- 1.9.0
1
+ 1.9.1
@@ -75,6 +75,27 @@ describe file('/tmp/http_request.html') do
75
75
  its(:content) { should match(/"from": "itamae"/) }
76
76
  end
77
77
 
78
+ describe file('/tmp/http_request_delete.html') do
79
+ it { should be_file }
80
+ its(:content) { should match(/"from": "itamae"/) }
81
+ end
82
+
83
+ describe file('/tmp/http_request_post.html') do
84
+ it { should be_file }
85
+ its(:content) do
86
+ should match(/"from": "itamae"/)
87
+ should match(/"love": "sushi"/)
88
+ end
89
+ end
90
+
91
+ describe file('/tmp/http_request_put.html') do
92
+ it { should be_file }
93
+ its(:content) do
94
+ should match(/"from": "itamae"/)
95
+ should match(/"love": "sushi"/)
96
+ end
97
+ end
98
+
78
99
  describe file('/tmp/http_request_headers.html') do
79
100
  it { should be_file }
80
101
  its(:content) { should match(/"User-Agent": "Itamae"/) }
@@ -160,6 +160,23 @@ http_request "/tmp/http_request.html" do
160
160
  url "https://httpbin.org/get?from=itamae"
161
161
  end
162
162
 
163
+ http_request "/tmp/http_request_delete.html" do
164
+ action :delete
165
+ url "https://httpbin.org/delete?from=itamae"
166
+ end
167
+
168
+ http_request "/tmp/http_request_post.html" do
169
+ action :post
170
+ message "love=sushi"
171
+ url "https://httpbin.org/post?from=itamae"
172
+ end
173
+
174
+ http_request "/tmp/http_request_put.html" do
175
+ action :put
176
+ message "love=sushi"
177
+ url "https://httpbin.org/put?from=itamae"
178
+ end
179
+
163
180
  http_request "/tmp/http_request_headers.html" do
164
181
  headers "User-Agent" => "Itamae"
165
182
  url "https://httpbin.org/get"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -313,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
313
  version: '0'
314
314
  requirements: []
315
315
  rubyforge_project:
316
- rubygems_version: 2.4.5
316
+ rubygems_version: 2.4.5.1
317
317
  signing_key:
318
318
  specification_version: 4
319
319
  summary: Simple Configuration Management Tool