maid 0.1.4.alpha.2 → 0.2.0.alpha.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.
@@ -0,0 +1,21 @@
1
+ require 'ohai'
2
+
3
+ # Version information for the host system, kind of like a browser's user agent string.
4
+ #
5
+ # This could potentially be a part of `Platform` or `VERSION` but both of those are used when building the gemspec, which can't depend on other gems.
6
+ module Maid::UserAgent
7
+ class << self
8
+ # This used to be called `#to_s`, but that made things difficult when testing.
9
+ def value
10
+ ohai = Ohai::System.new
11
+ ohai.all_plugins
12
+ ohai_rb = ohai['languages']['ruby']
13
+
14
+ maid = "Maid/#{ ::Maid.const_get(:VERSION) }"
15
+ platform = "#{ ohai['platform'] }/#{ ohai['platform_version'] }"
16
+ ruby = "Ruby/#{ ohai_rb['version'] } #{ ohai_rb['platform'] }"
17
+
18
+ "#{ maid } (#{ platform }; #{ ruby })"
19
+ end
20
+ end
21
+ end
data/lib/maid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maid
2
- VERSION = '0.1.4.alpha.2'
2
+ VERSION = '0.2.0.alpha.1'
3
3
  end
data/maid.gemspec CHANGED
@@ -22,12 +22,15 @@ Gem::Specification.new do |s|
22
22
  # # After a new version with the Ruby 1.9 bugfix is released, change over to `xdg`
23
23
  # s.add_dependency('xdg', '~> 2.2.2')
24
24
  s.add_dependency('maid-xdg', '= 2.2.1.2')
25
+ s.add_dependency('ohai', '~> 6.14.0')
26
+ s.add_development_dependency('fakefs', '~> 0.4.1')
25
27
  s.add_development_dependency('guard', '~> 1.5.4')
26
- s.add_development_dependency('guard-rspec', '~> 2.1.2')
28
+ s.add_development_dependency('guard-rspec', '~> 2.2.0')
27
29
  s.add_development_dependency('rake', '~> 10.0.2')
30
+ s.add_development_dependency('redcarpet', '~> 2.2.2') # Soft dependency of `yard`
28
31
  s.add_development_dependency('rspec', '~> 2.12.0')
29
32
  s.add_development_dependency('timecop', '~> 0.5.3')
30
- s.add_development_dependency('fakefs', '~> 0.4.1')
33
+ s.add_development_dependency('yard', '~> 0.8.3')
31
34
 
32
35
  if Maid::Platform.linux?
33
36
  s.add_development_dependency('rb-inotify', '~> 0.8.8')
@@ -0,0 +1,38 @@
1
+ require 'ohai'
2
+ require 'xdg'
3
+
4
+ # > What is Dependency Testing?
5
+ # >
6
+ # > Examines an application's requirements for pre-existing software, initial states and configuration in order to maintain proper functionality.
7
+ # >
8
+ # > -- http://sqa.fyicenter.com/FAQ/Software-QA-Testing/What_is_Dependency_Testing_.html
9
+ describe 'Dependency expectations' do
10
+ describe Ohai do
11
+ before do
12
+ @ohai = Ohai::System.new
13
+ # FIXME: For some reason this is really slow when using `guard`
14
+ @ohai.require_plugin('os')
15
+ end
16
+
17
+ it 'has platform information' do
18
+ @ohai.require_plugin('platform')
19
+ @ohai['platform'].should match(/[a-z]+/i)
20
+ @ohai['platform_version'].should match(/[0-9]+/)
21
+ end
22
+
23
+ it 'has Ruby information' do
24
+ ruby = @ohai['languages']['ruby']
25
+ ruby['version'].should match(/^[0-9\.]+$/i)
26
+ ruby['platform'].should match(/[a-z0-9]+/i)
27
+ end
28
+ end
29
+
30
+ describe XDG do
31
+ it 'has DATA_HOME' do
32
+ # FIXME: This test could be cleaner. We can't depend on the directory to already exist, even on systems that use the XDG standard. This seems safe enough for now.
33
+ #
34
+ # More info: [XDG Base Directory Specification](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html)
35
+ XDG['DATA_HOME'].to_s.should match(%r{^/.*?/\.local/share$})
36
+ end
37
+ end
38
+ end
@@ -21,14 +21,14 @@ module Maid
21
21
  $stderr = STDERR
22
22
  end
23
23
 
24
- before :each do
24
+ before do
25
25
  @app = App.new
