mark_set_go 0.0.1
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/bin/mark_set_go +11 -0
- data/lib/mark_set_go/code.rb +15 -0
- data/lib/mark_set_go/comment.rb +30 -0
- data/lib/mark_set_go/document.rb +76 -0
- data/lib/mark_set_go.rb +3 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e092ca3a31736b02f3fdec9546151baeb117363e
|
4
|
+
data.tar.gz: 281ec832ed073c54b94143381195d22ac305cb52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d53cc0d7400235f591ca4bbcbd67505f0e73cdc3a31507c9fba2ef61ec33a85c3d7b338e20330de8f3ad457cfa8d76c01bc297b4f7e97bf63bebaea247598830
|
7
|
+
data.tar.gz: 490b68f88a139207d666e08e7e1ce6805e926a664c7eca3ece176427688285adb8ed40d23db8da0fa35acb935c5af521cd28407343b3fd0bcb96fee60102c2cb
|
data/bin/mark_set_go
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Comment
|
2
|
+
attr_accessor :lines, :type
|
3
|
+
|
4
|
+
def initialize(init_line)
|
5
|
+
@lines = [init_line]
|
6
|
+
set_type
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_type
|
10
|
+
if @lines.first.start_with? "/*"
|
11
|
+
@type = "block"
|
12
|
+
else
|
13
|
+
@type = "line"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def remove_comment(line)
|
18
|
+
if /^\/\//.match(line)
|
19
|
+
line.gsub(/^\/\//, '')
|
20
|
+
elsif /^\/\*/.match(line)
|
21
|
+
line.gsub(/^\/\*/, '')
|
22
|
+
else
|
23
|
+
line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
@lines.map { |line| remove_comment(line) }.join("")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class Document
|
2
|
+
attr_accessor :sections, :lines
|
3
|
+
|
4
|
+
def initialize(lines)
|
5
|
+
@sections = []
|
6
|
+
@lines = lines
|
7
|
+
|
8
|
+
@current_section = nil
|
9
|
+
@lines.each do |line|
|
10
|
+
if @current_section.nil?
|
11
|
+
if line.strip == "" # skip initial whitespace
|
12
|
+
next
|
13
|
+
elsif comment_check(line)
|
14
|
+
@current_section = Comment.new(line)
|
15
|
+
else
|
16
|
+
@current_section = Code.new(line)
|
17
|
+
end
|
18
|
+
|
19
|
+
elsif @current_section.class == Code
|
20
|
+
if comment_check(line)
|
21
|
+
push_current_section
|
22
|
+
@current_section = Comment.new(line)
|
23
|
+
else
|
24
|
+
@current_section.lines << line
|
25
|
+
end
|
26
|
+
|
27
|
+
elsif @current_section.class == Comment
|
28
|
+
if @current_section.type == "block"
|
29
|
+
if check_block_end(line)
|
30
|
+
push_current_section
|
31
|
+
else
|
32
|
+
@current_section.lines << line
|
33
|
+
end
|
34
|
+
elsif @current_section.type == "line"
|
35
|
+
if check_block_start(line)
|
36
|
+
push_current_section
|
37
|
+
@current_section = Comment.new(line)
|
38
|
+
else
|
39
|
+
if comment_check(line)
|
40
|
+
@current_section.lines << line
|
41
|
+
elsif line.strip == ""
|
42
|
+
@current_section.lines << line
|
43
|
+
else
|
44
|
+
push_current_section
|
45
|
+
@current_section = Code.new(line)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if !@current_section.nil?
|
52
|
+
push_current_section
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def comment_check(line)
|
57
|
+
["/*", "//"].map { |str| line.strip.start_with? str }.include? true
|
58
|
+
end
|
59
|
+
|
60
|
+
def check_block_start(line)
|
61
|
+
line.strip.start_with? "/*"
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_block_end(line)
|
65
|
+
line.strip.end_with? "*/"
|
66
|
+
end
|
67
|
+
|
68
|
+
def push_current_section
|
69
|
+
@sections << @current_section.dup
|
70
|
+
@current_section = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_s
|
74
|
+
@sections.map(&:to_s).join("\n").strip
|
75
|
+
end
|
76
|
+
end
|
data/lib/mark_set_go.rb
ADDED
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mark_set_go
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alice Pote
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Literate programming in Golang
|
14
|
+
email: alice.writes.wrongs@gmail.com
|
15
|
+
executables:
|
16
|
+
- mark_set_go
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/mark_set_go
|
21
|
+
- lib/mark_set_go.rb
|
22
|
+
- lib/mark_set_go/code.rb
|
23
|
+
- lib/mark_set_go/comment.rb
|
24
|
+
- lib/mark_set_go/document.rb
|
25
|
+
homepage: https://github.com/aliceriot/mark_set_go
|
26
|
+
licenses:
|
27
|
+
- GPL-3.0
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.5.1
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Mark, Set, Go!
|
49
|
+
test_files: []
|