lecter 0.1.2
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 +7 -0
- data/.gitignore +12 -0
- data/.idea/encodings.xml +6 -0
- data/.idea/lecter.iml +52 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/workspace.xml +826 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +111 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/highlight.pack.js +2 -0
- data/app/assets/stylesheets/railscasts.css +106 -0
- data/app/controllers/lecter/diagnosis_controller.rb +47 -0
- data/app/views/lecter/diagnosis/new.erb +11 -0
- data/app/views/lecter/diagnosis/show.slim +57 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lecter.gemspec +37 -0
- data/lib/lecter/rack.rb +34 -0
- data/lib/lecter/version.rb +3 -0
- data/lib/lecter.rb +16 -0
- metadata +141 -0
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at neodelf@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lecter (0.1.1)
|
5
|
+
rest-client
|
6
|
+
slim-rails
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (5.2.3)
|
12
|
+
actionview (= 5.2.3)
|
13
|
+
activesupport (= 5.2.3)
|
14
|
+
rack (~> 2.0)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
18
|
+
actionview (5.2.3)
|
19
|
+
activesupport (= 5.2.3)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
24
|
+
activesupport (5.2.3)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
builder (3.2.3)
|
30
|
+
concurrent-ruby (1.1.5)
|
31
|
+
crass (1.0.4)
|
32
|
+
diff-lcs (1.3)
|
33
|
+
domain_name (0.5.20190701)
|
34
|
+
unf (>= 0.0.5, < 1.0.0)
|
35
|
+
erubi (1.8.0)
|
36
|
+
http-cookie (1.0.3)
|
37
|
+
domain_name (~> 0.5)
|
38
|
+
i18n (1.6.0)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
loofah (2.2.3)
|
41
|
+
crass (~> 1.0.2)
|
42
|
+
nokogiri (>= 1.5.9)
|
43
|
+
method_source (0.9.2)
|
44
|
+
mime-types (3.2.2)
|
45
|
+
mime-types-data (~> 3.2015)
|
46
|
+
mime-types-data (3.2019.0331)
|
47
|
+
mini_portile2 (2.4.0)
|
48
|
+
minitest (5.11.3)
|
49
|
+
netrc (0.11.0)
|
50
|
+
nokogiri (1.10.3)
|
51
|
+
mini_portile2 (~> 2.4.0)
|
52
|
+
rack (2.0.7)
|
53
|
+
rack-test (1.1.0)
|
54
|
+
rack (>= 1.0, < 3)
|
55
|
+
rails-dom-testing (2.0.3)
|
56
|
+
activesupport (>= 4.2.0)
|
57
|
+
nokogiri (>= 1.6)
|
58
|
+
rails-html-sanitizer (1.0.4)
|
59
|
+
loofah (~> 2.2, >= 2.2.2)
|
60
|
+
railties (5.2.3)
|
61
|
+
actionpack (= 5.2.3)
|
62
|
+
activesupport (= 5.2.3)
|
63
|
+
method_source
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
thor (>= 0.19.0, < 2.0)
|
66
|
+
rake (10.5.0)
|
67
|
+
rest-client (2.0.2)
|
68
|
+
http-cookie (>= 1.0.2, < 2.0)
|
69
|
+
mime-types (>= 1.16, < 4.0)
|
70
|
+
netrc (~> 0.8)
|
71
|
+
rspec (3.8.0)
|
72
|
+
rspec-core (~> 3.8.0)
|
73
|
+
rspec-expectations (~> 3.8.0)
|
74
|
+
rspec-mocks (~> 3.8.0)
|
75
|
+
rspec-core (3.8.2)
|
76
|
+
rspec-support (~> 3.8.0)
|
77
|
+
rspec-expectations (3.8.4)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.8.0)
|
80
|
+
rspec-mocks (3.8.1)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.8.0)
|
83
|
+
rspec-support (3.8.2)
|
84
|
+
slim (4.0.1)
|
85
|
+
temple (>= 0.7.6, < 0.9)
|
86
|
+
tilt (>= 2.0.6, < 2.1)
|
87
|
+
slim-rails (3.2.0)
|
88
|
+
actionpack (>= 3.1)
|
89
|
+
railties (>= 3.1)
|
90
|
+
slim (>= 3.0, < 5.0)
|
91
|
+
temple (0.8.1)
|
92
|
+
thor (0.20.3)
|
93
|
+
thread_safe (0.3.6)
|
94
|
+
tilt (2.0.9)
|
95
|
+
tzinfo (1.2.5)
|
96
|
+
thread_safe (~> 0.1)
|
97
|
+
unf (0.1.4)
|
98
|
+
unf_ext
|
99
|
+
unf_ext (0.0.7.6)
|
100
|
+
|
101
|
+
PLATFORMS
|
102
|
+
ruby
|
103
|
+
|
104
|
+
DEPENDENCIES
|
105
|
+
bundler (~> 2.0)
|
106
|
+
lecter!
|
107
|
+
rake (~> 10.0)
|
108
|
+
rspec (~> 3.0)
|
109
|
+
|
110
|
+
BUNDLED WITH
|
111
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Neodelf
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Lecter
|
2
|
+
|
3
|
+
There are a lot of people around developing web apps also as new developers on projects. Sometimes they don't know how app works and which exactly processes work.
|
4
|
+
That gem will help them to understand which code executes per request.
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'lecter'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install lecter
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
|
26
|
+
1. Use multithreading server such like a `puma` with workers more than `1`.
|
27
|
+
2. Precompile `railscasts.css` and `highlight.pack.js` assets.
|
28
|
+
3. Add routes in your `routes.rb`
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
namespace :lecter do
|
32
|
+
resource :diagnosis, only: %i[show create new], controller: :diagnosis
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/neodelf/lecter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
43
|
+
|
44
|
+
## Code of Conduct
|
45
|
+
|
46
|
+
Everyone interacting in the Lecter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lecter/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! highlight.js v9.15.8 | BSD3 License | git.io/hljslicense */
|
2
|
+
!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(a){var f=[],u=Object.keys,N={},c={},n=/^(no-?highlight|plain|text)$/i,s=/\blang(?:uage)?-([\w-]+)\b/i,t=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,r={case_insensitive:"cI",lexemes:"l",contains:"c",keywords:"k",subLanguage:"sL",className:"cN",begin:"b",beginKeywords:"bK",end:"e",endsWithParent:"eW",illegal:"i",excludeBegin:"eB",excludeEnd:"eE",returnBegin:"rB",returnEnd:"rE",relevance:"r",variants:"v",IDENT_RE:"IR",UNDERSCORE_IDENT_RE:"UIR",NUMBER_RE:"NR",C_NUMBER_RE:"CNR",BINARY_NUMBER_RE:"BNR",RE_STARTERS_RE:"RSR",BACKSLASH_ESCAPE:"BE",APOS_STRING_MODE:"ASM",QUOTE_STRING_MODE:"QSM",PHRASAL_WORDS_MODE:"PWM",C_LINE_COMMENT_MODE:"CLCM",C_BLOCK_COMMENT_MODE:"CBCM",HASH_COMMENT_MODE:"HCM",NUMBER_MODE:"NM",C_NUMBER_MODE:"CNM",BINARY_NUMBER_MODE:"BNM",CSS_NUMBER_MODE:"CSSNM",REGEXP_MODE:"RM",TITLE_MODE:"TM",UNDERSCORE_TITLE_MODE:"UTM",COMMENT:"C",beginRe:"bR",endRe:"eR",illegalRe:"iR",lexemesRe:"lR",terminators:"t",terminator_end:"tE"},b="</span>",h={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};function _(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function E(e){return e.nodeName.toLowerCase()}function v(e,n){var t=e&&e.exec(n);return t&&0===t.index}function l(e){return n.test(e)}function g(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function R(e){var a=[];return function e(n,t){for(var r=n.firstChild;r;r=r.nextSibling)3===r.nodeType?t+=r.nodeValue.length:1===r.nodeType&&(a.push({event:"start",offset:t,node:r}),t=e(r,t),E(r).match(/br|hr|img|input/)||a.push({event:"stop",offset:t,node:r}));return t}(e,0),a}function i(e){if(r&&!e.langApiRestored){for(var n in e.langApiRestored=!0,r)e[n]&&(e[r[n]]=e[n]);(e.c||[]).concat(e.v||[]).forEach(i)}}function m(o){function s(e){return e&&e.source||e}function c(e,n){return new RegExp(s(e),"m"+(o.cI?"i":"")+(n?"g":""))}!function n(t,e){if(!t.compiled){if(t.compiled=!0,t.k=t.k||t.bK,t.k){function r(t,e){o.cI&&(e=e.toLowerCase()),e.split(" ").forEach(function(e){var n=e.split("|");a[n[0]]=[t,n[1]?Number(n[1]):1]})}var a={};"string"==typeof t.k?r("keyword",t.k):u(t.k).forEach(function(e){r(e,t.k[e])}),t.k=a}t.lR=c(t.l||/\w+/,!0),e&&(t.bK&&(t.b="\\b("+t.bK.split(" ").join("|")+")\\b"),t.b||(t.b=/\B|\b/),t.bR=c(t.b),t.endSameAsBegin&&(t.e=t.b),t.e||t.eW||(t.e=/\B|\b/),t.e&&(t.eR=c(t.e)),t.tE=s(t.e)||"",t.eW&&e.tE&&(t.tE+=(t.e?"|":"")+e.tE)),t.i&&(t.iR=c(t.i)),null==t.r&&(t.r=1),t.c||(t.c=[]),t.c=Array.prototype.concat.apply([],t.c.map(function(e){return function(n){return n.v&&!n.cached_variants&&(n.cached_variants=n.v.map(function(e){return g(n,{v:null},e)})),n.cached_variants||n.eW&&[g(n)]||[n]}("self"===e?t:e)})),t.c.forEach(function(e){n(e,t)}),t.starts&&n(t.starts,e);var i=t.c.map(function(e){return e.bK?"\\.?(?:"+e.b+")\\.?":e.b}).concat([t.tE,t.i]).map(s).filter(Boolean);t.t=i.length?c(function(e,n){for(var t=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./,r=0,a="",i=0;i<e.length;i++){var o=r,c=s(e[i]);for(0<i&&(a+=n);0<c.length;){var u=t.exec(c);if(null==u){a+=c;break}a+=c.substring(0,u.index),c=c.substring(u.index+u[0].length),"\\"==u[0][0]&&u[1]?a+="\\"+String(Number(u[1])+o):(a+=u[0],"("==u[0]&&r++)}}return a}(i,"|"),!0):{exec:function(){return null}}}}(o)}function C(e,n,i,t){function c(e,n,t,r){var a='<span class="'+(r?"":h.classPrefix);return e?(a+=e+'">')+n+(t?"":b):n}function o(){E+=null!=l.sL?function(){var e="string"==typeof l.sL;if(e&&!N[l.sL])return _(g);var n=e?C(l.sL,g,!0,f[l.sL]):O(g,l.sL.length?l.sL:void 0);return 0<l.r&&(R+=n.r),e&&(f[l.sL]=n.top),c(n.language,n.value,!1,!0)}():function(){var e,n,t,r,a,i,o;if(!l.k)return _(g);for(r="",n=0,l.lR.lastIndex=0,t=l.lR.exec(g);t;)r+=_(g.substring(n,t.index)),a=l,i=t,void 0,o=s.cI?i[0].toLowerCase():i[0],(e=a.k.hasOwnProperty(o)&&a.k[o])?(R+=e[1],r+=c(e[0],_(t[0]))):r+=_(t[0]),n=l.lR.lastIndex,t=l.lR.exec(g);return r+_(g.substr(n))}(),g=""}function u(e){E+=e.cN?c(e.cN,"",!0):"",l=Object.create(e,{parent:{value:l}})}function r(e,n){if(g+=e,null==n)return o(),0;var t=function(e,n){var t,r,a;for(t=0,r=n.c.length;t<r;t++)if(v(n.c[t].bR,e))return n.c[t].endSameAsBegin&&(n.c[t].eR=(a=n.c[t].bR.exec(e)[0],new RegExp(a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"m"))),n.c[t]}(n,l);if(t)return t.skip?g+=n:(t.eB&&(g+=n),o(),t.rB||t.eB||(g=n)),u(t),t.rB?0:n.length;var r=function e(n,t){if(v(n.eR,t)){for(;n.endsParent&&n.parent;)n=n.parent;return n}if(n.eW)return e(n.parent,t)}(l,n);if(r){var a=l;for(a.skip?g+=n:(a.rE||a.eE||(g+=n),o(),a.eE&&(g=n));l.cN&&(E+=b),l.skip||l.sL||(R+=l.r),(l=l.parent)!==r.parent;);return r.starts&&(r.endSameAsBegin&&(r.starts.eR=r.eR),u(r.starts)),a.rE?0:n.length}if(function(e,n){return!i&&v(n.iR,e)}(n,l))throw new Error('Illegal lexeme "'+n+'" for mode "'+(l.cN||"<unnamed>")+'"');return g+=n,n.length||1}var s=B(e);if(!s)throw new Error('Unknown language: "'+e+'"');m(s);var a,l=t||s,f={},E="";for(a=l;a!==s;a=a.parent)a.cN&&(E=c(a.cN,"",!0)+E);var g="",R=0;try{for(var d,p,M=0;l.t.lastIndex=M,d=l.t.exec(n);)p=r(n.substring(M,d.index),d[0]),M=d.index+p;for(r(n.substr(M)),a=l;a.parent;a=a.parent)a.cN&&(E+=b);return{r:R,value:E,language:e,top:l}}catch(e){if(e.message&&-1!==e.message.indexOf("Illegal"))return{r:0,value:_(n)};throw e}}function O(t,e){e=e||h.languages||u(N);var r={r:0,value:_(t)},a=r;return e.filter(B).filter(M).forEach(function(e){var n=C(e,t,!1);n.language=e,n.r>a.r&&(a=n),n.r>r.r&&(a=r,r=n)}),a.language&&(r.second_best=a),r}function d(e){return h.tabReplace||h.useBR?e.replace(t,function(e,n){return h.useBR&&"\n"===e?"<br>":h.tabReplace?n.replace(/\t/g,h.tabReplace):""}):e}function o(e){var n,t,r,a,i,o=function(e){var n,t,r,a,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=s.exec(i))return B(t[1])?t[1]:"no-highlight";for(n=0,r=(i=i.split(/\s+/)).length;n<r;n++)if(l(a=i[n])||B(a))return a}(e);l(o)||(h.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div")).innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ \/]*>/g,"\n"):n=e,i=n.textContent,r=o?C(o,i,!0):O(i),(t=R(n)).length&&((a=document.createElementNS("http://www.w3.org/1999/xhtml","div")).innerHTML=r.value,r.value=function(e,n,t){var r=0,a="",i=[];function o(){return e.length&&n.length?e[0].offset!==n[0].offset?e[0].offset<n[0].offset?e:n:"start"===n[0].event?e:n:e.length?e:n}function c(e){a+="<"+E(e)+f.map.call(e.attributes,function(e){return" "+e.nodeName+'="'+_(e.value).replace('"',""")+'"'}).join("")+">"}function u(e){a+="</"+E(e)+">"}function s(e){("start"===e.event?c:u)(e.node)}for(;e.length||n.length;){var l=o();if(a+=_(t.substring(r,l[0].offset)),r=l[0].offset,l===e){for(i.reverse().forEach(u);s(l.splice(0,1)[0]),(l=o())===e&&l.length&&l[0].offset===r;);i.reverse().forEach(c)}else"start"===l[0].event?i.push(l[0].node):i.pop(),s(l.splice(0,1)[0])}return a+_(t.substr(r))}(t,R(a),i)),r.value=d(r.value),e.innerHTML=r.value,e.className=function(e,n,t){var r=n?c[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}(e.className,o,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function p(){if(!p.called){p.called=!0;var e=document.querySelectorAll("pre code");f.forEach.call(e,o)}}function B(e){return e=(e||"").toLowerCase(),N[e]||N[c[e]]}function M(e){var n=B(e);return n&&!n.disableAutodetect}return a.highlight=C,a.highlightAuto=O,a.fixMarkup=d,a.highlightBlock=o,a.configure=function(e){h=g(h,e)},a.initHighlighting=p,a.initHighlightingOnLoad=function(){addEventListener("DOMContentLoaded",p,!1),addEventListener("load",p,!1)},a.registerLanguage=function(n,e){var t=N[n]=e(a);i(t),t.aliases&&t.aliases.forEach(function(e){c[e]=n})},a.listLanguages=function(){return u(N)},a.getLanguage=B,a.autoDetection=M,a.inherit=g,a.IR=a.IDENT_RE="[a-zA-Z]\\w*",a.UIR=a.UNDERSCORE_IDENT_RE="[a-zA-Z_]\\w*",a.NR=a.NUMBER_RE="\\b\\d+(\\.\\d+)?",a.CNR=a.C_NUMBER_RE="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",a.BNR=a.BINARY_NUMBER_RE="\\b(0b[01]+)",a.RSR=a.RE_STARTERS_RE="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",a.BE=a.BACKSLASH_ESCAPE={b:"\\\\[\\s\\S]",r:0},a.ASM=a.APOS_STRING_MODE={cN:"string",b:"'",e:"'",i:"\\n",c:[a.BE]},a.QSM=a.QUOTE_STRING_MODE={cN:"string",b:'"',e:'"',i:"\\n",c:[a.BE]},a.PWM=a.PHRASAL_WORDS_MODE={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},a.C=a.COMMENT=function(e,n,t){var r=a.inherit({cN:"comment",b:e,e:n,c:[]},t||{});return r.c.push(a.PWM),r.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),r},a.CLCM=a.C_LINE_COMMENT_MODE=a.C("//","$"),a.CBCM=a.C_BLOCK_COMMENT_MODE=a.C("/\\*","\\*/"),a.HCM=a.HASH_COMMENT_MODE=a.C("#","$"),a.NM=a.NUMBER_MODE={cN:"number",b:a.NR,r:0},a.CNM=a.C_NUMBER_MODE={cN:"number",b:a.CNR,r:0},a.BNM=a.BINARY_NUMBER_MODE={cN:"number",b:a.BNR,r:0},a.CSSNM=a.CSS_NUMBER_MODE={cN:"number",b:a.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},a.RM=a.REGEXP_MODE={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[a.BE,{b:/\[/,e:/\]/,r:0,c:[a.BE]}]},a.TM=a.TITLE_MODE={cN:"title",b:a.IR,r:0},a.UTM=a.UNDERSCORE_TITLE_MODE={cN:"title",b:a.UIR,r:0},a.METHOD_GUARD={b:"\\.\\s*"+a.UIR,r:0},a});hljs.registerLanguage("ruby",function(e){var b="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},c={cN:"doctag",b:"@[A-Za-z]+"},a={b:"#<",e:">"},s=[e.C("#","$",{c:[c]}),e.C("^\\=begin","^\\=end",{c:[c],r:10}),e.C("^__END__","\\n$")],n={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,n],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{b:/<<(-?)\w+$/,e:/^\s*\w+$/}]},i={cN:"params",b:"\\(",e:"\\)",endsParent:!0,k:r},d=[t,a,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{b:"<\\s*",c:[{b:"("+e.IR+"::)?"+e.IR}]}].concat(s)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:b}),i].concat(s)},{b:e.IR+"::"},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":(?!\\s)",c:[t,{b:b}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{cN:"params",b:/\|/,e:/\|/,k:r},{b:"("+e.RSR+"|unless)\\s*",k:"unless",c:[a,{cN:"regexp",c:[e.BE,n],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(s),r:0}].concat(s);n.c=d;var l=[{b:/^\s*=>/,starts:{e:"$",c:i.c=d}},{cN:"meta",b:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+>|(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>)",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:s.concat(l).concat(d)}});
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Railscasts-like style (c) Visoft, Inc. (Damien White)
|
4
|
+
|
5
|
+
*/
|
6
|
+
|
7
|
+
.hljs {
|
8
|
+
display: block;
|
9
|
+
overflow-x: auto;
|
10
|
+
padding: 0.5em;
|
11
|
+
background: #232323;
|
12
|
+
color: #e6e1dc;
|
13
|
+
}
|
14
|
+
|
15
|
+
.hljs-comment,
|
16
|
+
.hljs-quote {
|
17
|
+
color: #bc9458;
|
18
|
+
font-style: italic;
|
19
|
+
}
|
20
|
+
|
21
|
+
.hljs-keyword,
|
22
|
+
.hljs-selector-tag {
|
23
|
+
color: #c26230;
|
24
|
+
}
|
25
|
+
|
26
|
+
.hljs-string,
|
27
|
+
.hljs-number,
|
28
|
+
.hljs-regexp,
|
29
|
+
.hljs-variable,
|
30
|
+
.hljs-template-variable {
|
31
|
+
color: #a5c261;
|
32
|
+
}
|
33
|
+
|
34
|
+
.hljs-subst {
|
35
|
+
color: #519f50;
|
36
|
+
}
|
37
|
+
|
38
|
+
.hljs-tag,
|
39
|
+
.hljs-name {
|
40
|
+
color: #e8bf6a;
|
41
|
+
}
|
42
|
+
|
43
|
+
.hljs-type {
|
44
|
+
color: #da4939;
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
.hljs-symbol,
|
49
|
+
.hljs-bullet,
|
50
|
+
.hljs-built_in,
|
51
|
+
.hljs-builtin-name,
|
52
|
+
.hljs-attr,
|
53
|
+
.hljs-link {
|
54
|
+
color: #6d9cbe;
|
55
|
+
}
|
56
|
+
|
57
|
+
.hljs-params {
|
58
|
+
color: #d0d0ff;
|
59
|
+
}
|
60
|
+
|
61
|
+
.hljs-attribute {
|
62
|
+
color: #cda869;
|
63
|
+
}
|
64
|
+
|
65
|
+
.hljs-meta {
|
66
|
+
color: #9b859d;
|
67
|
+
}
|
68
|
+
|
69
|
+
.hljs-title,
|
70
|
+
.hljs-section {
|
71
|
+
color: #ffc66d;
|
72
|
+
}
|
73
|
+
|
74
|
+
.hljs-addition {
|
75
|
+
background-color: #144212;
|
76
|
+
color: #e6e1dc;
|
77
|
+
display: inline-block;
|
78
|
+
width: 100%;
|
79
|
+
}
|
80
|
+
|
81
|
+
.hljs-deletion {
|
82
|
+
background-color: #600;
|
83
|
+
color: #e6e1dc;
|
84
|
+
display: inline-block;
|
85
|
+
width: 100%;
|
86
|
+
}
|
87
|
+
|
88
|
+
.hljs-selector-class {
|
89
|
+
color: #9b703f;
|
90
|
+
}
|
91
|
+
|
92
|
+
.hljs-selector-id {
|
93
|
+
color: #8b98ab;
|
94
|
+
}
|
95
|
+
|
96
|
+
.hljs-emphasis {
|
97
|
+
font-style: italic;
|
98
|
+
}
|
99
|
+
|
100
|
+
.hljs-strong {
|
101
|
+
font-weight: bold;
|
102
|
+
}
|
103
|
+
|
104
|
+
.hljs-link {
|
105
|
+
text-decoration: underline;
|
106
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'slim-rails'
|
3
|
+
|
4
|
+
class Lecter::DiagnosisController < ActionController::Base
|
5
|
+
def new
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
if diagnosis_params[:method].downcase == 'get'
|
13
|
+
response = ::RestClient.get(
|
14
|
+
'localhost:3000/' + diagnosis_params[:endpoint],
|
15
|
+
params: (YAML.load(diagnosis_params[:params]) || {}).merge(lecter_analysis: true)
|
16
|
+
).body
|
17
|
+
prepare_data(response)
|
18
|
+
elsif diagnosis_params[:method].downcase == 'post'
|
19
|
+
response = ::RestClient.post(
|
20
|
+
'localhost:3000/' + diagnosis_params[:endpoint],
|
21
|
+
YAML.load(diagnosis_params[:params]).merge(lecter_analysis: true)
|
22
|
+
).body
|
23
|
+
prepare_data(response)
|
24
|
+
end
|
25
|
+
|
26
|
+
render :show
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def diagnosis_params
|
32
|
+
params.permit(:endpoint, :params, :method)
|
33
|
+
end
|
34
|
+
|
35
|
+
def prepare_data(items)
|
36
|
+
@lines = []
|
37
|
+
@items = items.split(';')
|
38
|
+
@items.each do |item|
|
39
|
+
file = item.split(' ')[0]
|
40
|
+
if @lines.last.is_a?(Hash) && @lines.last.keys.first.to_s == file
|
41
|
+
@lines.last[file] = @lines.last[file] << item.split(' ')[1].to_i
|
42
|
+
else
|
43
|
+
@lines << {"#{file}" => [item.split(' ')[1].to_i]}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
= javascript_include_tag 'highlight.pack.js', '//code.jquery.com/jquery-1.12.4.js', '//code.jquery.com/ui/1.12.1/jquery-ui.js'
|
2
|
+
= stylesheet_link_tag 'railscasts', '//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css'
|
3
|
+
|
4
|
+
|
5
|
+
h1 Lecter diagnosis
|
6
|
+
|
7
|
+
.left
|
8
|
+
div id='accordion'
|
9
|
+
- @lines.each_with_index do |item, item_index|
|
10
|
+
div
|
11
|
+
h5 id="anchor#{item_index}"
|
12
|
+
- file = item.keys.first
|
13
|
+
= file
|
14
|
+
- lines = item.values.split(' ').flatten.map(&:to_i)
|
15
|
+
= lines
|
16
|
+
- previous_row_is_empty = false
|
17
|
+
div
|
18
|
+
pre
|
19
|
+
- file_context = File.open(file, 'r').read.split("\n")
|
20
|
+
- file_context.each_with_index do |row, index_row|
|
21
|
+
- include = lines.include?(index_row + 1)
|
22
|
+
- if include || lines.reduce(false) { |memo, line| memo || index_row.in?(line - 5..line + 4) }
|
23
|
+
- previous_row_is_empty = false
|
24
|
+
code class='ruby' style=('background-color: #4a4a4a;' if include)
|
25
|
+
= "#{index_row + 1} #{row} #{lines.index(index_row + 1) + 1 if include}"
|
26
|
+
- elsif !previous_row_is_empty
|
27
|
+
code
|
28
|
+
- previous_row_is_empty = true
|
29
|
+
'...
|
30
|
+
.right
|
31
|
+
- @lines.each_with_index do |item, item_index|
|
32
|
+
p
|
33
|
+
= link_to item.keys.first.split('/').last, "#anchor#{item_index}"
|
34
|
+
|
35
|
+
css:
|
36
|
+
.ui-accordion .ui-accordion-header {
|
37
|
+
font-size: 78%;
|
38
|
+
}
|
39
|
+
|
40
|
+
.left {
|
41
|
+
float: left;
|
42
|
+
width: 70%;
|
43
|
+
}
|
44
|
+
|
45
|
+
.right {
|
46
|
+
float: left;
|
47
|
+
padding-left: 10px;
|
48
|
+
}
|
49
|
+
|
50
|
+
javascript:
|
51
|
+
hljs.initHighlightingOnLoad();
|
52
|
+
$('#accordion > div').accordion({
|
53
|
+
header: 'h5',
|
54
|
+
heightStyle: 'content',
|
55
|
+
collapsible: true,
|
56
|
+
active: 1
|
57
|
+
});
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'lecter'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lecter.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'lecter/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'lecter'
|
7
|
+
spec.version = Lecter::VERSION
|
8
|
+
spec.authors = ['Neodelf']
|
9
|
+
spec.email = ['neodelf@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
12
|
+
spec.description = %q{Write a longer description or delete this line.}
|
13
|
+
spec.homepage = 'https://github.com/neodelf/lecter'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
# spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
|
20
|
+
# spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
|
35
|
+
spec.add_runtime_dependency 'slim-rails'
|
36
|
+
spec.add_runtime_dependency 'rest-client'
|
37
|
+
end
|
data/lib/lecter/rack.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Lecter::Rack
|
2
|
+
def initialize(app)
|
3
|
+
@app = app
|
4
|
+
end
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
request = Rack::Request.new(env)
|
8
|
+
if request.params['lecter_analysis']
|
9
|
+
thread = Thread.current
|
10
|
+
thread[:items] = ''
|
11
|
+
tp = TracePoint.new(:line, :class, :call, :c_call, :return) do |tp|
|
12
|
+
if tp.path &&
|
13
|
+
!tp.path.include?('/app/views') &&
|
14
|
+
!tp.path.include?('/app/helpers') &&
|
15
|
+
tp.path.include?(Rails.root.to_s) &&
|
16
|
+
tp.method_id != :method_added &&
|
17
|
+
tp.defined_class != Module &&
|
18
|
+
tp.defined_class != Class &&
|
19
|
+
tp.defined_class != String &&
|
20
|
+
tp.defined_class != Kernel &&
|
21
|
+
tp.defined_class != NilClass
|
22
|
+
|
23
|
+
thread[:items] += [tp.path, tp.lineno, tp.defined_class, tp.method_id, tp.event].join(' ') + ';'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
tp.enable
|
27
|
+
end
|
28
|
+
status, headers, response = @app.call(env)
|
29
|
+
|
30
|
+
[status, headers, tp ? [thread[:items]] : response]
|
31
|
+
ensure
|
32
|
+
tp.disable if tp
|
33
|
+
end
|
34
|
+
end
|
data/lib/lecter.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "lecter/version"
|
2
|
+
|
3
|
+
module Lecter
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
end
|
6
|
+
|
7
|
+
autoload :Rack, 'lecter/rack'
|
8
|
+
|
9
|
+
if defined? Rails::Railtie
|
10
|
+
class LecterRailtie < Rails::Railtie
|
11
|
+
initializer 'lecter.configure_rails_initialization' do |app|
|
12
|
+
app.middleware.use Lecter::Rack
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|