casey_jones 0.0.100 → 0.0.101
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ajax_loading/application_helpers.rb +10 -0
- data/lib/casey_jones/string_reader.rb +96 -93
- metadata +3 -3
@@ -1,5 +1,15 @@
|
|
1
1
|
module AjaxLoading
|
2
2
|
module ApplicationHelpers
|
3
|
+
def ajax_box_id(object, association)
|
4
|
+
object.element_id(:show, association)
|
5
|
+
end
|
6
|
+
def render_js(options={})
|
7
|
+
"'"+escape_javascript(render(options))+"'"
|
8
|
+
end
|
9
|
+
def growl(title, msg, type=:info)
|
10
|
+
"$.growl('#{title}', '#{msg}', 'images/growl/#{type}.png');"
|
11
|
+
end
|
12
|
+
|
3
13
|
def loadbehind_link(name, object, association, options={})
|
4
14
|
# This should go to the controller for the association class!
|
5
15
|
ass_info = object.class.reflect_on_association(association)
|
@@ -1,113 +1,116 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@comment = nil
|
19
|
-
@items = []
|
20
|
-
|
21
|
-
def save(block)
|
22
|
-
unless @item.strip.empty?
|
23
|
-
@items << block.call(@item.strip, @comment.nil? ? nil : @comment.strip)
|
24
|
-
end
|
1
|
+
module CaseyJones
|
2
|
+
module ActiveRecord
|
3
|
+
class StringReader
|
4
|
+
KEY_SYMPTOM = "*"
|
5
|
+
POSS_SYMPTOM = "-"
|
6
|
+
START_COMMENT = "{"
|
7
|
+
ONE_LINE_COMMENT = "/"
|
8
|
+
END_COMMENT = "}"
|
9
|
+
NEWLINE = "\n"
|
10
|
+
|
11
|
+
DELIM = [START_COMMENT, NEWLINE, ONE_LINE_COMMENT, END_COMMENT]
|
12
|
+
|
13
|
+
MULTI_LINE = :multi_line
|
14
|
+
ONE_LINE = :one_line
|
15
|
+
NAME = :name
|
16
|
+
COMMENT = [MULTI_LINE, ONE_LINE]
|
17
|
+
|
25
18
|
@item = ""
|
26
19
|
@comment = nil
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
item, comment = block.call(obj)
|
33
|
-
if comment.nil? || comment.empty?
|
34
|
-
lines << item
|
35
|
-
elsif comment.index("/") || comment.index("\n")
|
36
|
-
lines << "#{item} {#{comment}}"
|
37
|
-
else
|
38
|
-
lines << "#{item} / #{comment}"
|
20
|
+
@items = []
|
21
|
+
|
22
|
+
def save(block)
|
23
|
+
unless @item.strip.empty?
|
24
|
+
@items << block.call(@item.strip, @comment.nil? ? nil : @comment.strip)
|
39
25
|
end
|
26
|
+
@item = ""
|
27
|
+
@comment = nil
|
40
28
|
end
|
41
|
-
lines.join("\n")
|
42
|
-
end
|
43
|
-
|
44
|
-
def read_items(str, &block)
|
45
|
-
@items = []
|
46
|
-
buffer = ""
|
47
|
-
@item = ""
|
48
|
-
@comment = nil
|
49
|
-
state = NAME
|
50
29
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
30
|
+
def write_items(coll, &block)
|
31
|
+
lines = []
|
32
|
+
coll.each do |obj|
|
33
|
+
item, comment = block.call(obj)
|
34
|
+
if comment.nil? || comment.empty?
|
35
|
+
lines << item
|
36
|
+
elsif comment.index("/") || comment.index("\n")
|
37
|
+
lines << "#{item} {#{comment}}"
|
38
|
+
else
|
39
|
+
lines << "#{item} / #{comment}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
lines.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def read_items(str, &block)
|
46
|
+
@items = []
|
47
|
+
buffer = ""
|
48
|
+
@item = ""
|
49
|
+
@comment = nil
|
50
|
+
state = NAME
|
51
|
+
|
52
|
+
str.chars.each do |char|
|
53
|
+
if (char == "/") && (state != MULTI_LINE)
|
67
54
|
@item = buffer.strip
|
68
55
|
buffer = ""
|
69
|
-
|
70
|
-
elsif
|
71
|
-
@
|
72
|
-
|
56
|
+
state = ONE_LINE
|
57
|
+
elsif char == "{"
|
58
|
+
@item = buffer.strip
|
59
|
+
buffer = ""
|
60
|
+
state = MULTI_LINE
|
61
|
+
elsif char == "}"
|
62
|
+
@comment = buffer.strip unless buffer.strip.empty?
|
73
63
|
buffer = ""
|
74
64
|
save(block)
|
65
|
+
state = NAME
|
66
|
+
elsif char == "\n"
|
67
|
+
if state == NAME
|
68
|
+
@item = buffer.strip
|
69
|
+
buffer = ""
|
70
|
+
save(block)
|
71
|
+
elsif state == ONE_LINE
|
72
|
+
@comment = buffer.strip
|
73
|
+
state = NAME
|
74
|
+
buffer = ""
|
75
|
+
save(block)
|
76
|
+
else
|
77
|
+
buffer << char
|
78
|
+
end
|
75
79
|
else
|
76
80
|
buffer << char
|
77
81
|
end
|
82
|
+
end
|
83
|
+
|
84
|
+
if state == ONE_LINE
|
85
|
+
@comment = buffer
|
86
|
+
elsif state == MULTI_LINE
|
87
|
+
@comment = buffer
|
78
88
|
else
|
79
|
-
|
89
|
+
@item = buffer
|
80
90
|
end
|
91
|
+
save(block)
|
92
|
+
@items
|
81
93
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
94
|
+
|
95
|
+
def self.parse_symptom(obj, symptom)
|
96
|
+
if symptom.index(KEY_SYMPTOM) == 0
|
97
|
+
obj.key_symptom = true
|
98
|
+
obj.symptom_name = symptom[KEY_SYMPTOM.length..symptom.length]
|
99
|
+
elsif symptom.index(POSS_SYMPTOM) == 0
|
100
|
+
obj.maybe = true
|
101
|
+
obj.symptom_name = symptom[POSS_SYMPTOM.length..symptom.length]
|
102
|
+
else
|
103
|
+
obj.symptom_name = symptom
|
104
|
+
end
|
89
105
|
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
obj.key_symptom = true
|
97
|
-
obj.symptom_name = symptom[KEY_SYMPTOM.length..symptom.length]
|
98
|
-
elsif symptom.index(POSS_SYMPTOM) == 0
|
99
|
-
obj.maybe = true
|
100
|
-
obj.symptom_name = symptom[POSS_SYMPTOM.length..symptom.length]
|
101
|
-
else
|
102
|
-
obj.symptom_name = symptom
|
106
|
+
|
107
|
+
def self.decorate_symptom(obj)
|
108
|
+
decorator = ""
|
109
|
+
decorator = KEY_SYMPTOM if obj.key_symptom
|
110
|
+
decorator = POSS_SYMPTOM if obj.maybe
|
111
|
+
"#{decorator}#{obj.symptom_name}"
|
103
112
|
end
|
104
113
|
end
|
105
|
-
|
106
|
-
def self.decorate_symptom(obj)
|
107
|
-
decorator = ""
|
108
|
-
decorator = KEY_SYMPTOM if obj.key_symptom
|
109
|
-
decorator = POSS_SYMPTOM if obj.maybe
|
110
|
-
"#{decorator}#{obj.symptom_name}"
|
111
|
-
end
|
112
114
|
end
|
113
115
|
end
|
116
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casey_jones
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 213
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 101
|
10
|
+
version: 0.0.101
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tyler Gannon
|