podgraph 0.0.5 → 0.1.5
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.
- data/NEWS +7 -0
- data/README.rdoc +8 -4
- data/Rakefile +3 -1
- data/TODO +0 -3
- data/bin/podgraph +20 -5
- data/lib/podgraph/meta.rb +1 -1
- data/test/test_mime.rb +3 -3
- metadata +3 -3
data/NEWS
CHANGED
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ posterous.com.
|
|
5
5
|
|
6
6
|
= Synopsis
|
7
7
|
|
8
|
-
podgraph [
|
8
|
+
podgraph [options] [file.html]
|
9
9
|
|
10
10
|
= Description
|
11
11
|
|
@@ -15,9 +15,11 @@ local MTA.
|
|
15
15
|
|
16
16
|
The options are as follows:
|
17
17
|
|
18
|
-
-v
|
19
|
-
-S
|
20
|
-
-m ARG
|
18
|
+
-v Be more verbose.
|
19
|
+
-S Don't send, just dump the mail to stdout.
|
20
|
+
-m ARG 1 of modes: related, mixed.
|
21
|
+
--from EMAIL 'From' address
|
22
|
+
--to EMAIL 'To' address
|
21
23
|
|
22
24
|
The file is supposed to be a XHTML generated by python's docutils from
|
23
25
|
reStructuredText. The idea is:
|
@@ -54,6 +56,8 @@ example:
|
|
54
56
|
:to: post@posterous.com
|
55
57
|
:from: me@example.org
|
56
58
|
|
59
|
+
('--to' & '--from' command line options override values in config.yaml.)
|
60
|
+
|
57
61
|
Start writing a .rest file:
|
58
62
|
|
59
63
|
% emacsclient 0001.rest &
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*-ruby-*-
|
2
|
+
|
1
3
|
require 'rake'
|
2
4
|
require 'rake/gempackagetask'
|
3
5
|
require 'rake/clean'
|
@@ -23,7 +25,7 @@ spec = Gem::Specification.new do |s|
|
|
23
25
|
s.test_files = FileList['test/test_*.rb']
|
24
26
|
s.rdoc_options << '-m' << 'Podgraph'
|
25
27
|
|
26
|
-
s.add_dependency('mail', '~> 2.
|
28
|
+
s.add_dependency('mail', '~> 2.3.0')
|
27
29
|
s.add_development_dependency('git', '>= 1.2.5')
|
28
30
|
end
|
29
31
|
|
data/TODO
CHANGED
data/bin/podgraph
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require_relative '../lib/podgraph/posterous'
|
@@ -15,23 +15,36 @@ $conf[:from] = nil
|
|
15
15
|
$conf[:banner] = "#{File.basename($0)} [options] [file.html]\nType 'ri #{Podgraph::Meta::NAME.capitalize}' for the help."
|
16
16
|
$conf[:input] = nil
|
17
17
|
|
18
|
-
def mailconfig_load
|
18
|
+
def mailconfig_load
|
19
19
|
begin
|
20
20
|
myconf = YAML.load_file($conf[:mailconfig])
|
21
21
|
rescue
|
22
22
|
abort("cannot parse #{$conf[:mailconfig]} in the current directory")
|
23
23
|
end
|
24
24
|
%w(to from).each { |i|
|
25
|
-
|
25
|
+
if ! $conf[i.to_sym]
|
26
|
+
Trestle.errx(1, "missing #{i} in #{$conf[:mailconfig]}") if ! myconf.key?(i.to_sym)
|
27
|
+
$conf[i.to_sym] = myconf[i.to_sym]
|
28
|
+
end
|
26
29
|
}
|
27
|
-
$conf.merge!(myconf)
|
28
30
|
end
|
29
31
|
|
32
|
+
def mail_addr_valid?(t)
|
33
|
+
return false if t =~ /^\s*$/ # why Mail::Address doesn't handle this?
|
34
|
+
begin
|
35
|
+
Mail::Address.new t
|
36
|
+
rescue
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
return true
|
40
|
+
end
|
30
41
|
|
31
42
|
# ---
|
32
43
|
|
33
44
|
u.config_parse(['foobar']) {|src|
|
34
45
|
o = u.cl_parse(src) # create an OptionParser object
|
46
|
+
o.on('--from EMAIL', "'From' address") { |v| $conf[:from] = v if mail_addr_valid?(v) }
|
47
|
+
o.on('--to EMAIL', "'To' address") { |v| $conf[:to] = v if mail_addr_valid?(v) }
|
35
48
|
o.on('-c ARG', "Use another configuration file instead of",
|
36
49
|
$conf[:mailconfig]) { |v| $conf[:mailconfig] = v }
|
37
50
|
o.on('-S', "Don't send, just dump the mail to stdout") { |v| $conf[:send?] = false }
|
@@ -39,8 +52,10 @@ u.config_parse(['foobar']) {|src|
|
|
39
52
|
u.cl_parse(src, o) # run cl parser
|
40
53
|
}
|
41
54
|
|
55
|
+
#pp $conf
|
56
|
+
|
42
57
|
ARGV.size < 1 ? $conf[:input] = STDIN : $conf[:input] = ARGV[0]
|
43
|
-
mailconfig_load
|
58
|
+
mailconfig_load if (!$conf[:from] || !$conf[:to])
|
44
59
|
|
45
60
|
begin
|
46
61
|
p = Podgraph::Posterous.new(u, $conf[:input], $conf[:to], $conf[:from], $conf[:mode])
|
data/lib/podgraph/meta.rb
CHANGED
data/test/test_mime.rb
CHANGED
@@ -69,7 +69,7 @@ class TestMime < MiniTest::Unit::TestCase
|
|
69
69
|
|
70
70
|
# NOTE: run
|
71
71
|
#
|
72
|
-
# ../bin/podgraph -S simple.html | grep -v -e ^To: -e '^Date:' -e ^Message-ID: -e '^user-agent:'|md5
|
72
|
+
# ../bin/podgraph -S simple.html | grep -i -v -e ^To: -e '^Date:' -e ^Message-ID: -e '^user-agent:'|md5
|
73
73
|
#
|
74
74
|
# to get a new hash for this test.
|
75
75
|
def test_simple
|
@@ -78,10 +78,10 @@ class TestMime < MiniTest::Unit::TestCase
|
|
78
78
|
mail.sub!(/^Date: .+$\n/, '')
|
79
79
|
mail.sub!(/^To: .+$\n/, '')
|
80
80
|
mail.sub!(/^Message-ID: .+$\n/, '')
|
81
|
-
mail.sub!(/^
|
81
|
+
mail.sub!(/^User-Agent: .+$\n/, '')
|
82
82
|
# p mail
|
83
83
|
# puts mail
|
84
|
-
assert_equal('
|
84
|
+
assert_equal('54c07d54f21efd28cc4634bd6b61efaf',
|
85
85
|
Digest::MD5.hexdigest(mail + "\n"))
|
86
86
|
end
|
87
87
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: podgraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.1.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alexander Gromnitsky
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-28 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mail
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.
|
23
|
+
version: 2.3.0
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|