herdic 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +82 -0
- data/bin/herdic +1 -1
- data/lib/herdic.rb +2 -2
- data/lib/herdic/client.rb +11 -19
- data/lib/herdic/loader.rb +18 -13
- data/lib/herdic/printer.rb +6 -3
- data/lib/herdic/version.rb +1 -1
- data/preview.gif +0 -0
- metadata +3 -3
- data/lib/herdic/color.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e293ef971ac5b07472c541fa6b6348183cdaf105
|
4
|
+
data.tar.gz: 2f0904dcdc7ecf20317d44e41434615ad8a856fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7a737516853ed8aca699b0b5ccdf4a86235c67aa4c7eb7f0d5d80911bd23df7f246ae4d4c0edd52338296001f1c10363d17197d6d6a8dbe6b0f5bbd75a47aad
|
7
|
+
data.tar.gz: 68317f866a290521f3b8a5075aaf3712069a19ab2f9e63bd53f9f737a4b997ee505beb18ff10402fd42b132206c03de98b7c6d38dd129a5ab2495851e3d4cbe0
|
data/README.md
CHANGED
@@ -4,6 +4,88 @@ Herdic
|
|
4
4
|
**Herdic is a command line HTTP client intended to create and test API documentation with ease.**
|
5
5
|
|
6
6
|
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
|
10
|
+
```sh
|
11
|
+
$ gem install herdic
|
12
|
+
```
|
13
|
+
|
14
|
+
Or add the gem to your Gemfile.
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'herdic'
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
Synopsis
|
22
|
+
--------
|
23
|
+
|
24
|
+
```
|
25
|
+
herdic [-e] [-c config.yaml] [--use-ssl] path/to/spec.yaml
|
26
|
+
```
|
27
|
+
|
28
|
+
| Option | Description |
|
29
|
+
| ---------------- | --------------------------------------------- |
|
30
|
+
| `-e` | Edit request file in vim (default) before run |
|
31
|
+
| `-c config.yaml` | Specify absolute path of herdic.yaml |
|
32
|
+
| `--use-ssl` | Use `Net::HTTP` with flag `use_ssl = true` |
|
33
|
+
|
34
|
+
|
35
|
+
Sample
|
36
|
+
------
|
37
|
+
|
38
|
+
### Config
|
39
|
+
|
40
|
+
```yaml
|
41
|
+
# herdic.yaml
|
42
|
+
api_base: http://localhost:3000/user_v1
|
43
|
+
|
44
|
+
user_account:
|
45
|
+
email: user+1@example.com
|
46
|
+
password: password
|
47
|
+
```
|
48
|
+
|
49
|
+
### Specs
|
50
|
+
|
51
|
+
```yaml
|
52
|
+
# sessions/create.yaml
|
53
|
+
|
54
|
+
- title: Signin as user
|
55
|
+
method: post
|
56
|
+
endpoint: <%= config['api_base'] %>/user_account/session
|
57
|
+
|
58
|
+
body:
|
59
|
+
user_account:
|
60
|
+
email: <%= config['user_account']['email'] %>
|
61
|
+
password: <%= config['user_account']['password'] %>
|
62
|
+
|
63
|
+
register:
|
64
|
+
user_account_access_token: user_account.access_token
|
65
|
+
```
|
66
|
+
|
67
|
+
```yaml
|
68
|
+
# user_bases/show.yaml
|
69
|
+
|
70
|
+
- include: ../sessions/create.yaml
|
71
|
+
|
72
|
+
- title: Show user basis
|
73
|
+
method: get
|
74
|
+
endpoint: <%= config['api_base'] %>/user_basis
|
75
|
+
|
76
|
+
header:
|
77
|
+
X-Access-Token: <%= registry['user_account_access_token'] %>
|
78
|
+
```
|
79
|
+
|
80
|
+
### Run
|
81
|
+
|
82
|
+
```sh
|
83
|
+
$ herdic user_bases/show.yaml
|
84
|
+
```
|
85
|
+
|
86
|
+
![](./preview.gif)
|
87
|
+
|
88
|
+
|
7
89
|
License
|
8
90
|
-------
|
9
91
|
|
data/bin/herdic
CHANGED
data/lib/herdic.rb
CHANGED
@@ -22,8 +22,8 @@ module Herdic
|
|
22
22
|
@pwd = File.expand_path '.'
|
23
23
|
@herdic_path = File.expand_path '~/.herdic'
|
24
24
|
@store_path = File.join @herdic_path, 'store'
|
25
|
-
@edit_request_file = File.join @herdic_path, 'edit_request.
|
26
|
-
@config_filename = 'herdic.
|
25
|
+
@edit_request_file = File.join @herdic_path, 'edit_request.yaml'
|
26
|
+
@config_filename = 'herdic.yaml'
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/herdic/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext'
|
2
2
|
require 'erb'
|
3
|
+
require 'fileutils'
|
3
4
|
require 'json'
|
4
5
|
require 'net/http'
|
5
6
|
require 'open-uri'
|
@@ -16,16 +17,16 @@ module Herdic
|
|
16
17
|
def initialize(file, options)
|
17
18
|
@file, @options = file, options
|
18
19
|
|
19
|
-
@config_file = @options['c'] || Util.find_files_upward(Herdic.config_filename, Herdic.pwd, 1)[0]
|
20
20
|
@context = binding
|
21
21
|
|
22
|
-
@
|
23
|
-
@
|
22
|
+
@config_file = @options['c'] || Util.find_files_upward(Herdic.config_filename, Herdic.pwd, 1)[0]
|
23
|
+
load_config @config_file if @config_file
|
24
24
|
|
25
25
|
@printer = Printer.new @options
|
26
|
+
@printer.start_message @config_file
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
@store = Store.new @config_file
|
29
|
+
@registry = @store.data
|
29
30
|
end
|
30
31
|
|
31
32
|
def load_config(file)
|
@@ -38,24 +39,15 @@ module Herdic
|
|
38
39
|
@config = Psych.load @config
|
39
40
|
end
|
40
41
|
|
41
|
-
def
|
42
|
-
@specs = Loader.new(@file).specs
|
43
|
-
|
42
|
+
def run_all
|
44
43
|
if @options['e']
|
45
|
-
|
46
|
-
f.write Psych.dump(@specs)
|
47
|
-
end
|
48
|
-
|
44
|
+
FileUtils.cp @file, Herdic.edit_request_file
|
49
45
|
system "$EDITOR '%s'" % Herdic.edit_request_file
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
@specs = Loader.new Herdic.edit_request_file, @file
|
48
|
+
else
|
49
|
+
@specs = Loader.new @file
|
54
50
|
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def run_all
|
58
|
-
@printer.start_message @specs
|
59
51
|
|
60
52
|
@specs.each do |spec|
|
61
53
|
# FIXME: figure out better way
|
data/lib/herdic/loader.rb
CHANGED
@@ -4,34 +4,39 @@ require 'psych'
|
|
4
4
|
module Herdic
|
5
5
|
class Loader
|
6
6
|
|
7
|
-
|
7
|
+
include Enumerable
|
8
8
|
|
9
|
-
def initialize(file)
|
10
|
-
@
|
11
|
-
|
12
|
-
load file
|
9
|
+
def initialize(file, original = nil)
|
10
|
+
@file, @original = file, original
|
13
11
|
end
|
14
12
|
|
15
|
-
def load(file, included_from = nil)
|
13
|
+
def load(file, original, included_from = nil)
|
16
14
|
file = File.expand_path file, included_from
|
17
15
|
|
16
|
+
specs = ''
|
17
|
+
|
18
18
|
File.open(file, 'r') do |f|
|
19
|
-
|
19
|
+
specs = f.read
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
specs = Psych.load specs
|
23
23
|
|
24
|
-
|
25
|
-
spec['file'] = file
|
24
|
+
specs.each do |spec|
|
25
|
+
spec['file'] = original || file
|
26
26
|
|
27
27
|
if spec['include']
|
28
|
-
load spec['include'], File.dirname(file)
|
28
|
+
load spec['include'], nil, File.dirname(spec['file'])
|
29
29
|
else
|
30
|
-
@
|
30
|
+
@block.call spec
|
31
31
|
end
|
32
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def each(&block)
|
36
|
+
return unless block
|
33
37
|
|
34
|
-
@
|
38
|
+
@block = block
|
39
|
+
load @file, @original
|
35
40
|
end
|
36
41
|
|
37
42
|
end
|
data/lib/herdic/printer.rb
CHANGED
@@ -9,8 +9,12 @@ module Herdic
|
|
9
9
|
@options = options
|
10
10
|
end
|
11
11
|
|
12
|
-
def start_message(
|
13
|
-
|
12
|
+
def start_message(config_file = nil)
|
13
|
+
if config_file
|
14
|
+
puts "Starting Herdic (#{config_file})"
|
15
|
+
else
|
16
|
+
puts 'Starting Herdic'
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
def title(meta)
|
@@ -93,4 +97,3 @@ module Herdic
|
|
93
97
|
|
94
98
|
end
|
95
99
|
end
|
96
|
-
|
data/lib/herdic/version.rb
CHANGED
data/preview.gif
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herdic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Iwanaga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -91,12 +91,12 @@ files:
|
|
91
91
|
- herdic.gemspec
|
92
92
|
- lib/herdic.rb
|
93
93
|
- lib/herdic/client.rb
|
94
|
-
- lib/herdic/color.rb
|
95
94
|
- lib/herdic/loader.rb
|
96
95
|
- lib/herdic/printer.rb
|
97
96
|
- lib/herdic/store.rb
|
98
97
|
- lib/herdic/util.rb
|
99
98
|
- lib/herdic/version.rb
|
99
|
+
- preview.gif
|
100
100
|
homepage: https://github.com/creasty/herdic
|
101
101
|
licenses:
|
102
102
|
- MIT
|
data/lib/herdic/color.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
class Her
|