working_man 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +3 -0
- data/Gemfile.lock +30 -2
- data/Rakefile +13 -4
- data/bin/working_man +4 -15
- data/features/support/env.rb +23 -0
- data/features/working_man.feature +69 -0
- data/lib/working_man.rb +42 -35
- data/lib/working_man/version.rb +1 -1
- data/spec/lib/working_man_spec.rb +5 -0
- data/spec/spec_helper.rb +1 -0
- data/working_man.gemspec +3 -2
- metadata +31 -8
- data/test/test_working_man.rb +0 -5
data/.rspec
ADDED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,51 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
working_man (0.0.
|
5
|
-
methadone
|
4
|
+
working_man (0.0.4)
|
5
|
+
methadone (~> 1.0.0.rc4)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
aruba (0.4.11)
|
11
|
+
childprocess (>= 0.2.3)
|
12
|
+
cucumber (>= 1.1.1)
|
13
|
+
ffi (>= 1.0.11)
|
14
|
+
rspec (>= 2.7.0)
|
15
|
+
builder (3.0.0)
|
16
|
+
childprocess (0.3.1)
|
17
|
+
ffi (~> 1.0.6)
|
18
|
+
cucumber (1.1.9)
|
19
|
+
builder (>= 2.1.2)
|
20
|
+
diff-lcs (>= 1.1.2)
|
21
|
+
gherkin (~> 2.9.0)
|
22
|
+
json (>= 1.4.6)
|
23
|
+
term-ansicolor (>= 1.0.6)
|
24
|
+
diff-lcs (1.1.3)
|
25
|
+
ffi (1.0.11)
|
26
|
+
gherkin (2.9.3)
|
27
|
+
json (>= 1.4.6)
|
10
28
|
json (1.6.5)
|
11
29
|
methadone (1.0.0)
|
12
30
|
bundler
|
13
31
|
rake (0.9.2.2)
|
14
32
|
rdoc (3.12)
|
15
33
|
json (~> 1.4)
|
34
|
+
rspec (2.9.0)
|
35
|
+
rspec-core (~> 2.9.0)
|
36
|
+
rspec-expectations (~> 2.9.0)
|
37
|
+
rspec-mocks (~> 2.9.0)
|
38
|
+
rspec-core (2.9.0)
|
39
|
+
rspec-expectations (2.9.1)
|
40
|
+
diff-lcs (~> 1.1.3)
|
41
|
+
rspec-mocks (2.9.0)
|
42
|
+
term-ansicolor (1.0.7)
|
16
43
|
|
17
44
|
PLATFORMS
|
18
45
|
ruby
|
19
46
|
|
20
47
|
DEPENDENCIES
|
48
|
+
aruba (~> 0.4.11)
|
21
49
|
rake (~> 0.9.2)
|
22
50
|
rdoc
|
23
51
|
working_man!
|
data/Rakefile
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
3
|
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
5
4
|
require 'rdoc/task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'cucumber/rake/task'
|
6
7
|
|
7
8
|
include Rake::DSL
|
8
9
|
|
9
10
|
Bundler::GemHelper.install_tasks
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
desc 'Run specs'
|
13
|
+
RSpec::Core::RakeTask.new :spec do |t|
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
CUKE_RESULTS = 'results.html'
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
20
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
21
|
+
t.fork = false
|
13
22
|
end
|
14
23
|
|
15
24
|
Rake::RDocTask.new do |rd|
|
@@ -19,4 +28,4 @@ Rake::RDocTask.new do |rd|
|
|
19
28
|
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
20
29
|
end
|
21
30
|
|
22
|
-
task :default => [:
|
31
|
+
task :default => [:spec,:features]
|
data/bin/working_man
CHANGED
@@ -5,6 +5,7 @@ require 'methadone'
|
|
5
5
|
require 'working_man'
|
6
6
|
|
7
7
|
include Methadone::Main
|
8
|
+
include Methadone::CLILogging
|
8
9
|
|
9
10
|
main do |run_type|
|
10
11
|
# your program code here
|
@@ -21,23 +22,11 @@ end
|
|
21
22
|
# supplemental methods here
|
22
23
|
|
23
24
|
# Declare command-line interface here
|
24
|
-
|
25
|
-
# description "one line description of your app"
|
26
|
-
#
|
27
|
-
# Accept flags via:
|
28
|
-
# on("--flag VAL","Some flag")
|
29
|
-
# options[flag] will contain VAL
|
30
|
-
#
|
31
|
-
# Specify switches via:
|
32
|
-
# on("--[no-]switch","Some switch")
|
33
|
-
#
|
34
|
-
# Or, just call OptionParser methods on opts
|
35
25
|
#
|
36
|
-
|
37
|
-
# arg :some_arg
|
26
|
+
description "WorkingMan starts and stops your work day"
|
38
27
|
#
|
39
|
-
#
|
40
|
-
|
28
|
+
# Require run_type
|
29
|
+
arg :run_type, "'start' or 'stop' your work day"
|
41
30
|
|
42
31
|
version WorkingMan::VERSION
|
43
32
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'methadone/cucumber'
|
3
|
+
|
4
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
5
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
6
|
+
|
7
|
+
Before do
|
8
|
+
# Using "announce" causes massive warnings on 1.9.2
|
9
|
+
@puts = true
|
10
|
+
@original_rubylib = ENV['RUBYLIB']
|
11
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
12
|
+
|
13
|
+
# Setup fake home directory in /tmp/fakehome before tests
|
14
|
+
@real_home = ENV['HOME']
|
15
|
+
ENV['HOME'] = '/tmp/fakehome'
|
16
|
+
FileUtils.rm_rf '/tmp/fakehome'
|
17
|
+
FileUtils.mkdir '/tmp/fakehome'
|
18
|
+
end
|
19
|
+
|
20
|
+
After do
|
21
|
+
ENV['RUBYLIB'] = @original_rubylib
|
22
|
+
ENV['HOME'] = @real_home
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
Feature: My bootstrapped app kinda works
|
2
|
+
In order to get going on coding my awesome app
|
3
|
+
I want to have aruba and cucumber setup
|
4
|
+
So I don't have to do it myself
|
5
|
+
|
6
|
+
Scenario: App just runs
|
7
|
+
When I get help for "working_man"
|
8
|
+
Then the exit status should be 0
|
9
|
+
And the banner should be present
|
10
|
+
And the banner should document that this app takes options
|
11
|
+
And the following options should be documented:
|
12
|
+
|--version|
|
13
|
+
And the banner should document that this app's arguments are:
|
14
|
+
| run_type | which is required |
|
15
|
+
|
16
|
+
Scenario: Start work successfully with app and url
|
17
|
+
Given a file named "/tmp/fakehome/.working_man.yml" with:
|
18
|
+
"""
|
19
|
+
apps:
|
20
|
+
- 'Twitter'
|
21
|
+
urls:
|
22
|
+
- 'http://www.google.com'
|
23
|
+
"""
|
24
|
+
Then the file "/tmp/fakehome/.working_man.yml" should contain "Twitter"
|
25
|
+
And I run `working_man start`
|
26
|
+
Then the output should contain "Work hard today"
|
27
|
+
And the exit status should be 0
|
28
|
+
|
29
|
+
Scenario: Start work successfully with app and no url
|
30
|
+
Given a file named "/tmp/fakehome/.working_man.yml" with:
|
31
|
+
"""
|
32
|
+
apps:
|
33
|
+
- 'Twitter'
|
34
|
+
urls:
|
35
|
+
"""
|
36
|
+
Then the file "/tmp/fakehome/.working_man.yml" should contain "Twitter"
|
37
|
+
And I run `working_man start`
|
38
|
+
Then the output should contain "Work hard today"
|
39
|
+
And the exit status should be 0
|
40
|
+
|
41
|
+
Scenario: Start work unsuccessfully without any apps
|
42
|
+
Given a file named "/tmp/fakehome/.working_man.yml" with:
|
43
|
+
"""
|
44
|
+
apps:
|
45
|
+
urls:
|
46
|
+
- 'http://www.google.com'
|
47
|
+
"""
|
48
|
+
Then the file "/tmp/fakehome/.working_man.yml" should contain "http://www.google.com"
|
49
|
+
And I run `working_man start`
|
50
|
+
Then the output should contain "No applications in configuration"
|
51
|
+
And the exit status should be 2
|
52
|
+
|
53
|
+
Scenario: Start work unsuccessfully without a configuration
|
54
|
+
Given a file named "/tmp/fakehome/.working_man.yml" should not exist
|
55
|
+
When I run `working_man start`
|
56
|
+
Then the output should contain "No configuration found."
|
57
|
+
And the exit status should be 1
|
58
|
+
|
59
|
+
Scenario: Stop work successfully
|
60
|
+
Given a file named "/tmp/fakehome/.working_man.yml" with:
|
61
|
+
"""
|
62
|
+
apps:
|
63
|
+
- 'Twitter'
|
64
|
+
urls:
|
65
|
+
- 'http://www.google.com'
|
66
|
+
"""
|
67
|
+
When I run `working_man stop`
|
68
|
+
Then the output should contain "Have a great day!"
|
69
|
+
And the exit status should be 0
|
data/lib/working_man.rb
CHANGED
@@ -3,50 +3,57 @@ require "working_man/version"
|
|
3
3
|
require "working_man/actions"
|
4
4
|
|
5
5
|
module WorkingMan
|
6
|
-
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# Internal: Starts work day by calling WorkingMan::Actions#launch_applications,
|
7
|
+
# iterating through each app in @config['apps']. It exits if there are no
|
8
|
+
# applications with error code 2. If there are no URLs, the program finishes
|
9
|
+
# successfully.
|
9
10
|
#
|
11
|
+
# Examples:
|
10
12
|
#
|
11
|
-
|
12
|
-
@config = YAML::load File.open(File.expand_path('~/.working_man.yml'))
|
13
|
-
else
|
14
|
-
print "No configuration found. Please configure which apps to start in ~/.working_man.yml\n"
|
15
|
-
exit(1)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Start work calls WorkingMan::Actions#launch_applications, iterating through
|
19
|
-
# each app in @config['apps']. It exits if there are no applications with
|
20
|
-
# error code 2. If there are no URLs, the program finishes successfully.
|
21
|
-
#
|
22
|
-
#
|
13
|
+
# WorkingMan.start_work
|
23
14
|
def self.start_work
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
if File.exists?(File.expand_path('~/.working_man.yml'))
|
16
|
+
@config = YAML::load(File.open(File.expand_path('~/.working_man.yml')))
|
17
|
+
print "Starting work...\n"
|
18
|
+
begin
|
19
|
+
WorkingMan::Actions.launch_applications(@config['apps'])
|
20
|
+
rescue NoMethodError
|
21
|
+
p "No applications in configuration"
|
22
|
+
exit(2)
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
WorkingMan::Actions.open_urls(@config['urls'])
|
27
|
+
rescue NoMethodError
|
28
|
+
end
|
29
|
+
print "Work hard today!\n"
|
30
|
+
return true
|
31
|
+
else
|
32
|
+
puts "No configuration found. Please configure which apps to start in ~/.working_man.yml."
|
33
|
+
exit(1)
|
35
34
|
end
|
36
|
-
print "Work hard today!\n"
|
37
35
|
end
|
38
36
|
|
39
|
-
# Stop work iterates through the apps in @config['apps'], stopping
|
37
|
+
# Internal: Stop work iterates through the apps in @config['apps'], stopping
|
38
|
+
# each one
|
40
39
|
#
|
40
|
+
# Examples:
|
41
41
|
#
|
42
|
+
# WorkingMan.stop_work
|
42
43
|
def self.stop_work
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
if File.exists?(File.expand_path('~/.working_man.yml'))
|
45
|
+
@config = YAML::load(File.open(File.expand_path('~/.working_man.yml')))
|
46
|
+
print "Stopping work...\n"
|
47
|
+
begin
|
48
|
+
WorkingMan::Actions.close_applications(@config['apps'])
|
49
|
+
rescue NoMethodError
|
50
|
+
p "No applications in configuration"
|
51
|
+
exit(2)
|
52
|
+
end
|
53
|
+
print "Have a great day!\n"
|
54
|
+
else
|
55
|
+
puts "No configuration found. Please configure which apps to start in ~/.working_man.yml."
|
56
|
+
exit(1)
|
49
57
|
end
|
50
|
-
print "Have a great day!\n"
|
51
58
|
end
|
52
59
|
end
|
data/lib/working_man/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'working_man'
|
data/working_man.gemspec
CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = WorkingMan::VERSION
|
17
17
|
gem.add_development_dependency('rdoc')
|
18
|
-
gem.add_development_dependency('rake','~> 0.9.2')
|
19
|
-
gem.
|
18
|
+
gem.add_development_dependency('rake', '~> 0.9.2')
|
19
|
+
gem.add_development_dependency 'aruba', '~> 0.4.11'
|
20
|
+
gem.add_dependency('methadone', '~>1.0.0.rc4')
|
20
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: working_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -43,22 +43,38 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 0.9.2
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: aruba
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.4.11
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.4.11
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: methadone
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
49
65
|
none: false
|
50
66
|
requirements:
|
51
|
-
- -
|
67
|
+
- - ~>
|
52
68
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
69
|
+
version: 1.0.0.rc4
|
54
70
|
type: :runtime
|
55
71
|
prerelease: false
|
56
72
|
version_requirements: !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
58
74
|
requirements:
|
59
|
-
- -
|
75
|
+
- - ~>
|
60
76
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
77
|
+
version: 1.0.0.rc4
|
62
78
|
description: Start/stop your work apps for the day
|
63
79
|
email:
|
64
80
|
- emachnic@broadmac.net
|
@@ -68,17 +84,21 @@ extensions: []
|
|
68
84
|
extra_rdoc_files: []
|
69
85
|
files:
|
70
86
|
- .gitignore
|
87
|
+
- .rspec
|
71
88
|
- Gemfile
|
72
89
|
- Gemfile.lock
|
73
90
|
- LICENSE
|
74
91
|
- README.md
|
75
92
|
- Rakefile
|
76
93
|
- bin/working_man
|
94
|
+
- features/support/env.rb
|
95
|
+
- features/working_man.feature
|
77
96
|
- lib/resources/working_man.yml
|
78
97
|
- lib/working_man.rb
|
79
98
|
- lib/working_man/actions.rb
|
80
99
|
- lib/working_man/version.rb
|
81
|
-
-
|
100
|
+
- spec/lib/working_man_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
82
102
|
- working_man.gemspec
|
83
103
|
homepage: http://emachnic.github.com/working_man
|
84
104
|
licenses: []
|
@@ -105,4 +125,7 @@ signing_key:
|
|
105
125
|
specification_version: 3
|
106
126
|
summary: Start/stop your work apps for the day
|
107
127
|
test_files:
|
108
|
-
-
|
128
|
+
- features/support/env.rb
|
129
|
+
- features/working_man.feature
|
130
|
+
- spec/lib/working_man_spec.rb
|
131
|
+
- spec/spec_helper.rb
|