working_man 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f8c9d1f1dadb1f09f69c6b4412c03edb4a53a70
4
+ data.tar.gz: ff0a41774615e60a8122a01293fdc0fd55815152
5
+ SHA512:
6
+ metadata.gz: 8da4643b976351d89a87efd9c4b7e2c7830cb765d1320ed2ce8929c86e06536b314f1e283af27c2f76884e06dbeb27f529db335c2c5789af65e04482ad911c5f
7
+ data.tar.gz: 612e69bb62edbf10fbe5b27d939f5e705f2b3278531fbe42196e247ba919513db83967ca37deb8ff44d730ac59498ccf192ceb35c866ac760fd399aceaf23bdb
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in working_man.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,50 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- working_man (0.3.0)
5
- methadone (~> 1.2.1)
4
+ working_man (1.0.0)
5
+ thor (~> 0.18.1)
6
6
 
7
7
  GEM
8
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
9
9
  specs:
10
- aruba (0.5.0)
11
- childprocess (= 0.2.3)
10
+ aruba (0.5.4)
11
+ childprocess (>= 0.3.6)
12
12
  cucumber (>= 1.1.1)
13
- ffi (>= 1.0.11)
14
13
  rspec-expectations (>= 2.7.0)
15
- builder (3.1.4)
16
- childprocess (0.2.3)
17
- ffi (~> 1.0.6)
18
- cucumber (1.2.1)
14
+ builder (3.2.2)
15
+ childprocess (0.5.1)
16
+ ffi (~> 1.0, >= 1.0.11)
17
+ cucumber (1.3.12)
19
18
  builder (>= 2.1.2)
20
19
  diff-lcs (>= 1.1.3)
21
- gherkin (~> 2.11.0)
22
- json (>= 1.4.6)
23
- diff-lcs (1.1.3)
24
- ffi (1.0.11)
25
- gherkin (2.11.5)
26
- json (>= 1.4.6)
27
- json (1.6.5)
28
- methadone (1.2.1)
29
- bundler
30
- rake (0.9.2.2)
20
+ gherkin (~> 2.12)
21
+ multi_json (>= 1.7.5, < 2.0)
22
+ multi_test (>= 0.1.1)
23
+ diff-lcs (1.2.5)
24
+ ffi (1.9.3)
25
+ gherkin (2.12.2)
26
+ multi_json (~> 1.3)
27
+ json (1.8.1)
28
+ multi_json (1.9.2)
29
+ multi_test (0.1.1)
30
+ rake (10.1.1)
31
31
  rdoc (3.12)
32
32
  json (~> 1.4)
33
- rspec (2.11.0)
34
- rspec-core (~> 2.11.0)
35
- rspec-expectations (~> 2.11.0)
36
- rspec-mocks (~> 2.11.0)
37
- rspec-core (2.11.1)
38
- rspec-expectations (2.11.3)
39
- diff-lcs (~> 1.1.3)
40
- rspec-mocks (2.11.3)
33
+ rspec (2.14.1)
34
+ rspec-core (~> 2.14.0)
35
+ rspec-expectations (~> 2.14.0)
36
+ rspec-mocks (~> 2.14.0)
37
+ rspec-core (2.14.8)
38
+ rspec-expectations (2.14.5)
39
+ diff-lcs (>= 1.1.3, < 2.0)
40
+ rspec-mocks (2.14.6)
41
+ thor (0.18.1)
41
42
 
42
43
  PLATFORMS
43
44
  ruby
44
45
 
45
46
  DEPENDENCIES
46
- aruba (~> 0.5)
47
- rake (~> 0.9.2)
47
+ aruba (~> 0.5.4)
48
+ rake (~> 10.1.1)
48
49
  rdoc
49
- rspec (~> 2.9)
50
+ rspec (~> 2.14.1)
50
51
  working_man!
data/bin/working_man CHANGED
@@ -1,78 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path('../../lib', __FILE__))
2
3
 
3
- require 'optparse'
4
- require 'methadone'
5
4
  require 'working_man'
6
5
 