26
26
  @app.stub!(:maid_options)
27
27
  @app.stub!(:say)
28
28
 
29
29
  TrashMigration.stub(:needed?) { false }
30
30
 
31
- # NOTE It's pretty important that this is stubbed, unless you want your rules to be run over and over when you test!
31
+ # NOTE: It's pretty important that this is stubbed, unless you want your rules to be run over and over when you test!
32
32
  @maid = mock('Maid')
33
33
  @maid.stub!(:clean)
34
34
  @maid.stub!(:log_device)
@@ -37,7 +37,7 @@ module Maid
37
37
  end
38
38
 
39
39
  it 'should make a new Maid with the options' do
40
- opts = {:foo => 'bar'}
40
+ opts = { :foo => 'bar' }
41
41
  @app.stub!(:maid_options).and_return(opts)
42
42
  Maid.should_receive(:new).with(opts).and_return(@maid)
43
43
  @app.clean
@@ -53,7 +53,7 @@ module Maid
53
53
  end
54
54
 
55
55
  it 'should be silent if given the --silent option' do
56
- # TODO It might even make sense to wrap "maid.clean" in capture_stdout { }...
56
+ # TODO: It might even make sense to wrap `maid.clean` in `capture_stdout { ... }`
57
57
  capture_stdout { App.start(['clean', '--silent']) }.string.should == ''
58
58
  end
59
59
 
@@ -67,15 +67,35 @@ module Maid
67
67
  end
68
68
 
69
69
  describe App, '#version' do
70
+ before do
71
+ @app = App.new
72
+ end
73
+
70
74
  it 'should print out the gem version' do
71
- app = App.new
72
- app.should_receive(:say).with(VERSION)
73
- app.version
75
+ @app.should_receive(:say).with(VERSION)
76
+ @app.version
77
+ end
78
+
79
+ context 'with the "long" option' do
80
+ before do
81
+ # FIXME: This is ugly. Maybe use `Maid.start(%w(version --long))` instead.
82
+
83
+ # We can't simply stub `long?` because `options` is a frozen object.
84
+ options = mock('options', :long? => true)
85
+ @app.options = options
86
+ end
87
+
88
+ it 'should print out the gem version' do
89
+ ua = 'Maid/0.0.1'
90
+ UserAgent.stub(:value) { ua }
91
+ @app.should_receive(:say).with(ua)
92
+ @app.version
93
+ end
74
94
  end
75
95
  end
76
96
 
77
97
  describe App, '#maid_options' do
78
- before :each do
98
+ before do
79
99
  @app = App.new
80
100
  end
81
101
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Maid
4
4
  describe Maid do
5
- before :each do
5
+ before do
6
6
  @logger = double('Logger').as_null_object
7
7
  Logger.stub!(:new).and_return(@logger)
8
8
  FileUtils.stub(:mkdir_p)
@@ -95,8 +95,8 @@ module Maid
95
95
  end
96
96
 
97
97
  it 'should set the file options to the given options, if provided' do
98
- maid = Maid.new(:file_options => {:verbose => true})
99
- maid.file_options.should == {:verbose => true}
98
+ maid = Maid.new(:file_options => { :verbose => true })
99
+ maid.file_options.should == { :verbose => true }
100
100
  end
101
101
 
102
102
  it 'should set the rules path' do
@@ -115,7 +115,7 @@ module Maid
115
115
  end
116
116
 
117
117
  describe '#clean' do
118
- before :each do
118
+ before do
119
119
  @maid = Maid.new
120
120
  @logger.stub!(:info)
121
121
  end
@@ -133,7 +133,7 @@ module Maid
133
133
  end
134
134
 
135
135
  describe '#load_rules' do
136
- before :each do
136
+ before do
137
137
  Kernel.stub!(:load)
138
138
  @maid = Maid.new
139
139
  end
@@ -151,14 +151,14 @@ module Maid
151
151
  end
152
152
 
153
153
  describe '#rule' do
154
- before :each do
154
+ before do
155
155
  @maid = Maid.new
156
156
  end
157
157
 
158
158
  it 'should add a rule to the list of rules' do
159
159
  @maid.rules.length.should == 0
160
160
 
161
- @maid.rule 'description' do
161
+ @maid.rule('description') do
162
162
  'instructions'
163
163
  end
164
164
 
@@ -173,7 +173,7 @@ module Maid
173
173
  maid = Maid.new
