apitest 0.1.3 → 0.1.4

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: b05a220c3be3ef63f2dae5d29d27ed591fbc6600
4
- data.tar.gz: ee983eb2d81dbcfd3de82484baa6f6de59777b96
3
+ metadata.gz: a9c932efea1742c420d8d73ec4982d99ff9fb8ed
4
+ data.tar.gz: 96916744dcf87a1518ca7c5adefedcc9655b502a
5
5
  SHA512:
6
- metadata.gz: cd8375ccdcc10f991e42a5b7c6dbd23a87ac73d0a4cd6d54c8ef81493d8b0c9235af3565864e21bfb33dffb2112587e7142212b65cd0d9a4e016ae093cc71078
7
- data.tar.gz: 7aaf50e2ad5b9f27460d42f652f2097d4cc7de8aa279ce6d9761446e81634d18c28ff7cf65523b0d9e2a4699ef31f890f6f1eb2961ddd128a4d333081894f58d
6
+ metadata.gz: 345924cb41f29583ec7ca0f00788940dc88f80599d9f5a0f0fdc56a567d4678e2f401c11b238911b130c6f09f7a2a0dbe9268eb118bbdb784a6c50d7080b46bc
7
+ data.tar.gz: be819f5df9595df40196f32b53b9aa995c801c6a9cc57d7d779c45ebe4f2bba9f1ddf1105c6ca7c207b7db4e9c28160c0c64ad0cf5bc8275e36563e2ba2b3e90
data/README.md CHANGED
@@ -1,28 +1,67 @@
1
1
  # Apitest
2
2
  Short description and motivation.
3
3
 
4
- ## Usage
5
- How to use my plugin.
4
+ ## Version
5
+ 0.1.4
6
6
 
7
7
  ## Installation
8
- Add this line to your application's Gemfile:
8
+ 添加如下代码到 Gemfile:
9
9
 
10
10
  ```ruby
11
11
  gem 'apitest'
12
12
  ```
13
13
 
14
- And then execute:
14
+ 执行:
15
+ ```bash
16
+ $ bundle install
17
+ ```
18
+
19
+ 安装lsof
20
+
21
+
22
+ ```bash
23
+ $ yum install lsof -y #CentOS
24
+ ```
25
+
15
26
  ```bash
16
- $ bundle
27
+ $ sudo apt-get install lsof -y #Ubuntu
17
28
  ```
18
29
 
19
- Or install it yourself as:
20
30
  ```bash
21
- $ gem install apitest
31
+ $ brew install lsof #MacOS
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ 约定的api目录如下:
37
+ ```shell
38
+ ├── controllers
39
+ │   ├── api
40
+ │   │   └── v1
41
+ │   │   ├── foo_controller.rb
42
+ │   │   ├── bar_controller.rb
43
+ │   │   └── v2
44
+ │   │   ├── foobar_controller.rb
45
+ │   │   ├── barfoo_controller.rb
46
+ ```
47
+
48
+ mount apitest到指定url,比如:
49
+
50
+ ```ruby
51
+ mount Apitest::Engine => "/apitest"
52
+
22
53
  ```
23
54
 
55
+ 浏览器中访问apitest 的url
56
+
57
+
58
+
59
+
60
+ ## TODO
61
+ - [ ] 可自定义api目录
62
+
24
63
  ## Contributing
25
- Contribution directions go here.
64
+
26
65
 
27
66
  ## License
28
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
67
+ [MIT License](http://opensource.org/licenses/MIT).
@@ -1,33 +1 @@
1
- Process.detach(
2
- fork do
3
- p 'Kill Apitest WebSocket Process ...'
4
- `lsof -i :9527 |awk '$1 == "ruby" {print $2}' |xargs kill -9`
5
- begin
6
- class Reader < EventMachine::FileTail
7
- def initialize(path, startpos=-1, &block)
8
- super(path, startpos)
9
- @buffer = BufferedTokenizer.new
10
- @block = block
11
- end
12
-
13
- def receive_data(data)
14
- @buffer.extract(data).each { |line| @block.call(line) }
15
- end
16
- end
17
-
18
- filename = "#{Rails.root}/log/#{Rails.env}.log"
19
-
20
- EventMachine.run do
21
- WebSocket::EventMachine::Server.start(:host => "0.0.0.0", :port => 9527) do |ws|
22
- proc = Proc.new { |line|
23
- ws.send Ansi::To::Html.new(line.strip).to_html.strip
24
- }
25
- EventMachine::file_tail(filename, Reader, &proc)
26
- end
27
- p 'Start Apitest WebSocket Process !'
28
- end
29
- rescue Exception => e
30
- retry
31
- end
32
- end
33
- )
1
+ Apitest.start_server_log_listen unless require("rails/commands/server")
@@ -10,5 +10,41 @@ require 'eventmachine-tail'
10
10
  require 'websocket-eventmachine-server'
11
11
 
12
12
  module Apitest
13
- # Your code goes here...
13
+ class Reader < EventMachine::FileTail
14
+ def initialize(path, startpos=-1, &block)
15
+ super(path, startpos)
16
+ @buffer = BufferedTokenizer.new
17
+ @block = block
18
+ end
19
+
20
+ def receive_data(data)
21
+ @buffer.extract(data).each { |line| @block.call(line) }
22
+ end
23
+ end
24
+ def self.start_server_log_listen
25
+ Process.detach(
26
+ fork do
27
+ p 'Kill Apitest WebSocket Process ...'
28
+ `lsof -i :9527 |awk '$1 == "ruby" {print $2}' |xargs kill -9`
29
+ begin
30
+ filename = "#{Rails.root}/log/#{Rails.env}.log"
31
+
32
+ EventMachine.run do
33
+ WebSocket::EventMachine::Server.start(:host => "0.0.0.0", :port => 9527) do |ws|
34
+ proc = Proc.new { |line|
35
+ ws.send Ansi::To::Html.new(line.strip).to_html.strip
36
+ }
37
+ EventMachine::file_tail(filename, Reader, &proc)
38
+ end
39
+ p 'Start Apitest WebSocket Process !'
40
+ end
41
+ rescue Exception => e
42
+ retry
43
+ end
44
+ end
45
+ )
46
+ end
14
47
  end
48
+
49
+
50
+
@@ -1,3 +1,3 @@
1
1
  module Apitest
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyuubi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-27 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails