comment_extractor 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +132 -0
- data/bin/comment_parser_debug +45 -0
- data/lib/comment_extractor/code_object/comment.rb +19 -0
- data/lib/comment_extractor/code_object.rb +12 -0
- data/lib/comment_extractor/code_objects.rb +46 -0
- data/lib/comment_extractor/configuration.rb +50 -0
- data/lib/comment_extractor/encoding.rb +40 -0
- data/lib/comment_extractor/extractor/c.rb +8 -0
- data/lib/comment_extractor/extractor/cc.rb +8 -0
- data/lib/comment_extractor/extractor/class.rb +8 -0
- data/lib/comment_extractor/extractor/clojure.rb +11 -0
- data/lib/comment_extractor/extractor/coffee.rb +13 -0
- data/lib/comment_extractor/extractor/concerns/simple_extractor.rb +189 -0
- data/lib/comment_extractor/extractor/concerns/slash_extractor.rb +16 -0
- data/lib/comment_extractor/extractor/cpp.rb +8 -0
- data/lib/comment_extractor/extractor/cs.rb +8 -0
- data/lib/comment_extractor/extractor/css.rb +8 -0
- data/lib/comment_extractor/extractor/cxx.rb +8 -0
- data/lib/comment_extractor/extractor/d.rb +9 -0
- data/lib/comment_extractor/extractor/erlang.rb +12 -0
- data/lib/comment_extractor/extractor/fortran.rb +11 -0
- data/lib/comment_extractor/extractor/go.rb +8 -0
- data/lib/comment_extractor/extractor/h.rb +8 -0
- data/lib/comment_extractor/extractor/haml.rb +49 -0
- data/lib/comment_extractor/extractor/haskell.rb +12 -0
- data/lib/comment_extractor/extractor/hpp.rb +8 -0
- data/lib/comment_extractor/extractor/html.rb +13 -0
- data/lib/comment_extractor/extractor/java.rb +8 -0
- data/lib/comment_extractor/extractor/java_script.rb +12 -0
- data/lib/comment_extractor/extractor/lisp.rb +11 -0
- data/lib/comment_extractor/extractor/lua.rb +12 -0
- data/lib/comment_extractor/extractor/m.rb +9 -0
- data/lib/comment_extractor/extractor/markdown.rb +7 -0
- data/lib/comment_extractor/extractor/mm.rb +8 -0
- data/lib/comment_extractor/extractor/perl.rb +12 -0
- data/lib/comment_extractor/extractor/php.rb +8 -0
- data/lib/comment_extractor/extractor/python.rb +13 -0
- data/lib/comment_extractor/extractor/ruby.rb +40 -0
- data/lib/comment_extractor/extractor/sass.rb +8 -0
- data/lib/comment_extractor/extractor/scala.rb +8 -0
- data/lib/comment_extractor/extractor/scss.rb +8 -0
- data/lib/comment_extractor/extractor/shell.rb +11 -0
- data/lib/comment_extractor/extractor/sqf.rb +8 -0
- data/lib/comment_extractor/extractor/sql.rb +12 -0
- data/lib/comment_extractor/extractor/sqs.rb +7 -0
- data/lib/comment_extractor/extractor/tex.rb +12 -0
- data/lib/comment_extractor/extractor/text.rb +10 -0
- data/lib/comment_extractor/extractor/yaml.rb +12 -0
- data/lib/comment_extractor/extractor.rb +96 -0
- data/lib/comment_extractor/extractor_manager.rb +158 -0
- data/lib/comment_extractor/file.rb +42 -0
- data/lib/comment_extractor/parser.rb +33 -0
- data/lib/comment_extractor/smart_string_scanner.rb +11 -0
- data/lib/comment_extractor/version.rb +4 -0
- data/lib/comment_extractor.rb +18 -0
- data/spec/assets/binary_file +0 -0
- data/spec/assets/shebang_file +3 -0
- data/spec/assets/source_code/c.c +158 -0
- data/spec/assets/source_code/cc.cc +24 -0
- data/spec/assets/source_code/class +0 -0
- data/spec/assets/source_code/clojure.clj +41 -0
- data/spec/assets/source_code/coffee.coffee +27 -0
- data/spec/assets/source_code/cpp.cpp +130 -0
- data/spec/assets/source_code/cs.cs +53 -0
- data/spec/assets/source_code/css.css +37 -0
- data/spec/assets/source_code/cxx +0 -0
- data/spec/assets/source_code/d.d +110 -0
- data/spec/assets/source_code/erlang.es +34 -0
- data/spec/assets/source_code/fortran.f +41 -0
- data/spec/assets/source_code/golang.go +61 -0
- data/spec/assets/source_code/h +0 -0
- data/spec/assets/source_code/haml.haml +26 -0
- data/spec/assets/source_code/haskell.hs +36 -0
- data/spec/assets/source_code/hpp +0 -0
- data/spec/assets/source_code/html.html +139 -0
- data/spec/assets/source_code/java.java +39 -0
- data/spec/assets/source_code/java_script.js +164 -0
- data/spec/assets/source_code/lisp.el +18 -0
- data/spec/assets/source_code/lua.lua +34 -0
- data/spec/assets/source_code/m +0 -0
- data/spec/assets/source_code/mm +0 -0
- data/spec/assets/source_code/perl.pl +36 -0
- data/spec/assets/source_code/php.php +31 -0
- data/spec/assets/source_code/python.py +139 -0
- data/spec/assets/source_code/ruby.rb +36 -0
- data/spec/assets/source_code/sass.sass +77 -0
- data/spec/assets/source_code/scala.scala +46 -0
- data/spec/assets/source_code/scss.scss +93 -0
- data/spec/assets/source_code/shell.sh +5 -0
- data/spec/assets/source_code/sqf +0 -0
- data/spec/assets/source_code/sql.sql +11 -0
- data/spec/assets/source_code/sqs +0 -0
- data/spec/assets/source_code/tex.tex +20 -0
- data/spec/assets/source_code/text.txt +15 -0
- data/spec/assets/source_code/vim +17 -0
- data/spec/assets/source_code/yaml.yml +44 -0
- data/spec/assets/stripper/children/children +0 -0
- data/spec/assets/stripper/children/children.c +0 -0
- data/spec/assets/stripper/children/children.js +0 -0
- data/spec/assets/stripper/children/children.o +0 -0
- data/spec/assets/stripper/children/children.rb +1 -0
- data/spec/assets/stripper/test +0 -0
- data/spec/assets/stripper/test.c +0 -0
- data/spec/assets/stripper/test.js +0 -0
- data/spec/assets/stripper/test.o +0 -0
- data/spec/assets/stripper/test.rb +1 -0
- data/spec/comment_extractor/code_object/comment_spec.rb +15 -0
- data/spec/comment_extractor/code_object_spec.rb +18 -0
- data/spec/comment_extractor/code_objects_spec.rb +66 -0
- data/spec/comment_extractor/configuration_spec.rb +68 -0
- data/spec/comment_extractor/encoding_spec.rb +77 -0
- data/spec/comment_extractor/extractor/c_spec.rb +9 -0
- data/spec/comment_extractor/extractor/cc_spec.rb +9 -0
- data/spec/comment_extractor/extractor/class_spec.rb +9 -0
- data/spec/comment_extractor/extractor/clojure_spec.rb +9 -0
- data/spec/comment_extractor/extractor/coffee_spec.rb +9 -0
- data/spec/comment_extractor/extractor/cpp_spec.rb +9 -0
- data/spec/comment_extractor/extractor/cs_spec.rb +9 -0
- data/spec/comment_extractor/extractor/css_spec.rb +9 -0
- data/spec/comment_extractor/extractor/cxx_spec.rb +9 -0
- data/spec/comment_extractor/extractor/d_spec.rb +10 -0
- data/spec/comment_extractor/extractor/erlang_spec.rb +10 -0
- data/spec/comment_extractor/extractor/fortran_spec.rb +9 -0
- data/spec/comment_extractor/extractor/go_spec.rb +9 -0
- data/spec/comment_extractor/extractor/h_spec.rb +9 -0
- data/spec/comment_extractor/extractor/haml_spec.rb +9 -0
- data/spec/comment_extractor/extractor/haskell_spec.rb +9 -0
- data/spec/comment_extractor/extractor/hpp_spec.rb +9 -0
- data/spec/comment_extractor/extractor/html_spec.rb +9 -0
- data/spec/comment_extractor/extractor/java_script_spec.rb +10 -0
- data/spec/comment_extractor/extractor/java_spec.rb +9 -0
- data/spec/comment_extractor/extractor/lisp_spec.rb +9 -0
- data/spec/comment_extractor/extractor/lua_spec.rb +9 -0
- data/spec/comment_extractor/extractor/m_spec.rb +9 -0
- data/spec/comment_extractor/extractor/markdown_spec.rb +8 -0
- data/spec/comment_extractor/extractor/mm_spec.rb +9 -0
- data/spec/comment_extractor/extractor/perl_spec.rb +9 -0
- data/spec/comment_extractor/extractor/php_spec.rb +9 -0
- data/spec/comment_extractor/extractor/python_spec.rb +9 -0
- data/spec/comment_extractor/extractor/ruby_spec.rb +12 -0
- data/spec/comment_extractor/extractor/sass_spec.rb +9 -0
- data/spec/comment_extractor/extractor/scala_spec.rb +9 -0
- data/spec/comment_extractor/extractor/scss_spec.rb +9 -0
- data/spec/comment_extractor/extractor/shell_spec.rb +9 -0
- data/spec/comment_extractor/extractor/sqf_spec.rb +9 -0
- data/spec/comment_extractor/extractor/sql_spec.rb +9 -0
- data/spec/comment_extractor/extractor/sqs_spec.rb +9 -0
- data/spec/comment_extractor/extractor/tex_spec.rb +9 -0
- data/spec/comment_extractor/extractor/text_spec.rb +7 -0
- data/spec/comment_extractor/extractor/yaml_spec.rb +9 -0
- data/spec/comment_extractor/extractor_manager_spec.rb +233 -0
- data/spec/comment_extractor/extractor_spec.rb +102 -0
- data/spec/comment_extractor/file_spec.rb +100 -0
- data/spec/comment_extractor/parser_spec.rb +67 -0
- data/spec/comment_extractor/smart_string_scanner_spec.rb +24 -0
- data/spec/comment_extractor/version_spec.rb +8 -0
- data/spec/comment_extractor_spec.rb +15 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/rspec/comment_extractor/extractor_example_group.rb +115 -0
- data/spec/support/rspec/comment_extractor/matchers/extract_comment.rb +58 -0
- data/spec/support/rspec/comment_extractor/matchers.rb +7 -0
- data/spec/support/rspec/comment_extractor.rb +6 -0
- metadata +370 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
/*[-1-]@copyright wikipedia http://en.wikibooks.org/wiki/D_Programming/First_Program_Examples [-end-]*/
|
2
|
+
/*[-2-]Hello World in D
|
3
|
+
[-3-]To compile:
|
4
|
+
[-4-]dmd hello.d
|
5
|
+
[-5-]or to optimize:
|
6
|
+
[-6-]dmd -O -inline -release hello.d
|
7
|
+
[-7-]or to get generated documentation:
|
8
|
+
[-8-]dmd hello.d -D
|
9
|
+
*/
|
10
|
+
import std.stdio; //[-10-]References to commonly used I/O routines.
|
11
|
+
void main(char[][] args)
|
12
|
+
{
|
13
|
+
//[-13-]Write-Formatted-Line
|
14
|
+
writefln("Hello World, "
|
15
|
+
"Reloaded");
|
16
|
+
foreach(argc, argv; args)
|
17
|
+
{
|
18
|
+
auto cl = new CmdLin(argc, argv);
|
19
|
+
|
20
|
+
writefln(cl.argnum, cl.suffix, " arg: //%s", cl.argv);
|
21
|
+
delete cl;
|
22
|
+
}
|
23
|
+
struct specs
|
24
|
+
{
|
25
|
+
int count, allocated;
|
26
|
+
}
|
27
|
+
|
28
|
+
specs argspecs(char[][] args)
|
29
|
+
in{
|
30
|
+
assert (args.length > 0);
|
31
|
+
}
|
32
|
+
out(result){
|
33
|
+
assert(result.count == CmdLin.total);
|
34
|
+
assert(result.allocated > 0);
|
35
|
+
}
|
36
|
+
body{
|
37
|
+
specs* s = new specs;
|
38
|
+
s.count = args.length; //[-38-] The 'length' property is number of elements.
|
39
|
+
s.allocated = typeof(args).sizeof;
|
40
|
+
foreach(argv; args)
|
41
|
+
s.allocated += argv.length * typeof(argv[0]).sizeof;
|
42
|
+
return *s;
|
43
|
+
}
|
44
|
+
|
45
|
+
char[] argcmsg = "argc = %d";
|
46
|
+
char[] allocmsg = "allocated = %d";
|
47
|
+
writefln(argcmsg ~ ", " ~ allocmsg,
|
48
|
+
argspecs(args).count,argspecs(args).allocated);
|
49
|
+
}
|
50
|
+
/*[-50-]
|
51
|
+
[-51-]Stores a single command line argument.
|
52
|
+
[-52-][-end-]*/
|
53
|
+
class CmdLin
|
54
|
+
{
|
55
|
+
private {
|
56
|
+
int _argc;
|
57
|
+
char[] _argv;
|
58
|
+
static uint _totalc;
|
59
|
+
}
|
60
|
+
|
61
|
+
public:
|
62
|
+
this(int argc, char[] argv)
|
63
|
+
{
|
64
|
+
_argc = argc + 1;
|
65
|
+
_argv = argv;
|
66
|
+
_totalc++;
|
67
|
+
}
|
68
|
+
|
69
|
+
~this()
|
70
|
+
{
|
71
|
+
}
|
72
|
+
|
73
|
+
int argnum()
|
74
|
+
{
|
75
|
+
return _argc;
|
76
|
+
}
|
77
|
+
char[] argv()
|
78
|
+
{
|
79
|
+
return _argv;
|
80
|
+
}
|
81
|
+
wchar[] suffix()
|
82
|
+
{
|
83
|
+
wchar[] suffix;
|
84
|
+
switch(_argc)
|
85
|
+
{
|
86
|
+
case 1:
|
87
|
+
suffix = "st";
|
88
|
+
break;
|
89
|
+
case 2:
|
90
|
+
suffix = "nd";
|
91
|
+
break;
|
92
|
+
case 3:
|
93
|
+
suffix = "rd";
|
94
|
+
break;
|
95
|
+
default:
|
96
|
+
suffix = "th";
|
97
|
+
}
|
98
|
+
return suffix;
|
99
|
+
}
|
100
|
+
|
101
|
+
static typeof(_totalc) total()
|
102
|
+
{
|
103
|
+
return _totalc;
|
104
|
+
}
|
105
|
+
invariant
|
106
|
+
{
|
107
|
+
assert(_argc > 0);
|
108
|
+
assert(_totalc >= _argc);
|
109
|
+
}
|
110
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
%%[-1-]Attribution-Share Alike 3.0 License, copyright (c) 2010 Pieter Hintjens, modified @alpaca-tc
|
2
|
+
%%[-2-] Reading from multiple sockets
|
3
|
+
%%[-3-] This version uses active sockets
|
4
|
+
%[-4-]
|
5
|
+
|
6
|
+
main(_) ->
|
7
|
+
{ok,Context} = erlzmq:context(),
|
8
|
+
|
9
|
+
%%[-9-] Connect to task ventilator
|
10
|
+
{ok, Receiver} = erlzmq:socket(Context, [pull, {active, true}]),
|
11
|
+
ok = erlzmq:connect(Receiver, "tcp://localhost:5557"),
|
12
|
+
|
13
|
+
%%[-13-] Connect to weather server
|
14
|
+
{ok, Subscriber} = erlzmq:socket(Context, [sub, {active, true}]),
|
15
|
+
ok = erlzmq:connect(Subscriber, "tcp://localhost:5556"),
|
16
|
+
ok = erlzmq:setsockopt(Subscriber, subscribe, <<"10001">>),
|
17
|
+
|
18
|
+
%%[-18-] Process messages from both sockets
|
19
|
+
loop(Receiver, Subscriber),
|
20
|
+
|
21
|
+
%%[-21-] We never get here
|
22
|
+
ok = erlzmq:close(Receiver), %%[-22-] we never get here
|
23
|
+
ok = erlzmq:close(Subscriber),
|
24
|
+
ok = erlzmq:term(Context).
|
25
|
+
|
26
|
+
loop(Tasks, Weather) ->
|
27
|
+
receive
|
28
|
+
{zmq, Tasks, Msg, _Flags} ->
|
29
|
+
io:format("Processing task: ~s~n",[Msg]),
|
30
|
+
loop(Tasks, Weather);
|
31
|
+
{zmq, Weather, Msg, _Flags} ->
|
32
|
+
io:format("Processing weather update: ~s~n",[Msg]),
|
33
|
+
loop(Tasks, Weather)
|
34
|
+
end.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
program average
|
2
|
+
|
3
|
+
![-3-]@copyright wikipedia, modified @alpaca-tc. http://en.wikipedia.org/wiki/Fortran
|
4
|
+
![-4-] Read in some numbers and take the average
|
5
|
+
![-5-] As written, if there are no data points, an average of zero is returned
|
6
|
+
![-6-] While this may not be desired behavior, it keeps this example simple
|
7
|
+
|
8
|
+
implicit none
|
9
|
+
|
10
|
+
real, dimension(:), allocatable :: points
|
11
|
+
integer :: number_of_points
|
12
|
+
real :: average_points=0., positive_average=0., negative_average=0.
|
13
|
+
|
14
|
+
write (*,*) "Input number of points to average:"
|
15
|
+
read (*,*) number_of_points
|
16
|
+
|
17
|
+
allocate (points(number_of_points))
|
18
|
+
|
19
|
+
write (*,*) "Enter the points to average:"
|
20
|
+
read (*,*) points
|
21
|
+
|
22
|
+
![-22-] Take the average by summing points and dividing by number_of_points
|
23
|
+
if (number_of_points > 0) average_points = sum(points) / number_of_points
|
24
|
+
|
25
|
+
![-25-] Now form average over positive and negative points only
|
26
|
+
if (count(points > 0.) > 0) then
|
27
|
+
positive_average = sum(points, points > 0.) / count(points > 0.)
|
28
|
+
end if
|
29
|
+
|
30
|
+
if (count(points < 0.) > 0) then
|
31
|
+
negative_average = sum(points, points < 0.) / count(points < 0.)
|
32
|
+
end if
|
33
|
+
|
34
|
+
deallocate (points) ![-34-] Print result to terminal
|
35
|
+
|
36
|
+
![-36-] Print result to terminal
|
37
|
+
write (*,'(a,g12.4)') 'Average = ', average_points
|
38
|
+
write (*,'(a,g12.4)') 'Average of positive points = ', positive_average
|
39
|
+
write (*,'(a,g12.4)') 'Average of negative points = ', negative_average
|
40
|
+
|
41
|
+
end program average
|
@@ -0,0 +1,61 @@
|
|
1
|
+
//[-1-]Attribution-Share Alike 3.0 License, copyright (c) 2010 Pieter Hintjens, modified @alpaca-tc
|
2
|
+
//[-2-] Task Wroker
|
3
|
+
//[-3-] Connects PULL socket to tcp://localhost:5557
|
4
|
+
//[-4-] Collects workloads from ventilator via that socket
|
5
|
+
//[-5-] Connects PUSH socket to tcp://localhost:5558
|
6
|
+
//[-6-] Connects SUB socket to tcp://localhost:5559
|
7
|
+
//[-7-] Sends results to sink via that socket
|
8
|
+
//[-8-]
|
9
|
+
package main
|
10
|
+
|
11
|
+
import (
|
12
|
+
"fmt"
|
13
|
+
zmq "github.com/alecthomas/gozmq"
|
14
|
+
"strconv"
|
15
|
+
"time"
|
16
|
+
)
|
17
|
+
|
18
|
+
func main() {
|
19
|
+
context, _ := zmq.NewContext()
|
20
|
+
defer context.Close()
|
21
|
+
|
22
|
+
/*[-22-]
|
23
|
+
[-23-] Socket to receive messages on
|
24
|
+
*/
|
25
|
+
receiver.Connect("tcp://localhost:5557")
|
26
|
+
|
27
|
+
//[-27-] Socket to send messages to task sink
|
28
|
+
sender, _ := context.NewSocket(zmq.PUSH)
|
29
|
+
defer sender.Close()
|
30
|
+
sender.Connect("tcp://localhost:5558")
|
31
|
+
|
32
|
+
//[-32-] Socket for control input
|
33
|
+
controller, _ := context.NewSocket(zmq.SUB)
|
34
|
+
defer controller.Close()
|
35
|
+
controller.Connect("tcp://localhost:5559")
|
36
|
+
controller.SetSubscribe("")
|
37
|
+
|
38
|
+
items := zmq.PollItems{
|
39
|
+
zmq.PollItem{Socket: receiver, Events: zmq.POLLIN},
|
40
|
+
zmq.PollItem{Socket: controller, Events: zmq.POLLIN},
|
41
|
+
}
|
42
|
+
|
43
|
+
//[-43-] Process tasks forever
|
44
|
+
for {
|
45
|
+
zmq.Poll(items, -1)
|
46
|
+
switch {
|
47
|
+
case items[0].REvents&zmq.POLLIN != 0: /*[-47-] Process tasks forever [-end-]*/
|
48
|
+
msgbytes, _ := receiver.Recv(0)
|
49
|
+
fmt.Printf("%s.", string(msgbytes))
|
50
|
+
|
51
|
+
//[-51-] Do the work
|
52
|
+
msec, _ := strconv.ParseInt(string(msgbytes), 10, 64)
|
53
|
+
time.Sleep(time.Duration(msec) * 1e6)
|
54
|
+
|
55
|
+
sender.Send([]byte(""), 0) //[-55-] Send results to sink
|
56
|
+
case items[1].REvents&zmq.POLLIN != 0:
|
57
|
+
fmt.Println("stopping")
|
58
|
+
return
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html(lang="en")
|
3
|
+
%head
|
4
|
+
%meta(charset="utf-8")
|
5
|
+
%meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1")
|
6
|
+
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
|
7
|
+
%title= content_for?(:title) ? yield(:title) : "EnfacTv"
|
8
|
+
= csrf_meta_tags
|
9
|
+
/ Le HTML5 shim, for IE6-8 support of HTML elements
|
10
|
+
= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' #[-10-] single line
|
11
|
+
-#[-11-] single line
|
12
|
+
-#[-12-]
|
13
|
+
|
14
|
+
= huga
|
15
|
+
%body
|
16
|
+
#header
|
17
|
+
.inner
|
18
|
+
#header_links.clearfix
|
19
|
+
%ul
|
20
|
+
%li
|
21
|
+
%a{ :href => "" }= '' #[-21-] single line
|
22
|
+
#main_contents
|
23
|
+
#content_area
|
24
|
+
.inner.clearfix
|
25
|
+
= yield
|
26
|
+
-#[-26-]
|
@@ -0,0 +1,36 @@
|
|
1
|
+
--[-1-]Attribution-Share Alike 3.0 License, copyright (c) 2010 Pieter Hintjens, modified @alpaca-tc
|
2
|
+
--[-2-] | Pub/Sub envelope subscriber (p.76)
|
3
|
+
--[-3-] Pub/Sub envelope subscriber (p.76)
|
4
|
+
--[-4-] ^
|
5
|
+
{-[-5-]
|
6
|
+
[-6-]
|
7
|
+
[-7-][-end-]-}
|
8
|
+
{-[-8-]|
|
9
|
+
[-9-][-end-]-}
|
10
|
+
{-[-10-]| [-end-]-}
|
11
|
+
module Main where
|
12
|
+
|
13
|
+
import System.ZMQ4.Monadic
|
14
|
+
import Data.ByteString.Char8 (unpack)
|
15
|
+
import Control.Monad (when)
|
16
|
+
import Text.Printf
|
17
|
+
|
18
|
+
main :: IO ()
|
19
|
+
main =
|
20
|
+
runZMQ $ do
|
21
|
+
subscriber <- socket Sub
|
22
|
+
connect subscriber "tcp://localhost:5563"
|
23
|
+
subscribe subscriber "B"
|
24
|
+
|
25
|
+
loop subscriber --[-25-]start listening for pub messages
|
26
|
+
|
27
|
+
where
|
28
|
+
loop subscriber = do
|
29
|
+
--[-29-] read envelope with address
|
30
|
+
receive subscriber >>= \addr -> liftIO $ printf "Address is %s\n" (unpack addr)
|
31
|
+
--[-31-] read message content
|
32
|
+
more <- moreToReceive subscriber
|
33
|
+
when more $ do
|
34
|
+
contents <- receive subscriber
|
35
|
+
liftIO $ putStrLn (unpack contents)
|
36
|
+
loop subscriber
|
File without changes
|
@@ -0,0 +1,139 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="ja">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<title>RailsとRubyとVimのブログ</title>
|
6
|
+
|
7
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
|
8
|
+
<meta content='RailsとRubyとVimのブログ' name='title' />
|
9
|
+
|
10
|
+
|
11
|
+
<link rel="author" href="https://plus.google.com/105581201951227096827" />
|
12
|
+
<link rel="publisher" href="https://plus.google.com/105581201951227096827" />
|
13
|
+
<!--[-13-][if lte IE 8]>
|
14
|
+
[-14-] multiline comment
|
15
|
+
[-15-]<![endif][-end-]-->
|
16
|
+
|
17
|
+
<meta property="og:title" content='RailsとRubyとVimのブログ' />
|
18
|
+
<meta property="og:locale" content="ja_JP"/>
|
19
|
+
<meta property="og:image" content="http://http://alpaca.tc/images/meta/site_title.png"/>
|
20
|
+
<meta property="og:type" content="blog"/>
|
21
|
+
<meta property="og:url" content="http://alpaca.tc/index.html"/>
|
22
|
+
<meta property="og:site_name" content="RailsとRubyとVimのブログ"/>
|
23
|
+
<meta property="og:description" content="ここまで出来る!RubyのSplat Operatorまとめ Feb 12th, 2014 Posted by 石井浩之 Splat Operatorとは、*のことです この前、友人にコードレビューしてもらっていたら 「え、Rubyってこんな書き方出来るんですか?」と言われて、「 …" />
|
24
|
+
<meta property="fb:app_id" content="224701561024840" />
|
25
|
+
|
26
|
+
<meta name="twitter:card" content="summary">
|
27
|
+
<meta name="twitter:title" content="RailsとRubyとVimのブログ">
|
28
|
+
<meta name="twitter:description" content="ここまで出来る!RubyのSplat Operatorまとめ Feb 12th, 2014 Posted by 石井浩之 Splat Operatorとは、*のことです この前、友人にコードレビューしてもらっていたら 「え、Rubyってこんな書き方出来るんですか?」と言われて、「 …">
|
29
|
+
<meta name="twitter:image" content="http://http://alpaca.tc/images/meta/twitter.png">
|
30
|
+
<meta name="twitter:site" content="@alpaca_taichou">
|
31
|
+
<meta name="twitter:creator" content="@alpaca_taichou">
|
32
|
+
|
33
|
+
|
34
|
+
<script type="text/javascript">window._pt_lt = new Date().getTime();</script>
|
35
|
+
|
36
|
+
<link rel="stylesheet" href="/stylesheets/reset.css" type="text/css" media="all"/>
|
37
|
+
<link rel="stylesheet" href="/stylesheets/compression.css" type="text/css" media="all"/>
|
38
|
+
<meta name="google-site-verification" content="thSL3cUT7BV1-AENglRFIF-kv6I85JJ6_iUGAU8GaQI" />
|
39
|
+
|
40
|
+
<!--[-40-] multiline comment [-end-]-->
|
41
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
42
|
+
|
43
|
+
|
44
|
+
<script>
|
45
|
+
var _gaq = _gaq || [];
|
46
|
+
_gaq.push(['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js']);
|
47
|
+
_gaq.push(['_setAccount', 'UA-44082439-2']);
|
48
|
+
_gaq.push(['_trackPageview']);
|
49
|
+
(function() {
|
50
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
51
|
+
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
|
52
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
53
|
+
})();
|
54
|
+
</script>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<link rel="next" href="/blog/page/2/">
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
<link rel="canonical" href="http://alpaca.tc/index.html">
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</head>
|
71
|
+
<div id="fb-root"></div>
|
72
|
+
|
73
|
+
<body id="default_contents">
|
74
|
+
<div id="header_top" class="outer_envelope clearfix">
|
75
|
+
<header> <div class="inner_wrapper clearfix">
|
76
|
+
<div class="inner clearfix">
|
77
|
+
<div id="logo">
|
78
|
+
|
79
|
+
<h1 id="site_title"><a href="/">RailsとRubyとVimのブログ</a></h1>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<nav id="header_nav">
|
84
|
+
<ul class="clearfix">
|
85
|
+
<li>
|
86
|
+
<a href="/about_me">About Me</a>
|
87
|
+
</li>
|
88
|
+
<li>
|
89
|
+
<a href="/">Blog</a>
|
90
|
+
</li>
|
91
|
+
<li>
|
92
|
+
<a href="/works/">Works</a>
|
93
|
+
</li>
|
94
|
+
<li>
|
95
|
+
<a target="_blank" href="https://github.com/alpaca-tc">GitHub</a>
|
96
|
+
</li>
|
97
|
+
<li>
|
98
|
+
<a target="_blank" href="https://twitter.com/alpaca_taichou">Twitter</a>
|
99
|
+
</li>
|
100
|
+
</ul>
|
101
|
+
</nav>
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
</header>
|
105
|
+
|
106
|
+
<div id="main_contents" class="clearfix">
|
107
|
+
<div class="inner_wrapper">
|
108
|
+
<div class="inner">
|
109
|
+
<div class="left_page inner_wrapper">
|
110
|
+
<div id="page_contents" class="inner">
|
111
|
+
<div id="index_contents" class="blog-index">
|
112
|
+
<!--[-112-]
|
113
|
+
[-113-][-end-]-->
|
114
|
+
<script type="text/javascript" charset="utf-8">
|
115
|
+
(function() {
|
116
|
+
$(function() {
|
117
|
+
var isSmartPhone = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase());
|
118
|
+
if (isSmartPhone) {
|
119
|
+
var $pagination = $('.pagination'),
|
120
|
+
$prev = $pagination.find('.prev'),
|
121
|
+
$next = $pagination.find('.next');
|
122
|
+
$prev.text($prev.data('label'));
|
123
|
+
$next.text($next.data('label'));
|
124
|
+
}
|
125
|
+
});
|
126
|
+
})();
|
127
|
+
</script>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
</body>
|
139
|
+
</html>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
//[-1-]Attribution-Share Alike 3.0 License, copyright (c) 2010 Pieter Hintjens, modified @alpaca-tc
|
2
|
+
import java.util.HashMap;
|
3
|
+
import java.util.Map;
|
4
|
+
import java.util.concurrent.atomic.AtomicLong;
|
5
|
+
|
6
|
+
import org.zeromq.ZContext;
|
7
|
+
import org.zeromq.ZMQ;
|
8
|
+
import org.zeromq.ZMQ.Socket;
|
9
|
+
/*[-9-]
|
10
|
+
[-10-]Clone client model 1
|
11
|
+
[-11-]@author Danish Shrestha <dshrestha06@gmail.com>
|
12
|
+
[-12-]aa
|
13
|
+
[-13-] [-end-]*/
|
14
|
+
public class clonecli1 {
|
15
|
+
private static Map<String, kvsimple> kvMap = new HashMap<String, kvsimple>();
|
16
|
+
private static AtomicLong sequence = new AtomicLong();
|
17
|
+
|
18
|
+
public void run() { //[-18-]
|
19
|
+
ZContext ctx = new ZContext();
|
20
|
+
Socket subscriber = ctx.createSocket(ZMQ.SUB);
|
21
|
+
subscriber.connect("tcp://localhost:5556");
|
22
|
+
subscriber.subscribe("".getBytes());
|
23
|
+
/*[-23-] [-end-]*/
|
24
|
+
while (true) {
|
25
|
+
kvsimple kvMsg = kvsimple.recv(subscriber);
|
26
|
+
if (kvMsg == null)
|
27
|
+
break;
|
28
|
+
|
29
|
+
clonecli1.kvMap.put(kvMsg.getKey(), kvMsg);
|
30
|
+
System.out.println("receiving " + kvMsg);
|
31
|
+
sequence.incrementAndGet();
|
32
|
+
}
|
33
|
+
ctx.destroy();
|
34
|
+
}
|
35
|
+
|
36
|
+
public static void main(String[] args) {
|
37
|
+
new clonecli1().run();
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,164 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
//[-3-] Copyright 2014 jQuery Foundation and other contributors
|
4
|
+
define([
|
5
|
+
"./core",
|
6
|
+
'./var/rnotwhite'
|
7
|
+
], function( jQuery, rnotwhite ) {
|
8
|
+
|
9
|
+
var optionsCache = {};
|
10
|
+
|
11
|
+
function createOptions( options ) {
|
12
|
+
var object = optionsCache[ options ] = {};
|
13
|
+
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
|
14
|
+
object[ flag ] = true;
|
15
|
+
});
|
16
|
+
return object;
|
17
|
+
}
|
18
|
+
/*[-18-] multi line [-end-]*/
|
19
|
+
/*[-19-]
|
20
|
+
[-20-] Create a callback list using the following parameters:
|
21
|
+
[-21-]
|
22
|
+
[-22-] options: an optional list of space-separated options that will change how
|
23
|
+
[-23-] the callback list behaves or a more traditional option object
|
24
|
+
[-24-]
|
25
|
+
*/
|
26
|
+
jQuery.Callbacks = function( options ) {
|
27
|
+
//[-27-] (we check in cache first)
|
28
|
+
options = typeof options === "string" ?
|
29
|
+
( optionsCache[ options ] || createOptions( options ) ) :
|
30
|
+
jQuery.extend( {}, options );
|
31
|
+
|
32
|
+
var //[-32-] Last fire value (for non-forgettable lists)
|
33
|
+
memory,
|
34
|
+
//[-34-] Flag to know if list was already fired
|
35
|
+
fired,
|
36
|
+
//[-36-] Flag to know if list is currently firing
|
37
|
+
firing,
|
38
|
+
firingStart,
|
39
|
+
list = "// dummy",
|
40
|
+
list = "/*dummy",
|
41
|
+
list = [],
|
42
|
+
stack = !options.once && [],
|
43
|
+
fire = function( data ) {
|
44
|
+
memory = options.memory && data;
|
45
|
+
fired = true;
|
46
|
+
firingIndex = firingStart || 0;
|
47
|
+
firingStart = 0;
|
48
|
+
firingLength = list.length;
|
49
|
+
firing = true;
|
50
|
+
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
51
|
+
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
|
52
|
+
memory = false; //[-52-] To prevent further calls using add
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
firing = false;
|
57
|
+
if ( list ) {
|
58
|
+
if ( stack ) {
|
59
|
+
if ( stack.length ) {
|
60
|
+
fire( stack.shift() );
|
61
|
+
}
|
62
|
+
} else if ( memory ) {
|
63
|
+
list = [];
|
64
|
+
} else {
|
65
|
+
self.disable();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
},
|
69
|
+
self = {
|
70
|
+
add: function() {
|
71
|
+
if ( list ) {
|
72
|
+
var start = list.length;
|
73
|
+
(function add( args ) {
|
74
|
+
jQuery.each( args, function( _, arg ) {
|
75
|
+
var type = jQuery.type( arg );
|
76
|
+
if ( type === "function" ) {
|
77
|
+
if ( !options.unique || !self.has( arg ) ) {
|
78
|
+
list.push( arg );
|
79
|
+
}
|
80
|
+
} else if ( arg && arg.length && type !== "string" ) {
|
81
|
+
//[-81-] Inspect recursively
|
82
|
+
add( arg );
|
83
|
+
}
|
84
|
+
});
|
85
|
+
})( arguments );
|
86
|
+
if ( firing ) {
|
87
|
+
firingLength = list.length;
|
88
|
+
} else if ( memory ) {
|
89
|
+
firingStart = start;
|
90
|
+
fire( memory );
|
91
|
+
}
|
92
|
+
}
|
93
|
+
return this;
|
94
|
+
},
|
95
|
+
remove: function() {
|
96
|
+
if ( list ) {
|
97
|
+
jQuery.each( arguments, function( _, arg ) {
|
98
|
+
var index;
|
99
|
+
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
|
100
|
+
list.splice( index, 1 );
|
101
|
+
if ( firing ) {
|
102
|
+
if ( index <= firingLength ) {
|
103
|
+
firingLength--;
|
104
|
+
}
|
105
|
+
if ( index <= firingIndex ) {
|
106
|
+
firingIndex--;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
});
|
111
|
+
}
|
112
|
+
return this;
|
113
|
+
},
|
114
|
+
has: function( fn ) {
|
115
|
+
return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
|
116
|
+
},
|
117
|
+
empty: function() {
|
118
|
+
list = [];
|
119
|
+
firingLength = 0;
|
120
|
+
return this;
|
121
|
+
},
|
122
|
+
disable: function() {
|
123
|
+
list = stack = memory = undefined;
|
124
|
+
return this;
|
125
|
+
},
|
126
|
+
disabled: function() {
|
127
|
+
return !list;
|
128
|
+
},
|
129
|
+
lock: function() {
|
130
|
+
stack = undefined;
|
131
|
+
if ( !memory ) {
|
132
|
+
self.disable();
|
133
|
+
}
|
134
|
+
return this;
|
135
|
+
},
|
136
|
+
locked: function() {
|
137
|
+
return !stack;
|
138
|
+
},
|
139
|
+
fireWith: function( context, args ) {
|
140
|
+
if ( list && ( !fired || stack ) ) {
|
141
|
+
args = args || [];
|
142
|
+
args = [ context, args.slice ? args.slice() : args ];
|
143
|
+
if ( firing ) {
|
144
|
+
stack.push( args );
|
145
|
+
} else {
|
146
|
+
fire( args );
|
147
|
+
}
|
148
|
+
}
|
149
|
+
return this;
|
150
|
+
},
|
151
|
+
fire: function() {
|
152
|
+
self.fireWith( this, arguments );
|
153
|
+
return this;
|
154
|
+
},
|
155
|
+
fired: function() {
|
156
|
+
return !!fired;
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
return self;
|
161
|
+
};
|
162
|
+
|
163
|
+
return jQuery;
|
164
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
;;;;[-1-] COMMENT-EXAMPLE function.
|
2
|
+
;;;[-2-] This function is useless except to demonstrate comments.
|
3
|
+
;;;[-3-] (Actually, this example is much too cluttered with them.)
|
4
|
+
|
5
|
+
(defun comment-example (x y) ;[-5-]X is anything; Y is an a-list.
|
6
|
+
(cond ((listp x) x) ;[-6-]If X is a list, use that.
|
7
|
+
;;[-7-] X is now not a list. There are two other cases.
|
8
|
+
((symbolp x)
|
9
|
+
;;[-9-] Look up a symbol in the a-list.
|
10
|
+
(cdr (assoc x y))) ;[-10-]Remember, (cdr nil) is nil.
|
11
|
+
;;[-11-] Do this when all else fails:
|
12
|
+
(t (cons x ;[-12-]Add x to a default list.
|
13
|
+
'((lisp t) ;[-13-]LISP is okay.
|
14
|
+
(fortran nil) ;[-14-]FORTRAN is not.
|
15
|
+
(pl/i -500) ;[-15-]Note that you can put comments in
|
16
|
+
(ada .001) ;[-16-] "data" as well as in "programs".
|
17
|
+
;;[-17-] COBOL??
|
18
|
+
(teco -1.0e9))))))
|