174
174
  @logger.should_receive(:info).exactly(n).times
175
175
  rules = (1..n).map do |n|
176
- mock = mock("rule ##{n}", :description => 'description')
176
+ mock = mock("rule ##{ n }", :description => 'description')
177
177
  mock.should_receive(:follow)
178
178
  mock
179
179
  end
@@ -184,7 +184,7 @@ module Maid
184
184
  end
185
185
 
186
186
  describe '#cmd' do
187
- before :each do
187
+ before do
188
188
  @maid = Maid.new
189
189
  end
190
190
 
@@ -2,24 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe Maid::NumericExtensions::Time, '#since?' do
4
4
  it 'should tell you that 1 week ago happened after 2 weeks ago' do
5
- (1.week.since? 2.weeks.ago).should be_true
5
+ 1.week.since?(2.weeks.ago).should be_true
6
6
  end
7
7
 
8
8
  it 'should tell you that 2 weeks ago was not after 1 week ago' do
9
- (2.week.since? 1.weeks.ago).should be_false
9
+ 2.week.since?(1.weeks.ago).should be_false
10
10
  end
11
11
  end
12
12
 
13
13
  describe Maid::NumericExtensions::SizeToKb do
14
14
  it 'should tell you that 1 megabyte equals 1024 kilobytes' do
15
- (1.megabyte == 1024.kilobytes).should be_true
15
+ 1.megabyte.should == 1024.kilobytes
16
16
  end
17
17
 
18
18
  it 'should tell you that 1 gigabyte equals 1024 megabytes' do
19
- (1.gigabyte == 1024.megabytes).should be_true
19
+ 1.gigabyte.should == 1024.megabytes
20
20
  end
21
21
 
22
22
  it 'should tell you that 1 terabyte equals 1024 gigabytes' do
23
- (1.terabyte == 1024.gigabytes).should be_true
23
+ 1.terabyte.should == 1024.gigabytes
24
24
  end
25
- end
25
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module Maid
4
4
  describe Rule do
5
5
  it 'should be able to be followed' do
6
- rule = Rule.new 'my rule', lambda { 1 + 2 }
6
+ rule = Rule.new('my rule', lambda { 1 + 2 })
7
7
  rule.follow.should == 3
8
8
  end
9
9
  end
@@ -7,7 +7,7 @@ module Maid
7
7
  #
8
8
  # * [FakeFS](https://github.com/defunkt/fakefs)
9
9
  describe Tools, :fakefs => true do
10
- before :each do
10
+ before do
11
11
  @home = File.expand_path('~')
12
12
  @now = Time.now
13
13
 
@@ -24,7 +24,7 @@ module Maid
24
24
  end
25
25
 
26
26
  describe '#move' do
27
- before :each do
27
+ before do
28
28
  @src_file = (@src_dir = '~/Source/') + (@file_name = 'foo.zip')
29
29
  FileUtils.mkdir_p(@src_dir)
30
30
  FileUtils.touch(@src_file)
@@ -60,7 +60,7 @@ module Maid
60
60
  end
61
61
 
62
62
  describe '#trash' do
63
- before :each do
63
+ before do
64
64
  @trash_path = @maid.trash_path
65
65
  @src_file = (@src_dir = '~/Source/') + (@file_name = 'foo.zip')
66
66
  FileUtils.mkdir_p(@src_dir)
@@ -110,7 +110,7 @@ module Maid
110
110
  end
111
111
 
112
112
  describe '#remove' do
113
- before :each do
113
+ before do
114
114
  @src_file = (@src_dir = '~/Source/') + (@file_name = 'foo.zip')
115
115
  FileUtils.mkdir_p(@src_dir)
116
116
  FileUtils.touch(@src_file)
@@ -152,7 +152,7 @@ module Maid
152
152
  end
153
153
 
154
154
  describe '#dir' do
155
- before :each do
155
+ before do
156
156
  @file = (dir = "#@home/Downloads/") + 'foo.zip'
157
157
  FileUtils.mkdir_p(dir)
158
158
  end
@@ -161,6 +161,12 @@ module Maid
161
161
  FileUtils.touch(@file)
162
162
  @maid.dir('~/Downloads/*.zip').should == [@file]
163
163
  end