7
- include Methadone::Main
8
- include Methadone::CLILogging
9
-
10
- main do |run_type|
11
- config_path = File.expand_path("#{options[:file]}")
12
-
13
- check_config(config_path)
14
-
15
- case run_type
16
- when "start"
17
- WorkingMan.start_work
18
- when "stop"
19
- WorkingMan.stop_work
20
- end
21
- end
22
-
23
- # Internal: Checks for a configuration file. If one is not found, message
24
- # is printed to the console and system exits with status code "1"
25
- #
26
- # Examples:
27
- #
28
- # check_config(config_path)
29
- #
30
- # Returns true if everything passes
31
- def check_config(config_path)
32
- if File.exists?(config_path)
33
- check_config_format(config_path)
34
- return true
35
- else
36
- puts "No configuration found. Please configure which apps to start in #{config_path}"
37
- exit 1
38
- end
39
- end
40
-
41
- # Internal: Checks the format of the configuration file. If the configuration
42
- # is blank, exits with status "2". If there are no apps, exits with status "3"
43
- # If there are no URLs, prints a warning but continues with execution.
44
- #
45
- # Examples:
46
- #
47
- # check_config_format(config_path)
48
- #
49
- # Returns true if everything passes
50
- def check_config_format(config_path)
51
- $config = YAML::load(File.open(config_path))
52
-
53
- if !$config
54
- p "Nothing in configuration. Exiting..."
55
- exit 2
56
- elsif !$config['apps']
57
- p "No applications in configuration. Exiting..."
58
- exit 2
59
- elsif !$config['urls']
60
- p "WARN: No URLs in configuration"
61
- return true
62
- end
63
- end
64
-
65
- description "WorkingMan starts and stops your work day"
66
-
67
- on('-f path_to_file',
68
- '--file',
69
- 'Specify a different location for YAML config file')
70
-
71
- options[:file] = '~/.working_man.yml'
72
-
73
- # Require run_type
74
- arg :run_type, "'start' or 'stop' your work day"
75
-
76
- version WorkingMan::VERSION
77
-
78
- go!
6
+ WorkingMan::CLI.start(ARGV)
@@ -1,5 +1,4 @@
1
1
  require 'aruba/cucumber'
2
- require 'methadone/cucumber'
3
2
 
4
3
  ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
5
4
  LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
@@ -12,7 +11,7 @@ Before do
12
11
  @puts = true
13
12
  @original_rubylib = ENV['RUBYLIB']
14
13
  ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
15
-
14
+
16
15
  # Setup fake home directory in /tmp/fakehome before tests
17
16
  @real_home = ENV['HOME']
18
17
  ENV['HOME'] = '/tmp/fakehome'
@@ -0,0 +1,8 @@
1
+ When /^I get help for "([^"]*)"$/ do |app_name|
2
+ @app_name = app_name
3
+ step %(I run `#{app_name} --help`)
4
+ end
5
+
6
+ Then /^the output should print the version$/ do
7
+ assert_partial_output(WorkingMan::VERSION, all_output)
8
+ end
@@ -6,13 +6,23 @@ So that I can be lazy
6
6
  Scenario: App just runs
7
7
  When I get help for "working_man"
8
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
-
9
+ And the output should contain "Commands:"
10
+
11
+ Scenario: Prints the version number
12
+ When I run `working_man version`
13
+ Then the output should print the version
14
+ And the exit status should be 0
15
+
16
+ Scenario: Prints the version number when using "-v"
17
+ When I run `working_man -v`
18
+ Then the output should print the version
19
+ And the exit status should be 0
20
+
21
+ Scenario: Prints the version number when using "--version"
22
+ When I run `working_man --version`
23
+ Then the output should print the version
24
+ And the exit status should be 0
25
+
16
26
  Scenario: Start work successfully with app and url
17
27
  Given a file named "/tmp/fakehome/.working_man.yml" with:
18
28
  """
@@ -24,7 +34,7 @@ Scenario: Start work successfully with app and url
24
34
  And I run `working_man start`
25
35
  Then the output should contain "Work hard today"
26
36
  And the exit status should be 0
27
-
37
+
28
38
  Scenario: Start work successfully specifying a config file
29
39
  Given a file named "/tmp/fakehome/dotfiles/working_man_config.yml" with:
30
40
  """
@@ -33,7 +43,7 @@ Scenario: Start work successfully specifying a config file
33
43
  urls:
