gem_watch 0.1.1 → 0.1.2
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/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/gem_watch/command.rb +4 -6
- data/test/check_test.rb +19 -0
- data/test/command_options_test.rb +44 -0
- data/test/command_test.rb +60 -0
- data/test/complete_yaml_data.yml +11 -0
- data/test/minimal_yaml_data.yml +2 -0
- data/test/test_helper.rb +1 -0
- metadata +24 -6
- data/test/gem_watch_test.rb +0 -7
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/jakimowicz/gem_watch"
|
12
12
|
gem.authors = ["Fabien Jakimowicz"]
|
13
13
|
gem.rubyforge_project = "gemwatch"
|
14
|
+
gem.add_development_dependency "test-unit"
|
14
15
|
gem.add_development_dependency "thoughtbot-shoulda"
|
15
16
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
17
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/gem_watch/command.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Pure ruby requires
|
2
2
|
require 'optparse'
|
3
3
|
require 'net/smtp'
|
4
|
-
|
5
|
-
# Gems
|
6
4
|
require 'yaml'
|
7
5
|
|
8
6
|
# Internal stuff
|
@@ -72,7 +70,6 @@ END_OF_MESSAGE
|
|
72
70
|
|
73
71
|
opts.on "-e", "--email-recipient=email1, email2, ...", "Email address to send results." do |email|
|
74
72
|
@options.email_recipients = email
|
75
|
-
@options.stdout = false
|
76
73
|
end
|
77
74
|
|
78
75
|
opts.on "-s", "--email-subject=subject", "Subject used in the email." do |subject|
|
@@ -81,7 +78,6 @@ END_OF_MESSAGE
|
|
81
78
|
|
82
79
|
opts.on "-f", "--email-from=email", "Email's sender." do |email|
|
83
80
|
@options.email_recipient = email.split(',').collect {|email| email.strip}
|
84
|
-
@options.stdout = false
|
85
81
|
end
|
86
82
|
|
87
83
|
opts.separator ""
|
@@ -122,11 +118,13 @@ END_OF_MESSAGE
|
|
122
118
|
# Given a <tt>yaml</tt> object and a <tt>key</tt> string, returns the value.
|
123
119
|
# If <tt>key</tt> contains an underscore character, it will consider each word between underscores as a subtree.
|
124
120
|
def yaml_value(yaml, key)
|
121
|
+
yaml[key].value
|
122
|
+
rescue
|
125
123
|
if key.include?('_')
|
126
124
|
first_key, sep, rest = key.partition('_')
|
127
|
-
yaml_value
|
125
|
+
yaml_value(yaml[first_key], rest) rescue nil
|
128
126
|
else
|
129
|
-
|
127
|
+
nil
|
130
128
|
end
|
131
129
|
end
|
132
130
|
end
|
data/test/check_test.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'gem_watch/check'
|
3
|
+
|
4
|
+
class CheckTest < Test::Unit::TestCase
|
5
|
+
context "an empty check" do
|
6
|
+
setup do
|
7
|
+
@check = GemWatch::Check.new
|
8
|
+
end
|
9
|
+
|
10
|
+
should "@impacts be an empty hash at initialization" do
|
11
|
+
assert_kind_of Hash, @check.impacts
|
12
|
+
assert @check.impacts.empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
should "passed? returns true if @impacts is empty" do
|
16
|
+
assert @check.passed?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'gem_watch/command_options'
|
3
|
+
|
4
|
+
class CommandOptionsTest < Test::Unit::TestCase
|
5
|
+
context "initialize empty object" do
|
6
|
+
setup do
|
7
|
+
@options = GemWatch::CommandOptions.new
|
8
|
+
end
|
9
|
+
|
10
|
+
should "should initialize object with default values" do
|
11
|
+
GemWatch::CommandOptions::Defaults.each do |key, value|
|
12
|
+
assert_equal value, @options.send(key)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
should "email_recipients= accepts an Array attribute" do
|
17
|
+
emails = ['bob@test.com', 'alice@test.com']
|
18
|
+
@options.email_recipients = emails
|
19
|
+
assert_equal emails, @options.email_recipients
|
20
|
+
end
|
21
|
+
|
22
|
+
should "email_recipients= accepts a String with only one email address" do
|
23
|
+
email = "bob@test.com"
|
24
|
+
@options.email_recipients = email
|
25
|
+
assert_equal [email], @options.email_recipients
|
26
|
+
end
|
27
|
+
|
28
|
+
should "email_recipients= accepts a String with coma separated emails" do
|
29
|
+
emails = ['bob@test.com', 'alice@test.com']
|
30
|
+
@options.email_recipients = emails.join(', ')
|
31
|
+
assert_equal emails, @options.email_recipients
|
32
|
+
end
|
33
|
+
|
34
|
+
should "stdout false if email_recipients is not empty" do
|
35
|
+
@options.email_recipients = 'bob@test.com'
|
36
|
+
assert_false @options.stdout
|
37
|
+
end
|
38
|
+
|
39
|
+
should "stdout false if email_recipients is empty" do
|
40
|
+
@options.email_recipients = ''
|
41
|
+
assert_true @options.stdout
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'gem_watch/command'
|
3
|
+
|
4
|
+
# We must access to options in order to check them
|
5
|
+
class GemWatch::Command
|
6
|
+
attr_reader :options
|
7
|
+
end
|
8
|
+
|
9
|
+
class CommandTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
YamlData = {'stdout' => '1', 'email' => {'recipients' => 'bob@test.com, alice@test.com'}}
|
12
|
+
MinimalYamlData = {'email' => {'recipients' => 'bob@test.com'}}
|
13
|
+
|
14
|
+
context "initialize empty command object and get access to protected stuff" do
|
15
|
+
setup do
|
16
|
+
GemWatch::Command.send(:public, *GemWatch::Command.protected_instance_methods)
|
17
|
+
@command = GemWatch::Command.new
|
18
|
+
end
|
19
|
+
|
20
|
+
context "parse yaml data" do
|
21
|
+
setup do
|
22
|
+
@yaml = YAML.parse(YamlData.to_yaml)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "yaml_value returns value of a yaml object if key has no underscore" do
|
26
|
+
assert_equal YamlData['stdout'], @command.yaml_value(@yaml, 'stdout')
|
27
|
+
end
|
28
|
+
|
29
|
+
should "yaml_value returns nested value if an underscore is present in key name" do
|
30
|
+
assert_equal YamlData['email']['recipients'], @command.yaml_value(@yaml, 'email_recipients')
|
31
|
+
end
|
32
|
+
|
33
|
+
should "yaml_value returns nil if key is not found" do
|
34
|
+
assert_nil @command.yaml_value(@yaml, 'boggy_key')
|
35
|
+
end
|
36
|
+
end # context "parse yaml data"
|
37
|
+
|
38
|
+
should "parse_options should set stdout to true if both email and stdout options are set" do
|
39
|
+
@command.parse_options ["--email-recipient=bob@test.com", "--stdout"]
|
40
|
+
assert_true @command.options.stdout
|
41
|
+
end
|
42
|
+
|
43
|
+
should "parse_options handle a yaml file with no check definition and use default values" do
|
44
|
+
@command.parse_options ["--config=test/minimal_yaml_data.yml"]
|
45
|
+
assert_equal ['bob@test.com'], @command.options.email_recipients
|
46
|
+
end
|
47
|
+
|
48
|
+
should "parse_options handle a complete yaml file" do
|
49
|
+
@command.parse_options ["--config=test/complete_yaml_data.yml"]
|
50
|
+
assert_equal ['admin@example.com'], @command.options.email_recipients
|
51
|
+
assert_equal "Critical update !", @command.options.email_subject
|
52
|
+
assert_equal "bob@service.com", @command.options.email_from
|
53
|
+
assert_equal "127.0.0.1", @command.options.smtp_host
|
54
|
+
assert_equal "25", @command.options.smtp_port
|
55
|
+
assert_equal "super_security, rails", @command.options.check_update_on
|
56
|
+
end
|
57
|
+
|
58
|
+
end # context "initialize empty command ..."
|
59
|
+
|
60
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_watch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabien Jakimowicz
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-30 00:00:00 +01:00
|
13
13
|
default_executable: gemwatch
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: test-unit
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: thoughtbot-shoulda
|
17
27
|
type: :development
|
@@ -44,10 +54,16 @@ files:
|
|
44
54
|
- lib/gem_watch/checks/update.rb
|
45
55
|
- lib/gem_watch/command.rb
|
46
56
|
- lib/gem_watch/command_options.rb
|
47
|
-
- test/
|
57
|
+
- test/check_test.rb
|
58
|
+
- test/command_options_test.rb
|
59
|
+
- test/command_test.rb
|
60
|
+
- test/complete_yaml_data.yml
|
61
|
+
- test/minimal_yaml_data.yml
|
48
62
|
- test/test_helper.rb
|
49
63
|
has_rdoc: true
|
50
64
|
homepage: http://github.com/jakimowicz/gem_watch
|
65
|
+
licenses: []
|
66
|
+
|
51
67
|
post_install_message:
|
52
68
|
rdoc_options:
|
53
69
|
- --charset=UTF-8
|
@@ -68,10 +84,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
84
|
requirements: []
|
69
85
|
|
70
86
|
rubyforge_project: gemwatch
|
71
|
-
rubygems_version: 1.3.
|
87
|
+
rubygems_version: 1.3.5
|
72
88
|
signing_key:
|
73
|
-
specification_version:
|
89
|
+
specification_version: 3
|
74
90
|
summary: watch over outdated gems and send an email to notice admin.
|
75
91
|
test_files:
|
76
|
-
- test/
|
92
|
+
- test/check_test.rb
|
93
|
+
- test/command_options_test.rb
|
94
|
+
- test/command_test.rb
|
77
95
|
- test/test_helper.rb
|