164
+
165
+ it 'lists multiple files in alphabetical order' do
166
+ # It doesn't occur with `FakeFS` as far as I can tell, but Ubuntu (and possibly OS X) can give the results out of lexical order. That makes using the `dry-run` output difficult to use.
167
+ Dir.stub(:[]) { %w(/home/foo/b.zip /home/foo/a.zip /home/foo/c.zip) }
168
+ @maid.dir('~/Downloads/*.zip').should == %w(/home/foo/a.zip /home/foo/b.zip /home/foo/c.zip)
169
+ end
164
170
  end
165
171
 
166
172
  describe '#mkdir' do
@@ -171,7 +177,7 @@ module Maid
171
177
  end
172
178
 
173
179
  describe '#find' do
174
- before :each do
180
+ before do
175
181
  @file = (@dir = '~/Source/') + (@file_name = 'foo.zip')
176
182
  FileUtils.mkdir_p(@dir)
177
183
  FileUtils.touch(@file)
@@ -261,7 +267,7 @@ module Maid
261
267
 
262
268
  describe '#modified_at' do
263
269
  before do
264
- @path = "~/test.txt"
270
+ @path = '~/test.txt'
265
271
  FileUtils.touch(File.expand_path(@path))
266
272
  end
267
273
 
@@ -289,7 +295,7 @@ module Maid
289
295
  end
290
296
 
291
297
  describe '#sync' do
292
- before :each do
298
+ before do
293
299
  @src_dir = '~/Downloads/'
294
300
  @dst_dir = '~/Reference'
295
301
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ module Maid
4
+ describe UserAgent do
5
+ describe 'the user agent string' do
6
+ it 'is formatted with the Maid version, platform version, and Ruby version' do
7
+ system = {
8
+ 'platform' => 'Unix',
9
+ 'platform_version' => '1.0',
10
+ 'languages' => {
11
+ 'ruby' => {
12
+ 'version' => '1.8.8',
13
+ 'platform' => 'pdp7',
14
+ }
15
+ }
16
+ }
17
+
18
+ system.stub(:all_plugins)
19
+
20
+ Ohai::System.stub(:new) { system }
21
+ ::Maid.stub(:const_get).with(:VERSION) { '0.0.1' }
22
+
23
+ UserAgent.value.should == 'Maid/0.0.1 (Unix/1.0; Ruby/1.8.8 pdp7)'
24
+ end
25
+ end
26
+ end
27
+ end
data/spec/spec_helper.rb CHANGED
@@ -6,8 +6,8 @@ require 'fakefs/spec_helpers'
6
6
  require 'maid'
7
7
 
8
8
  RSpec.configure do |c|
9
- c.mock_with :rspec
10
- c.include FakeFS::SpecHelpers, :fakefs => true
9
+ c.mock_with(:rspec)
10
+ c.include(FakeFS::SpecHelpers, :fakefs => true)
11
11
  end
12
12
 
13
13
  RSpec::Matchers.define :have_deprecated_method do |expected|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.alpha.2
4
+ version: 0.2.0.alpha.1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-24 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &5554040 !ruby/object:Gem::Requirement
16
+ requirement: &10448900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.16.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *5554040
24
+ version_requirements: *10448900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: deprecated
27
- requirement: &5553020 !ruby/object:Gem::Requirement
27
+ requirement: &10447740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *5553020
35
+ version_requirements: *10447740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: maid-xdg
38
- requirement: &5551980 !ruby/object:Gem::Requirement
38
+ requirement: &10447020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,32 @@ dependencies:
43
43
  version: 2.2.1.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *5551980
46
+ version_requirements: *10447020
47
+ - !ruby/object:Gem::Dependency
48
+ name: ohai
49
+ requirement: &10445920 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 6.14.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *10445920
58
+ - !ruby/object:Gem::Dependency
59
+ name: fakefs
60
+ requirement: &10443960 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.4.1
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *10443960
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: guard
49
- requirement: &5551180 !ruby/object:Gem::Requirement
71
+ requirement: &10442880 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ~>
@@ -54,21 +76,21 @@ dependencies:
54
76
  version: 1.5.4
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *5551180
79
+ version_requirements: *10442880
58
80
  - !ruby/object:Gem::Dependency
59
81
  name: guard-rspec
60
- requirement: &5550480 !ruby/object:Gem::Requirement
82
+ requirement: &10442340 !ruby/object:Gem::Requirement
61
83
  none: false
62
84
  requirements:
63
85
  - - ~>
64
86
  - !ruby/object:Gem::Version
65
- version: 2.1.2
87
+ version: 2.2.0
66
88
  type: :development
67
89
  prerelease: false