34
44
  - 'http://www.google.com'
35
45
  """
36
- When I run `working_man -f ~/dotfiles/working_man_config.yml start`
46
+ When I run `working_man start -f ~/dotfiles/working_man_config.yml`
37
47
  Then the output should contain "Work hard today"
38
48
  And the exit status should be 0
39
49
 
@@ -47,13 +57,13 @@ Scenario: Start work unsuccessfully without any apps
47
57
  And I run `working_man start`
48
58
  Then the output should contain "No applications in configuration"
49
59
  And the exit status should be 2
50
-
60
+
51
61
  Scenario: Start work unsuccessfully without a configuration
52
62
  Given a file named "/tmp/fakehome/.working_man.yml" should not exist
53
63
  When I run `working_man start`
54
64
  Then the output should contain "No configuration found."
55
65
  And the exit status should be 1
56
-
66
+
57
67
  Scenario: Stop work successfully
58
68
  Given a file named "/tmp/fakehome/.working_man.yml" with:
59
69
  """
@@ -0,0 +1,49 @@
1
+ require 'yaml'
2
+
3
+ module WorkingMan
4
+ class CLI
5
+ class Config
6
+ # Internal: Checks for a configuration file. If one is not found, message
7
+ # is printed to the console and system exits with status code "1"
8
+ #
9
+ # Examples:
10
+ #
11
+ # check_config(config_path)
12
+ #
13
+ # Returns true if everything passes
14
+ def self.check_config(config_path)
15
+ if File.exists?(config_path)
16
+ check_config_format(config_path)
17
+ return true
18
+ else
19
+ puts "No configuration found. Please configure which apps to start in #{config_path}"
20
+ exit 1
21
+ end
22
+ end
23
+
24
+ # Internal: Checks the format of the configuration file. If the configuration
25
+ # is blank, exits with status "2". If there are no apps, exits with status "3"
26
+ # If there are no URLs, prints a warning but continues with execution.
27
+ #
28
+ # Examples:
29
+ #
30
+ # check_config_format(config_path)
31
+ #
32
+ # Returns true if everything passes
33
+ def self.check_config_format(config_path)
34
+ $config = YAML::load(File.open(config_path))
35
+
36
+ if !$config
37
+ p "Nothing in configuration. Exiting..."
38
+ exit 2
39
+ elsif !$config['apps']
40
+ p "No applications in configuration. Exiting..."
41
+ exit 2
42
+ elsif !$config['urls']
43
+ p "WARN: No URLs in configuration"
44
+ return true
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,44 @@
1
+ require 'thor'
2
+
3
+ module WorkingMan
4
+ class CLI < Thor
5
+ require 'working_man/cli/config'
6
+
7
+ class_option :file, default: '~/.working_man.yml', aliases: '-f'
8
+
9
+ desc 'start', 'Starts your work day'
10
+ def start
11
+ configuration_check(options[:file])
12
+
13
+ print "Staring work...\n"
14
+
15
+ WorkingMan::Actions.launch_applications($config['apps'])
16
+ WorkingMan::Actions.open_urls($config['urls'])
17
+
18
+ print "Work hard today!\n"
19
+ end
20
+
21
+ desc 'stop', 'Stop working and go home!'
22
+ def stop
23
+ configuration_check(options[:file])
24
+
25
+ print "Stopping work...\n"
26
+
27
+ WorkingMan::Actions.close_applications($config['apps'])
28
+
29
+ print "Have a great day!\n"
30
+ end
31
+
32
+ desc 'version', 'Print the version'
33
+ def version
34
+ print "#{WorkingMan::VERSION}\n"
35
+ end
36
+ map ['-v', '--version'] => :version
37
+
38
+ private
39
+ def configuration_check(file)
40
+ config_path = File.expand_path(file)
41
+ WorkingMan::CLI::Config.check_config(config_path)
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module WorkingMan
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/working_man.rb CHANGED
@@ -1,36 +1,6 @@
1
- require "yaml"
2
- require "working_man/version"
3
- require "working_man/actions"
4
-
5
1
  module WorkingMan
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.
10
- #
11
- # Examples:
12
- #
13
- # WorkingMan.start_work
14
- def self.start_work
15
- print "Starting work...\n"
16
-
17
- WorkingMan::Actions.launch_applications($config['apps'])
18
- WorkingMan::Actions.open_urls($config['urls'])
19
-
20
- print "Work hard today!\n"
21
- end
22
-
23
- # Internal: Stop work iterates through the apps in $config['apps'], stopping
24
- # each one
25
- #
26
- # Examples:
27
- #
28
- # WorkingMan.stop_work
29
- def self.stop_work
30
- print "Stopping work...\n"
31
-
32
- WorkingMan::Actions.close_applications($config['apps'])
33
-
34
- print "Have a great day!\n"
35
- end
36
2
  end
