doraemon 1.0.3 → 1.0.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
  SHA256:
3
- metadata.gz: 304954b8b1a5f4a6ebfb49bdef2e43050e81da9b85f464d4b92e8d2b46242143
4
- data.tar.gz: 45c308031b0878c94d67f529f4984959a520c66a3d29bde16f6ea61aa384eee1
3
+ metadata.gz: a6b13348dc30f6fdc19b7a744f994707cf893e8fc1cbbb98e4846105608108e9
4
+ data.tar.gz: 53c7273a066a05484b386a571ee1d3c8c4d1e0b4966556c6f9601e93fa5af3c9
5
5
  SHA512:
6
- metadata.gz: '039270536c13f6aa909c1a18bee18a2f071103519708fb0aa5fdbf94164961c7d87842dac58d3424e802f1c740014ee5316f59959da021342d420b413bbc3f20'
7
- data.tar.gz: c9bcdc3e7d49b9f8c34679395f69a127aa5ffaf8680dc36967ab2aae28879440bd5e011c5c4db7f44e46604d2f5b326e27d6e509acde821d3edd2b1e1be1a71d
6
+ metadata.gz: 922beda4ac0abb1c3f956d123f4475a8a3aa5daf6e4fe51154075dbbe614b32162e9d4c05caa5ad81d3388e47b9be1617e3b4058d0814ab676cd88794bdfb7b5
7
+ data.tar.gz: 44b6832358be98232653587a2bff1617507706851e33a8b256fccb54e255a478cb696da51d6c3e51f4ebc6830f92bdf6bd5ca822d2cbdd3e1434e68e474329e5
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  在命令行运行:
8
8
 
9
9
  ```
10
- $ [sudo] gem install doraemon
10
+ $ [sudo] gem install doraemon
11
11
  ```
12
12
 
13
13
  等待安装完成
@@ -25,7 +25,7 @@
25
25
  在 Mock 文件所在目录运行
26
26
 
27
27
  ```
28
- $ doraemon
28
+ $ doraemon
29
29
  ```
30
30
 
31
31
  此时可以看到 doraemon 已经将目录下所有 Mock 文件载入
@@ -93,13 +93,13 @@ _result
93
93
  ## 参数
94
94
  ### 指定端口
95
95
  ```
96
- $ doraemon --port=5000
96
+ $ doraemon --port=5000
97
97
  ```
98
98
  这时 API 监听端口就是5000,而证书下载的端口再加1也就是5001
99
99
 
100
100
  ### 指定目录
101
101
  ```
102
- $ doraemon --root=~/api
102
+ $ doraemon --root=~/api
103
103
  ```
104
104
  指定工作目录为 ~/api,可以在这个目录下维护一些测试 API 文件
105
105
 
@@ -116,7 +116,7 @@ alias mock='doraemon --root=~/api --port=4000'
116
116
 
117
117
  然后运行以下命令
118
118
  ```
119
- $ source ~/.bash_profile
119
+ $ source ~/.bash_profile
120
120
  ```
121
121
 
122
122
  以后只要打开 Terminal 执行命令 mock 就可以开始以 ~/api 为工作目录进行数据 mock 了
@@ -36,7 +36,8 @@ module Doraemon
36
36
  _result = begin JSON.parse(_resp.body) rescue {} end
37
37
 
38
38
  begin
39
- _result = eval(File.read(File.join(@root, api_list[_req.path])))
39
+ _api_path = File.join(@root, api_list[_req.path])
40
+ _result = eval(File.read(_api_path)) if File.exist?(_api_path)
40
41
  rescue
41
42
  _result = {
42
43
  "code": -1,
@@ -1,3 +1,3 @@
1
1
  module Doraemon
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doraemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhuoyi