liveblog 0.3.1 → 0.4.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/liveblog.rb +42 -35
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5afbb5af5239ae78124596c00158a5c81d6dcb43
|
4
|
+
data.tar.gz: 66f86ba416a0d0e669b98fba87bc56a8a871f591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a687a57d24753358e984c68436fe812e3b17a04e054af90e6724756ca430b18d9078c49ca71cec0caf280d614917dcf12c3df2f392cd84d2a3c3aa1d218a0ba9
|
7
|
+
data.tar.gz: 0e26b0551567985dfa1dd1f5c05b042aa0f314a2cb4e9ffb18e019758bbf4ce3773e585a4a033f5fa245ccd4882d8ea14bbbfb70ea7aa539db0b1b6abbc99b2d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/liveblog.rb
CHANGED
@@ -20,12 +20,48 @@ class LiveBlog
|
|
20
20
|
File.exists?(dxfile) ? @dx = Dynarex.new(dxfile) : new_file()
|
21
21
|
|
22
22
|
end
|
23
|
+
|
24
|
+
def add_entry(raw_entry)
|
25
|
+
|
26
|
+
hashtag = raw_entry[/#\w+$/]
|
27
|
+
|
28
|
+
success, msg = case raw_entry
|
29
|
+
when /^#\s*\w.*#\w+$/ then add_section raw_entry
|
30
|
+
when /#\w+$/ then add_section_entry raw_entry, hashtag
|
31
|
+
else [false, 'no valid entry found']
|
32
|
+
end
|
33
|
+
|
34
|
+
return [false, msg] unless success
|
35
|
+
|
36
|
+
save()
|
37
|
+
[true, "%s %s/%s/index.html%s" % [raw_entry, @urlbase, path(), hashtag]]
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
private
|
23
42
|
|
43
|
+
|
44
|
+
def add_section_entry(raw_entry, hashtag)
|
45
|
+
|
46
|
+
rec = @dx.all.find {|section| section.x.lstrip.lines.first =~ /#{hashtag}/}
|
47
|
+
|
48
|
+
return [false, 'rec not found'] unless rec
|
49
|
+
|
50
|
+
rec.x += "\n\n" + raw_entry.rstrip
|
51
|
+
[true, 'entry added to section ' + hashtag]
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_section(raw_entry)
|
55
|
+
|
56
|
+
@dx.create({x: raw_entry})
|
57
|
+
[true, 'section added']
|
58
|
+
end
|
59
|
+
|
24
60
|
def new_file
|
25
61
|
|
26
62
|
s =<<EOF
|
27
63
|
<?dynarex schema="sections[title]/section(x)"?>
|
28
|
-
title: LiveBlog #{ordinalize(@t.day) + @t.strftime(" %B %Y")}
|
64
|
+
title: LiveBlog #{ordinalize(@t.day) + @t.strftime(" %B %Y")}
|
29
65
|
--#
|
30
66
|
|
31
67
|
EOF
|
@@ -40,47 +76,18 @@ EOF
|
|
40
76
|
|
41
77
|
end
|
42
78
|
|
43
|
-
def
|
44
|
-
|
45
|
-
entry = String.new(raw_entry)
|
46
|
-
a = @dx.all
|
47
|
-
rec = a.find {|section| section.x.lstrip.lines.first =~ /#\s*#{hashtag}/}
|
48
|
-
|
49
|
-
if rec then
|
50
|
-
|
51
|
-
hashtag = entry.slice!(/#\w+$/)
|
52
|
-
rec.x += "\n" + entry.rstrip
|
53
|
-
save()
|
54
|
-
|
55
|
-
[true, "%s %s/%s/index.html%s" % [entry, @urlbase, path(), hashtag]]
|
56
|
-
else
|
57
|
-
[false, 'rec not found']
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def add_section(entry)
|
79
|
+
def path
|
62
80
|
|
63
|
-
|
64
|
-
|
65
|
-
save()
|
66
|
-
|
67
|
-
[true, "%s %s/%s/index.html%s" % [entry, @urlbase, path(), hashtag]]
|
81
|
+
File.join [@t.year.to_s, Date::MONTHNAMES[@t.month].downcase[0..2], \
|
82
|
+
@t.day.to_s]
|
68
83
|
end
|
69
|
-
|
84
|
+
|
70
85
|
def save()
|
71
86
|
|
72
87
|
@dx.save File.join(path(), 'index.xml')
|
73
88
|
File.write File.join(path(), 'index.txt'), @dx.to_s
|
74
89
|
save_html()
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def path
|
80
|
-
|
81
|
-
File.join [@t.year.to_s, Date::MONTHNAMES[@t.month].downcase[0..2], \
|
82
|
-
@t.day.to_s]
|
83
|
-
end
|
90
|
+
end
|
84
91
|
|
85
92
|
def save_html()
|
86
93
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liveblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
WoOSxvsTN7qoA8F0W4mkDpf+HhHxBOLTPykcHMIlx2gILLnNraaZ1rJlZAqWABGj
|
32
32
|
v8lGgeeqqjd5QA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-03-
|
34
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|