3
+
4
+ require 'working_man/version'
5
+ require 'working_man/cli'
6
+ require 'working_man/actions'
data/working_man.gemspec CHANGED
@@ -15,8 +15,8 @@ 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.add_development_dependency 'aruba', '~> 0.5'
20
- gem.add_development_dependency 'rspec', '~> 2.9'
21
- gem.add_dependency 'methadone', '~> 1.2.1'
18
+ gem.add_development_dependency 'rake', '~> 10.1.1'
19
+ gem.add_development_dependency 'aruba', '~> 0.5.4'
20
+ gem.add_development_dependency 'rspec', '~> 2.14.1'
21
+ gem.add_runtime_dependency 'thor', '~> 0.18.1'
22
22
  end
metadata CHANGED
@@ -1,96 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: working_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Evan Machnic
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-16 00:00:00.000000000 Z
11
+ date: 2014-03-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rdoc
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 0.9.2
33
+ version: 10.1.1
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 0.9.2
40
+ version: 10.1.1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: aruba
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.5'
47
+ version: 0.5.4
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0.5'
54
+ version: 0.5.4
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
- version: '2.9'
61
+ version: 2.14.1
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: '2.9'
68
+ version: 2.14.1
78
69
  - !ruby/object:Gem::Dependency
79
- name: methadone
70
+ name: thor
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
- version: 1.2.1
75
+ version: 0.18.1
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
- version: 1.2.1
82
+ version: 0.18.1
94
83
  description: Start/stop your work apps for the day
95
84
  email:
96
85
  - emachnic@broadmac.net
@@ -99,9 +88,9 @@ executables:
99
88
  extensions: []
100
89
  extra_rdoc_files: []
101
90
  files:
102
- - .gitignore
103
- - .rspec
104
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
105
94
  - Gemfile
106
95
  - Gemfile.lock
107
96
  - LICENSE
@@ -109,42 +98,39 @@ files:
109
98
  - Rakefile
110
99
  - bin/working_man
111
100
  - features/support/env.rb
101
+ - features/support/step_definitions.rb
112
102
  - features/working_man.feature
113
103
  - lib/resources/working_man.yml
114
104
  - lib/working_man.rb
115
105
  - lib/working_man/actions.rb
106
+ - lib/working_man/cli.rb
107
+ - lib/working_man/cli/config.rb
116
108
  - lib/working_man/version.rb
117
109
  - working_man.gemspec
118
110
  homepage: http://emachnic.github.com/working_man
119
111
  licenses: []
112
+ metadata: {}
120
113
  post_install_message:
121
114
  rdoc_options: []
122
115
  require_paths:
123
116
  - lib
124
117
  required_ruby_version: !ruby/object:Gem::Requirement
125
- none: false
126
118
  requirements:
127
- - - ! '>='
119
+ - - ">="
128
120
  - !ruby/object:Gem::Version
129
121
  version: '0'
130
- segments:
131
- - 0
132
- hash: 2595108310435164614
133
122
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
123
  requirements:
136
- - - ! '>='
124
+ - - ">="
137
125
  - !ruby/object:Gem::Version
138
126
  version: '0'
139
- segments:
140
- - 0
141
- hash: 2595108310435164614
142
127
  requirements: []
143
128
  rubyforge_project:
144
- rubygems_version: 1.8.23
129
+ rubygems_version: 2.2.0
145
130
  signing_key:
146
- specification_version: 3
131
+ specification_version: 4
147
132
  summary: Start/stop your work apps for the day
148
133
  test_files:
149
134
  - features/support/env.rb
135
+ - features/support/step_definitions.rb
150
136
  - features/working_man.feature