68
- version_requirements: *5550480
90
+ version_requirements: *10442340
69
91
  - !ruby/object:Gem::Dependency
70
92
  name: rake
71
- requirement: &5549900 !ruby/object:Gem::Requirement
93
+ requirement: &10441780 !ruby/object:Gem::Requirement
72
94
  none: false
73
95
  requirements:
74
96
  - - ~>
@@ -76,10 +98,21 @@ dependencies:
76
98
  version: 10.0.2
77
99
  type: :development
78
100
  prerelease: false
79
- version_requirements: *5549900
101
+ version_requirements: *10441780
102
+ - !ruby/object:Gem::Dependency
103
+ name: redcarpet
104
+ requirement: &10418840 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.2.2
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *10418840
80
113
  - !ruby/object:Gem::Dependency
81
114
  name: rspec
82
- requirement: &5549320 !ruby/object:Gem::Requirement
115
+ requirement: &10418280 !ruby/object:Gem::Requirement
83
116
  none: false
84
117
  requirements:
85
118
  - - ~>
@@ -87,10 +120,10 @@ dependencies:
87
120
  version: 2.12.0
88
121
  type: :development
89
122
  prerelease: false
90
- version_requirements: *5549320
123
+ version_requirements: *10418280
91
124
  - !ruby/object:Gem::Dependency
92
125
  name: timecop
93
- requirement: &5548760 !ruby/object:Gem::Requirement
126
+ requirement: &10417660 !ruby/object:Gem::Requirement
94
127
  none: false
95
128
  requirements:
96
129
  - - ~>
@@ -98,21 +131,21 @@ dependencies:
98
131
  version: 0.5.3
99
132
  type: :development
100
133
  prerelease: false
101
- version_requirements: *5548760
134
+ version_requirements: *10417660
102
135
  - !ruby/object:Gem::Dependency
103
- name: fakefs
104
- requirement: &5548180 !ruby/object:Gem::Requirement
136
+ name: yard
137
+ requirement: &10417100 !ruby/object:Gem::Requirement
105
138
  none: false
106
139
  requirements:
107
140
  - - ~>
108
141
  - !ruby/object:Gem::Version
109
- version: 0.4.1
142
+ version: 0.8.3
110
143
  type: :development
111
144
  prerelease: false
112
- version_requirements: *5548180
145
+ version_requirements: *10417100
113
146
  - !ruby/object:Gem::Dependency
114
147
  name: rb-inotify
115
- requirement: &5547540 !ruby/object:Gem::Requirement
148
+ requirement: &10416480 !ruby/object:Gem::Requirement
116
149
  none: false
117
150
  requirements:
118
151
  - - ~>
@@ -120,7 +153,7 @@ dependencies:
120
153
  version: 0.8.8
121
154
  type: :development
122
155
  prerelease: false
123
- version_requirements: *5547540
156
+ version_requirements: *10416480
124
157
  description: Be lazy. Let Maid clean up after you, based on rules you define.
125
158
  email:
126
159
  - hello@benjaminoakes.com
@@ -151,6 +184,7 @@ files:
151
184
  - lib/maid/rules.sample.rb
152
185
  - lib/maid/tools.rb
153
186
  - lib/maid/trash_migration.rb
187
+ - lib/maid/user_agent.rb
154
188
  - lib/maid/version.rb
155
189
  - maid.gemspec
156
190
  - resources/OneThingWell.png
@@ -158,6 +192,7 @@ files:
158
192
  - resources/ruby5.gif
159
193
  - script/vagrant-provision
160
194
  - script/vagrant-test
195
+ - spec/dependency_spec.rb
161
196
  - spec/lib/maid/app_spec.rb
162
197
  - spec/lib/maid/maid_spec.rb
163
198
  - spec/lib/maid/numeric_extensions_spec.rb
@@ -165,6 +200,7 @@ files:
165
200
  - spec/lib/maid/rule_spec.rb
166
201
  - spec/lib/maid/tools_spec.rb
167
202
  - spec/lib/maid/trash_migration_spec.rb
203
+ - spec/lib/maid/user_agent_spec.rb
168
204
  - spec/lib/maid_spec.rb
169
205
  - spec/spec_helper.rb
170
206
  homepage: http://github.com/benjaminoakes/maid
@@ -193,3 +229,4 @@ signing_key:
193
229
  specification_version: 3
194
230
  summary: Be lazy. Let Maid clean up after you, based on rules you define.
195
231
  test_files: []
232
+ has_rdoc: