ruml 0.0.2 → 0.1.0
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/.gitignore +1 -0
- data/.travis.yml +6 -0
- data/README.md +1 -1
- data/Rakefile +37 -4
- data/lib/ruml.rb +4 -0
- data/lib/ruml/broadcaster.rb +1 -1
- data/lib/ruml/config.rb +64 -0
- data/lib/ruml/list.rb +16 -13
- data/lib/ruml/version.rb +1 -1
- data/ruml.gemspec +3 -1
- data/test/fixtures/example_ml.yml +8 -0
- data/test/helper.rb +15 -1
- data/test/integration_test.rb +9 -6
- metadata +60 -62
- data/Gemfile.lock +0 -27
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -5,8 +5,41 @@ require 'rake/testtask'
|
|
5
5
|
desc 'Default: run unit tests.'
|
6
6
|
task :default => :test
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
test
|
8
|
+
AVAILABLE_TEST_FIXTURES = %w[file yaml]
|
9
|
+
|
10
|
+
AVAILABLE_TEST_FIXTURES.each do |test_fixture|
|
11
|
+
namespace :test do
|
12
|
+
Rake::TestTask.new(test_fixture) do |test|
|
13
|
+
ENV['TEST_FIXTURE'] = test_fixture
|
14
|
+
test.test_files = FileList.new('test/*_test.rb')
|
15
|
+
test.libs << 'test'
|
16
|
+
test.verbose = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Run tests for #{AVAILABLE_TEST_FIXTURES.join(', ')}"
|
22
|
+
task :test => AVAILABLE_TEST_FIXTURES.map { |f| "test:#{f}" }
|
23
|
+
|
24
|
+
SUPPORTED_RUBIES = %w[ree 1.9.2 1.9.3 jruby rbx]
|
25
|
+
GEMSPEC = Bundler::GemHelper.new(Dir.pwd).gemspec
|
26
|
+
|
27
|
+
def with_ruby(ruby, command)
|
28
|
+
rvm = "#{ruby}@#{GEMSPEC.name}"
|
29
|
+
command = %{rvm #{rvm} exec bash -c '#{command}'}
|
30
|
+
|
31
|
+
puts "\n" * 3
|
32
|
+
puts "CMD: #{command}"
|
33
|
+
puts "=" * 40
|
34
|
+
|
35
|
+
system(command) or raise "command failed: #{command}"
|
36
|
+
end
|
37
|
+
|
38
|
+
namespace :rubies do
|
39
|
+
desc "Run tests for following supported platforms #{SUPPORTED_RUBIES.join ", "}"
|
40
|
+
task :test do
|
41
|
+
command = "bundle check || bundle install && bundle exec rake"
|
42
|
+
rubies = ENV['RUBIES'] ? ENV['RUBIES'].split(",") : SUPPORTED_RUBIES
|
43
|
+
rubies.each { |ruby| with_ruby(ruby, command) }
|
44
|
+
end
|
12
45
|
end
|
data/lib/ruml.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'mail'
|
2
|
+
require 'moneta'
|
3
|
+
require 'moneta/adapters/basic_file'
|
4
|
+
require 'moneta/adapters/yaml'
|
2
5
|
|
3
6
|
module Ruml
|
4
7
|
autoload :List, 'ruml/list'
|
8
|
+
autoload :Config, 'ruml/config'
|
5
9
|
autoload :Broadcaster, 'ruml/broadcaster'
|
6
10
|
autoload :VERSION, 'ruml/version'
|
7
11
|
|
data/lib/ruml/broadcaster.rb
CHANGED
data/lib/ruml/config.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
module Ruml
|
2
|
+
class Config
|
3
|
+
attr_reader :path
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
@path = path.to_s
|
7
|
+
|
8
|
+
case @path
|
9
|
+
when /\.ya?ml/
|
10
|
+
construct PlainYAML, :path => @path
|
11
|
+
else
|
12
|
+
raise ArgumentError, "Couldn't find mailing list in #{@path.inspect}" unless File.directory?(@path)
|
13
|
+
construct Moneta::Adapters::BasicFile, :path => @path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def [](name)
|
18
|
+
@moneta[name]
|
19
|
+
end
|
20
|
+
|
21
|
+
def []=(name, value)
|
22
|
+
@moneta[name] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def construct(adapater, *args)
|
26
|
+
@moneta = Builder.new(adapater.new(*args))
|
27
|
+
end
|
28
|
+
|
29
|
+
class Builder
|
30
|
+
include Moneta::Middleware
|
31
|
+
|
32
|
+
def initialize(adapater)
|
33
|
+
adapater.extend NoSerialization
|
34
|
+
build(adapater)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
class PlainYAML < ::Moneta::Adapters::YAML
|
41
|
+
def [](key)
|
42
|
+
string_key = key_for(key)
|
43
|
+
yaml[string_key] if yaml.key?(string_key)
|
44
|
+
end
|
45
|
+
|
46
|
+
def store(key, value, *)
|
47
|
+
hash = yaml
|
48
|
+
hash[key_for(key)] = value
|
49
|
+
save(hash)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
module NoSerialization
|
54
|
+
def serialize(value)
|
55
|
+
value
|
56
|
+
end
|
57
|
+
|
58
|
+
def deserialize(value)
|
59
|
+
value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
data/lib/ruml/list.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module Ruml
|
2
2
|
class List
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :config
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
5
|
+
def initialize(path)
|
6
|
+
@config = Config.new(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def path
|
10
|
+
config.path
|
8
11
|
end
|
9
12
|
|
10
13
|
def id
|
@@ -12,19 +15,19 @@ module Ruml
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def name
|
15
|
-
@name ||=
|
18
|
+
@name ||= lines("name").first
|
16
19
|
end
|
17
20
|
|
18
21
|
def members
|
19
|
-
@members ||=
|
22
|
+
@members ||= lines("members").map(&:downcase).uniq.reject { |member| member =~ /^#|^$/ }
|
20
23
|
end
|
21
24
|
|
22
25
|
def to
|
23
|
-
@to ||=
|
26
|
+
@to ||= lines("to").first
|
24
27
|
end
|
25
28
|
|
26
29
|
def bounce_to
|
27
|
-
@bounce_to ||=
|
30
|
+
@bounce_to ||= lines("bounce_to").first || to
|
28
31
|
end
|
29
32
|
|
30
33
|
def broadcaster(body)
|
@@ -40,11 +43,11 @@ module Ruml
|
|
40
43
|
|
41
44
|
private
|
42
45
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
[]
|
46
|
+
def lines(name)
|
47
|
+
value = config[name]
|
48
|
+
value = value.split("\n").map(&:strip) if value.respond_to?(:split)
|
49
|
+
value
|
48
50
|
end
|
51
|
+
|
49
52
|
end
|
50
53
|
end
|
data/lib/ruml/version.rb
CHANGED
data/ruml.gemspec
CHANGED
@@ -16,7 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
+
s.add_development_dependency "rake", "~> 0.9.2"
|
19
20
|
s.add_development_dependency "minitest"
|
20
21
|
|
21
|
-
s.add_runtime_dependency "mail",
|
22
|
+
s.add_runtime_dependency "mail", "~> 2.3.0"
|
23
|
+
s.add_runtime_dependency "moneta-splattael", "~> 0.7.0"
|
22
24
|
end
|
data/test/helper.rb
CHANGED
@@ -10,6 +10,13 @@ Mail.defaults do
|
|
10
10
|
delivery_method :test
|
11
11
|
end
|
12
12
|
|
13
|
+
if fixture = ENV['TEST_FIXTURE']
|
14
|
+
TEST_FIXTURE = ENV['TEST_FIXTURE']
|
15
|
+
puts "Using TEST_FIXTURE=#{TEST_FIXTURE}"
|
16
|
+
else
|
17
|
+
abort "Please run: TEST_FIXTURE=file rake"
|
18
|
+
end
|
19
|
+
|
13
20
|
module RumlTestSupport
|
14
21
|
def exec_ruml(arg, input)
|
15
22
|
# TODO execute "bin/ruml" directly
|
@@ -31,7 +38,14 @@ module RumlTestSupport
|
|
31
38
|
end
|
32
39
|
|
33
40
|
def example_ml_path
|
34
|
-
|
41
|
+
case TEST_FIXTURE
|
42
|
+
when "file"
|
43
|
+
fixture_path "example_ml"
|
44
|
+
when "yaml", "yml"
|
45
|
+
fixture_path "example_ml.yml"
|
46
|
+
else
|
47
|
+
abort "Unknown TEST_FIXTURE #{TEST_FIXTURE.inspect}"
|
48
|
+
end
|
35
49
|
end
|
36
50
|
end
|
37
51
|
|
data/test/integration_test.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
describe "Ruml binary" do
|
4
|
-
it "fails with
|
4
|
+
it "fails with ArgumentError using empty list path" do
|
5
5
|
output = exec_ruml nil, nil
|
6
|
-
output.must_match "
|
6
|
+
output.must_match "Couldn't find mailing list in \"\""
|
7
|
+
output.must_match "ArgumentError"
|
7
8
|
end
|
8
9
|
|
9
10
|
it "fails with ArgumentError using invalid list path" do
|
10
11
|
output = exec_ruml "invalid path", nil
|
11
|
-
output.must_match "Couldn't find mailing list in \"invalid path\"
|
12
|
+
output.must_match "Couldn't find mailing list in \"invalid path\""
|
13
|
+
output.must_match "ArgumentError"
|
12
14
|
end
|
13
15
|
|
14
16
|
it "fails with NoMethodError on empty input" do
|
15
17
|
output = exec_ruml example_ml_path, nil
|
16
|
-
output.must_match
|
18
|
+
output.must_match %r{undefined method `size' (for|on) nil:NilClass}
|
19
|
+
output.must_match "NoMethodError"
|
17
20
|
end
|
18
21
|
|
19
22
|
describe "with example_ml" do
|
@@ -21,14 +24,14 @@ describe "Ruml binary" do
|
|
21
24
|
|
22
25
|
it "refuse email from unknown member" do
|
23
26
|
mail = compose_mail(mailing_list, :from => "unknown@member.com")
|
24
|
-
output = exec_ruml mailing_list.
|
27
|
+
output = exec_ruml mailing_list.path, mail.to_s
|
25
28
|
output.must_be_empty
|
26
29
|
deliveries.must_be_empty
|
27
30
|
end
|
28
31
|
|
29
32
|
describe "from valid member" do
|
30
33
|
let(:mail) { compose_mail(mailing_list) }
|
31
|
-
let(:output) { exec_ruml mailing_list.
|
34
|
+
let(:output) { exec_ruml mailing_list.path, mail.to_s }
|
32
35
|
let(:delivery) { output; deliveries.first }
|
33
36
|
|
34
37
|
it "output is empty" do
|
metadata
CHANGED
@@ -1,66 +1,72 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruml
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Peter Suschlik
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2011-11-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &5745740 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.2
|
22
|
+
type: :development
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
+
version_requirements: *5745740
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: minitest
|
27
|
+
requirement: &5744960 !ruby/object:Gem::Requirement
|
24
28
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
32
33
|
type: :development
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: mail
|
36
34
|
prerelease: false
|
37
|
-
|
35
|
+
version_requirements: *5744960
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mail
|
38
|
+
requirement: &5743680 !ruby/object:Gem::Requirement
|
38
39
|
none: false
|
39
|
-
requirements:
|
40
|
+
requirements:
|
40
41
|
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 2
|
45
|
-
- 3
|
46
|
-
- 0
|
42
|
+
- !ruby/object:Gem::Version
|
47
43
|
version: 2.3.0
|
48
44
|
type: :runtime
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *5743680
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: moneta-splattael
|
49
|
+
requirement: &5760440 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *5760440
|
58
|
+
description: ''
|
59
|
+
email:
|
52
60
|
- peter@suschlik.de
|
53
|
-
executables:
|
61
|
+
executables:
|
54
62
|
- ruml
|
55
63
|
extensions: []
|
56
|
-
|
57
64
|
extra_rdoc_files: []
|
58
|
-
|
59
|
-
files:
|
65
|
+
files:
|
60
66
|
- .gitignore
|
61
67
|
- .rvmrc
|
68
|
+
- .travis.yml
|
62
69
|
- Gemfile
|
63
|
-
- Gemfile.lock
|
64
70
|
- README.md
|
65
71
|
- Rakefile
|
66
72
|
- bin/ruml
|
@@ -70,9 +76,11 @@ files:
|
|
70
76
|
- example/testml/to
|
71
77
|
- lib/ruml.rb
|
72
78
|
- lib/ruml/broadcaster.rb
|
79
|
+
- lib/ruml/config.rb
|
73
80
|
- lib/ruml/list.rb
|
74
81
|
- lib/ruml/version.rb
|
75
82
|
- ruml.gemspec
|
83
|
+
- test/fixtures/example_ml.yml
|
76
84
|
- test/fixtures/example_ml/bounce_to
|
77
85
|
- test/fixtures/example_ml/members
|
78
86
|
- test/fixtures/example_ml/name
|
@@ -81,36 +89,26 @@ files:
|
|
81
89
|
- test/integration_test.rb
|
82
90
|
homepage: https://github.com/splattael/ruml
|
83
91
|
licenses: []
|
84
|
-
|
85
92
|
post_install_message:
|
86
93
|
rdoc_options: []
|
87
|
-
|
88
|
-
require_paths:
|
94
|
+
require_paths:
|
89
95
|
- lib
|
90
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
97
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
|
97
|
-
- 0
|
98
|
-
version: "0"
|
99
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
103
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
version: "0"
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
108
|
requirements: []
|
109
|
-
|
110
109
|
rubyforge_project:
|
111
110
|
rubygems_version: 1.8.10
|
112
111
|
signing_key:
|
113
112
|
specification_version: 3
|
114
113
|
summary: Ruby mailing list software
|
115
114
|
test_files: []
|
116
|
-
|
data/Gemfile.lock
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ruml (0.0.1)
|
5
|
-
mail (~> 2.3.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
i18n (0.6.0)
|
11
|
-
mail (2.3.0)
|
12
|
-
i18n (>= 0.4.0)
|
13
|
-
mime-types (~> 1.16)
|
14
|
-
treetop (~> 1.4.8)
|
15
|
-
mime-types (1.17.2)
|
16
|
-
minitest (2.7.0)
|
17
|
-
polyglot (0.3.2)
|
18
|
-
treetop (1.4.10)
|
19
|
-
polyglot
|
20
|
-
polyglot (>= 0.3.1)
|
21
|
-
|
22
|
-
PLATFORMS
|
23
|
-
ruby
|
24
|
-
|
25
|
-
DEPENDENCIES
|
26
|
-
minitest
|
27
|
-
ruml!
|