balboa 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 259c76600d7bcd513743de8ac654c905536d05f5
4
- data.tar.gz: 62811d033eb6aa3b0be11386c68a7fa835ea545a
3
+ metadata.gz: 4c25acee3579ab0c156d12ce5e438e813d1547d8
4
+ data.tar.gz: 1476c5b8e2c9a49b7f5e5d2d5591888234e3b5f0
5
5
  SHA512:
6
- metadata.gz: b098e9dde480d645e69e893dbdadece15f69113a3b2de85bf501d4e5de4c92218ac337d6978db2d4e2e63f5a14ea6f8fb0db09aad7de4be13d2ef35ff74d6b99
7
- data.tar.gz: e3cce93de5d628acec25cc1d241ac7c0ccd3430716b8e5482f6a6526da70a1a8decd9cef562ac14f790caf74dd20c9292c0ec0ce6deaeb44cecc1dcb50692502
6
+ metadata.gz: 3fcfe0ee354b9c9996907fb1d529e72d6910127b9abd812dbbb486259ea35f1ed21835843febaf6b626113b3dc95fda6fb0ec55b9bbf425459f69152c718dc4b
7
+ data.tar.gz: 387295753dda02919638b846b917bb4e9a63992ae178f74e1ff6b184628d1224f2ac50d3507e6badb22673f4a0784cbdca1bdcbdd4d79504c16be5dfc48f105e
data/balboa.gemspec CHANGED
@@ -25,4 +25,6 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_runtime_dependency 'capybara', '~> 2.7.1'
27
27
  s.add_runtime_dependency 'phantomjs', '~> 2.1.1.0'
28
+ s.add_runtime_dependency 'highline', '~> 1.7.8'
29
+ s.add_runtime_dependency 'holidays', '~> 4.6.0'
28
30
  end
data/bin/balboa CHANGED
@@ -3,24 +3,34 @@
3
3
 
4
4
  require_relative '../lib/balboa'
5
5
 
6
- command = ARGV.shift || :help
7
- app = Balboa::CLI::Application.new(command)
8
- options = Balboa::CLI::Options.parse(ARGV)
9
-
10
- raw_interactor = Balboa::Interactor::CapybaraInteractor.new
6
+ defaults = if File.exist?(Balboa::CONFIG_FILE)
7
+ YAML.load_file(Balboa::CONFIG_FILE)
8
+ else
9
+ Balboa::CLI::Defaults.prompt
10
+ end
11
11
 
12
- Balboa::Interactor::InteractorBuilder.create(raw_interactor, options)
12
+ options = Balboa::CLI::Options.parse(ARGV, defaults)
13
13
 
14
+ raw_interactor = Balboa::Interactor::InteractorBuilder.create(options)
14
15
  interactor = Balboa::Interactor::InteractorWrapper.new(raw_interactor)
15
16
 
16
17
  app_last = Balboa::CLI::Command::LastCommand.new(interactor)
17
- app_punch = Balboa::CLI::Command::PunchCommand.new(interactor, options['holidays'])
18
- app_help = Balboa::CLI::Command::HelpCommand.new
18
+ app_punch = Balboa::CLI::Command::PunchCommand.new(interactor)
19
+ app_reset = Balboa::CLI::Command::ResetCommand.new
19
20
  app_star_wars = Balboa::CLI::Command::StarWarsCommand.new
20
21
 
22
+ command = ARGV.first
23
+ app = Balboa::CLI::Application.new(command)
21
24
  app.add_command(:last, app_last)
22
25
  app.add_command(:punch, app_punch)
23
- app.add_command(:help, app_help)
26
+ app.add_command(:reset, app_reset)
24
27
  app.add_command(:star_wars, app_star_wars)
25
28
 
26
- app.execute
29
+ begin
30
+ app.execute
31
+ rescue Balboa::CLI::Application::CommandNotFound
32
+ $stdout.puts("\nCommand Not Found!")
33
+ $stdout.puts("\nRun `balboa -h' to check available commands and options.")
34
+ rescue Balboa::Interactor::Command::LoginCommand::LoginFailure
35
+ $stdout.puts("\nWrong e-mail or password!")
36
+ end
@@ -13,27 +13,6 @@ module Balboa
13
13
  private
14
14
 
15
15
  def help
16
- [
17
- "░░░░░▄▄███████████████▄▄░░░░ BALBOA #{Balboa::VERSION}",
18
- "░░▄██████████████████████▄░░",
19
- "░█████████▀███████▀████████░",
20
- "█████████▀▀█▀█░░▀██▄██▄████░ Usage: balboa [command] [options]",
21
- "░████████▄▄█░▀▀▄▄█░░▀░████░░",
22
- "░███████▀░░░▄▄▄▄░░░▄▄▄███░░░ Commands:",
23
- "▀███████░░▄▀▀██▀░░█▄░▄▀███░░ last Fetch last punch date",
24
- "░██████▀░░█░██▀▀░░████░██░░░ punch Punch up to yesterday",
25
- "████████░▄░░▀▀░░░░▀▄░▀▀█░░░░ help HERBERT, COME TO MY RESCUE",
26
- "█▀██████▀░▄░░▄░░░░░░█░░█░░░░",
27
- "▀▄████▄▀░░░▀▀░░▀░▄░░▀░░░█░░░ Options:",
28
- "▄██████▀▄░░░░░░░░░██▄▄▄░█░░░ balboa punch -c FILE Override config from .balboa",
29
- "███████░█░░░░░░░░█▀▄▄▄█░░█░░ balboa punch -p PASSWORD Override password from .balboa",
30
- "░██████░░█░░░░░░░░░▀░░░░░░▀▄",
31
- "▀▄█████░░░▀▄░░░░░░░░░░░░░░░█ Examples:",
32
- "░░░███▀░░░░░░▀░░░░▄░░░░░░▄█░ balboa",
33
- "░░░▄▀░░░░░░░░░▀▄░░░▀▀▀▀▀█▀░░ balboa punch",
34
- "░▀░░░░░░░░░░░░░░░▀░░░░░░▀▄░░",
35
- "░░░░░░░░░░░░░░░░░░░░░░░▄░█▀▄ #{quote}"
36
- ].join("\n")
37
16
  end
38
17
 
39
18
  def quote
@@ -1,25 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'holidays'
4
+ require 'highline/import'
5
+
3
6
  module Balboa
4
7
  module CLI
5
8
  module Command
6
9
  class PunchCommand
7
- def initialize(interactor, holidays)
10
+ def initialize(interactor)
8
11
  @interactor = interactor
9
- @holidays = holidays.uniq.map { |holiday| Date.parse(holiday) }
10
12
  end
11
13
 
12
14
  def execute
13
15
  punch_dates.each do |date|
14
- $stdout.print(date.strftime("%d/%m/%Y"))
15
-
16
- if date.saturday? || date.sunday? || holiday?(date)
17
- $stdout.print(" # SKIPPED")
18
- else
19
- @interactor.punch(date)
20
- end
16
+ $stdout.print("\n#{date.strftime("%d/%m/%Y")}")
21
17
 
22
- $stdout.print("\n")
18
+ @interactor.punch(date) unless skip_date?(date)
23
19
  end
24
20
  end
25
21
 
@@ -28,16 +24,65 @@ module Balboa
28
24
  def punch_dates
29
25
  yesterday = Date.today - 1
30
26
 
31
- (last_punch_date..yesterday)
27
+ (last_punch_date..yesterday).map do |date|
28
+ PunchDate.new(date)
29
+ end
30
+ end
31
+
32
+ def skip_date?(date)
33
+ !date.punchable? || skips_include?(date)
32
34
  end
33
35
 
34
- def holiday?(date)
35
- @holidays.include?(date)
36
+ def skips_include?(date)
37
+ @interactor.options['skips'].include?(date)
36
38
  end
37
39
 
38
40
  def last_punch_date
39
41
  Date.parse(@interactor.last) + 1
40
42
  end
43
+
44
+ class PunchDate
45
+ def initialize(date)
46
+ @date = date
47
+ @holiday = Hash(Holidays.on(@date, :br).first)
48
+ end
49
+
50
+ def punchable?
51
+ if weekend?
52
+ false
53
+ elsif holiday?
54
+ ask_for_punch
55
+ else
56
+ true
57
+ end
58
+ end
59
+
60
+ def to_s
61
+ @date.to_s
62
+ end
63
+
64
+ def strftime(format)
65
+ @date.strftime(format)
66
+ end
67
+
68
+ private
69
+
70
+ def ask_for_punch
71
+ HighLine.agree(" #{holiday_name}. Punch? (y|n) ")
72
+ end
73
+
74
+ def holiday_name
75
+ @holiday[:name]
76
+ end
77
+
78
+ def holiday?
79
+ !!@holiday
80
+ end
81
+
82
+ def weekend?
83
+ @date.sunday? || @date.saturday?
84
+ end
85
+ end
41
86
  end
42
87
  end
43
88
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Balboa
4
+ module CLI
5
+ module Command
6
+ class ResetCommand
7
+ def execute
8
+ File.delete(Balboa::CONFIG_FILE)
9
+
10
+ $stdout.puts(message)
11
+ end
12
+
13
+ def message
14
+ "\nBalboa restored to initial settings!"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'highline'
5
+
6
+ module Balboa
7
+ module CLI
8
+ class Defaults
9
+ def self.prompt
10
+ new.prompt
11
+ end
12
+
13
+ def initialize
14
+ @config = {}
15
+ @cli = HighLine.new
16
+ end
17
+
18
+ def prompt
19
+ prompt_attributes
20
+
21
+ prompt_schedule
22
+
23
+ create_file
24
+
25
+ @config
26
+ end
27
+
28
+ private
29
+
30
+ def create_file
31
+ @config.reject! { |_, key| key.empty? }
32
+ @config.merge!('skips' => [])
33
+
34
+ File.open(Balboa::CONFIG_FILE, 'w') { |file| file.write(@config.to_yaml) }
35
+ end
36
+
37
+ def prompt_attributes
38
+ @config.merge!('email' => prompt_email)
39
+ @config.merge!('password' => prompt_password)
40
+ @config.merge!('project' => prompt_project)
41
+ end
42
+
43
+ def prompt_email
44
+ @cli.ask("E-mail: ")
45
+ end
46
+
47
+ def prompt_password
48
+ @cli.say("\nRemember: Password can be stored as text or passed via option!")
49
+
50
+ @cli.ask("Password: ") { |qst| qst.echo = "*" }
51
+ end
52
+
53
+ def prompt_project
54
+ @cli.ask("\nProject: ")
55
+ end
56
+
57
+ def prompt_schedule
58
+ @config.merge!('start_at' => prompt_start)
59
+ @config.merge!('lunch_at' => prompt_lunch)
60
+ @config.merge!('restart_at' => prompt_restart)
61
+ @config.merge!('leave_at' => prompt_leave)
62
+ end
63
+
64
+ def prompt_start
65
+ @cli.ask("\nFirst shift: ") { |qst| qst.default = "8" }
66
+ end
67
+
68
+ def prompt_lunch
69
+ @cli.ask("\nLunch: ") { |qst| qst.default = "12" }
70
+ end
71
+
72
+ def prompt_restart
73
+ @cli.ask("\nSecond shift: ") { |qst| qst.default = "13" }
74
+ end
75
+
76
+ def prompt_leave
77
+ @cli.ask("\nLeave: ") { |qst| qst.default = "17" }
78
+ end
79
+ end
80
+ end
81
+ end
@@ -1,59 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'optparse'
4
- require 'yaml'
3
+ require_relative 'parser_builder'
5
4
 
6
5
  module Balboa
7
6
  module CLI
8
7
  class Options
9
- ERROR_EXIT_CODE = 1
10
- BALBOA_FILE = '.balboa'.freeze
11
-
12
- MissingOptionError = Class.new(RuntimeError)
13
-
14
- def self.parse(shifted_argv=[])
15
- new(shifted_argv).parse
8
+ def self.parse(*args)
9
+ new(*args).parse
16
10
  rescue OptionParser::InvalidOption => error
17
11
  $stderr.puts "Error: #{error}"
18
- exit ERROR_EXIT_CODE
12
+ exit
19
13
  end
20
14
 
21
- def initialize(shifted_argv)
22
- @parser = OptionParser.new(shifted_argv)
23
- @config = Hash.new { fail MissingOptionError }
24
-
25
- configure_parser
15
+ def initialize(argv=[], config={})
16
+ @config = config
17
+ @parser = Balboa::CLI::ParserBuilder.create(argv, config)
26
18
  end
27
19
 
28
20
  def parse
29
21
  @parser.parse!
30
-
31
22
  @config
32
23
  end
33
-
34
- private
35
-
36
- def configure_parser
37
- load_balboa_file
38
- load_config_file
39
- load_params
40
- end
41
-
42
- def load_balboa_file
43
- @config.merge!(YAML.load_file(BALBOA_FILE)) if File.exists?(BALBOA_FILE)
44
- end
45
-
46
- def load_config_file
47
- @parser.on('-c', '--config FILE') do |file|
48
- @config.merge!(YAML.load_file(file)) if File.exists?(file)
49
- end
50
- end
51
-
52
- def load_params
53
- @parser.on('-p', '--password PASSWORD') do |password|
54
- @config.merge!('password' => password)
55
- end
56
- end
57
24
  end
58
25
  end
59
26
  end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+ require 'yaml'
5
+
6
+ module Balboa
7
+ module CLI
8
+ class ParserBuilder
9
+ def self.create(*args)
10
+ new(*args).create
11
+ end
12
+
13
+ def initialize(argv, config)
14
+ @config = config
15
+ @parser = OptionParser.new(argv)
16
+ end
17
+
18
+ def create
19
+ configure_parser
20
+
21
+ @parser
22
+ end
23
+
24
+ private
25
+
26
+ def configure_parser
27
+ program_name = @parser.program_name
28
+
29
+ @parser.banner = <<-EOF.gsub(/^[ ]+/, '')
30
+ \nUsage: #{program_name} [commands] [options]"
31
+
32
+ Commands:
33
+
34
+ #{program_name} last
35
+ #{program_name} punch -p '123456' -s '12/06/1992,13/06/1992,14/06/1992'
36
+ #{program_name} reset
37
+ EOF
38
+
39
+ set_options
40
+ set_utilities
41
+ end
42
+
43
+ def set_options
44
+ @parser.separator "\nOptions:"
45
+ set_attributes
46
+ set_skipped_dates
47
+ set_custom_defaults
48
+ end
49
+
50
+ def set_utilities
51
+ @parser.separator "\nUtilities:"
52
+ set_help_option
53
+ set_version_option
54
+ set_balboa_picture
55
+ end
56
+
57
+ def set_custom_defaults
58
+ @parser.on('-c', '--config \'FILE\'', 'Read configuration options from FILE') do |file|
59
+ @config.merge!(YAML.load_file(file)) if File.exist?(file)
60
+ end
61
+ end
62
+
63
+ def set_attributes
64
+ @parser.on('-e', '--email \'EMAIL\'') do |email|
65
+ @config.merge!('email' => email)
66
+ end.on('-p', '--password \'PASSWORD\'') do |password|
67
+ @config.merge!('password' => password)
68
+ end.on('-w', '--project \'PROJECT\'') do |project|
69
+ @config.merge!('project' => project)
70
+ end
71
+ end
72
+
73
+ def set_skipped_dates
74
+ @parser.on('-s', '--skip \'DATES\'', 'Skip input dates', Array) do |dates|
75
+ parse_dates(dates)
76
+ end
77
+ end
78
+
79
+ def parse_dates(dates)
80
+ @config.merge!('skips' => dates.map { |date| Date.parse(date) })
81
+ end
82
+
83
+ def set_help_option
84
+ @parser.on('-h', '--help', 'Show this message') do
85
+ $stdout.puts @parser
86
+ exit
87
+ end
88
+ end
89
+
90
+ def set_version_option
91
+ @parser.on('-v', '--version', 'Show version') do
92
+ $stdout.puts "#{@parser.program_name} #{Balboa::VERSION}\n"
93
+ exit
94
+ end
95
+ end
96
+
97
+ def set_balboa_picture
98
+ @parser.separator("\n" + [
99
+ "░░░░░▄▄███████████████▄▄░░░░",
100
+ "░░▄██████████████████████▄░░",
101
+ "░█████████▀███████▀████████░",
102
+ "█████████▀▀█▀█░░▀██▄██▄████░",
103
+ "░████████▄▄█░▀▀▄▄█░░▀░████░░",
104
+ "░███████▀░░░▄▄▄▄░░░▄▄▄███░░░",
105
+ "▀███████░░▄▀▀██▀░░█▄░▄▀███░░",
106
+ "░██████▀░░█░██▀▀░░████░██░░░",
107
+ "████████░▄░░▀▀░░░░▀▄░▀▀█░░░░",
108
+ "█▀██████▀░▄░░▄░░░░░░█░░█░░░░",
109
+ "▀▄████▄▀░░░▀▀░░▀░▄░░▀░░░█░░░",
110
+ "▄██████▀▄░░░░░░░░░██▄▄▄░█░░░",
111
+ "███████░█░░░░░░░░█▀▄▄▄█░░█░░",
112
+ "░██████░░█░░░░░░░░░▀░░░░░░▀▄",
113
+ "▀▄█████░░░▀▄░░░░░░░░░░░░░░░█",
114
+ "░░░███▀░░░░░░▀░░░░▄░░░░░░▄█░",
115
+ "░░░▄▀░░░░░░░░░▀▄░░░▀▀▀▀▀█▀░░",
116
+ "░▀░░░░░░░░░░░░░░░▀░░░░░░▀▄░░",
117
+ "░░░░░░░░░░░░░░░░░░░░░░░▄░█▀▄",
118
+ ].join("\n"))
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Balboa
4
+ CONFIG_FILE = '.balboa.yml'.freeze
5
+ end
@@ -5,9 +5,13 @@ module Balboa
5
5
  class CapybaraInteractor
6
6
 
7
7
  CommandNotFound = Class.new(RuntimeError)
8
- LoginCommandNotFound = Class.new(CommandNotFound)
9
8
 
10
- def initialize
9
+ LoginCommandNotFound = Class.new(RuntimeError)
10
+
11
+ attr_reader :options
12
+
13
+ def initialize(options={})
14
+ @options = options
11
15
  @commands = Hash.new { fail CommandNotFound }
12
16
  @signed_in = false
13
17
  end
@@ -18,13 +22,11 @@ module Balboa
18
22
 
19
23
  def last
20
24
  login unless signed_in?
21
-
22
25
  @commands['last'].execute
23
26
  end
24
27
 
25
28
  def punch(date)
26
29
  login unless signed_in?
27
-
28
30
  @commands['punch'].execute(date)
29
31
  end
30
32
 
@@ -8,6 +8,11 @@ module Balboa
8
8
  class FillPunchCommand
9
9
  include Capybara::DSL
10
10
 
11
+ TIME_TEMPLATE = '%02d:00'.freeze
12
+ SUCCESS_MESSAGE = 'Punch foi criado com sucesso.'.freeze
13
+
14
+ PunchCreationError = Class.new(RuntimeError)
15
+
11
16
  def initialize(options)
12
17
  @options = options
13
18
  end
@@ -30,25 +35,25 @@ module Balboa
30
35
 
31
36
  def fill_first_shift(date)
32
37
  fill_form(date, @options['start_at'], @options['lunch_at'])
33
-
34
- confirm
35
38
  end
36
39
 
37
40
  def fill_second_shift(date)
38
41
  fill_form(date, @options['restart_at'], @options['leave_at'])
39
-
40
- confirm
41
42
  end
42
43
 
43
44
  def fill_form(date, start_time, finish_time)
44
- fill_in 'punch[from_time]', with: start_time
45
- fill_in 'punch[to_time]', with: finish_time
45
+ fill_in 'punch[from_time]', with: TIME_TEMPLATE % start_time
46
+ fill_in 'punch[to_time]', with: TIME_TEMPLATE % finish_time
46
47
  fill_in 'punch[when_day]', with: date.to_s
47
48
  select @options['project'], from: 'punch[project_id]'
49
+
50
+ confirm
48
51
  end
49
52
 
50
53
  def confirm
51
54
  click_button 'Criar Punch'
55
+
56
+ fail PunchCreationError unless body[SUCCESS_MESSAGE]
52
57
  end
53
58
  end
54
59
  end
@@ -8,7 +8,7 @@ module Balboa
8
8
  class LoginCommand
9
9
  include Capybara::DSL
10
10
 
11
- SuccessMessage = 'Login efetuado com sucesso!'.freeze
11
+ SUCCESS_MESSAGE = 'Login efetuado com sucesso!'.freeze
12
12
 
13
13
  LoginFailure = Class.new(RuntimeError)
14
14
 
@@ -37,9 +37,8 @@ module Balboa
37
37
 
38
38
  def confirm
39
39
  click_button 'Sign in'
40
- find('p', text: SuccessMessage)
41
- rescue Capybara::ElementNotFound
42
- raise LoginFailure
40
+
41
+ fail LoginFailure unless body[SUCCESS_MESSAGE]
43
42
  end
44
43
  end
45
44
  end
@@ -12,9 +12,9 @@ module Balboa
12
12
  new(*args).create
13
13
  end
14
14
 
15
- def initialize(interactor, options)
16
- @interactor = interactor
15
+ def initialize(options)
17
16
  @options = options
17
+ @interactor = Balboa::Interactor::CapybaraInteractor.new(options)
18
18
  end
19
19
 
20
20
  def create
@@ -14,6 +14,10 @@ module Balboa
14
14
  def last
15
15
  @interactor.last
16
16
  end
17
+
18
+ def options
19
+ @interactor.options
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Balboa
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.3'.freeze
5
5
  end
data/lib/balboa.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'balboa/version'
4
+ require_relative 'balboa/config_file'
4
5
  require_relative 'balboa/host'
5
6
 
6
7
  require_relative 'balboa/interactor/capybara_interactor'
@@ -12,9 +13,10 @@ require_relative 'balboa/interactor/command/login_command'
12
13
 
13
14
  require_relative 'balboa/cli/application'
14
15
  require_relative 'balboa/cli/options'
16
+ require_relative 'balboa/cli/defaults'
15
17
  require_relative 'balboa/cli/command/last_command'
16
18
  require_relative 'balboa/cli/command/punch_command'
17
- require_relative 'balboa/cli/command/help_command'
19
+ require_relative 'balboa/cli/command/reset_command'
18
20
  require_relative 'balboa/cli/command/star_wars_command'
19
21
 
20
22
  require 'phantomjs'
@@ -28,8 +28,8 @@ describe Balboa::Interactor::CapybaraInteractor do
28
28
  it 'responds to last but raises if no command provided' do
29
29
  interactor = described_class.new
30
30
 
31
- last = double('cmd', execute: true)
32
- login = double('login', execute: true)
31
+ last = double('cmd', execute: nil)
32
+ login = double('login', execute: nil)
33
33
 
34
34
  interactor.add_command('login', login)
35
35
 
@@ -39,6 +39,12 @@ describe Balboa::Interactor::CapybaraInteractor do
39
39
  }.to raise_error error
40
40
  end
41
41
 
42
+ it 'holds the options so commands can use it' do
43
+ interactor = described_class.new(a: 1, b: 2)
44
+
45
+ expect(interactor.options).to eq(a: 1, b: 2)
46
+ end
47
+
42
48
  it 'responds to punch but raises if no command provided' do
43
49
  interactor = described_class.new
44
50
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Balboa::Interactor::InteractorWrapper do
6
+ it 'forwards punch call to its dependency' do
7
+ today = Date.today
8
+
9
+ interactor = double
10
+ allow(interactor).to receive(:punch).with(today)
11
+
12
+ described_class.new(interactor).punch(today)
13
+
14
+ expect(interactor).to have_received(:punch).with(today).once
15
+ end
16
+
17
+ it 'forwards last call to its dependency' do
18
+ interactor = double
19
+ allow(interactor).to receive(:last)
20
+
21
+ described_class.new(interactor).last
22
+
23
+ expect(interactor).to have_received(:last).once
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balboa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Waldyr de Souza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.1.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.7.8
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.7.8
55
+ - !ruby/object:Gem::Dependency
56
+ name: holidays
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.6.0
41
69
  description: Make Balboa do the punches for you
42
70
  email:
43
71
  - waldyr.ar@gmail.com
@@ -66,8 +94,12 @@ files:
66
94
  - lib/balboa/cli/command/help_command.rb
67
95
  - lib/balboa/cli/command/last_command.rb
68
96
  - lib/balboa/cli/command/punch_command.rb
97
+ - lib/balboa/cli/command/reset_command.rb
69
98
  - lib/balboa/cli/command/star_wars_command.rb
99
+ - lib/balboa/cli/defaults.rb
70
100
  - lib/balboa/cli/options.rb
101
+ - lib/balboa/cli/parser_builder.rb
102
+ - lib/balboa/config_file.rb
71
103
  - lib/balboa/host.rb
72
104
  - lib/balboa/interactor/capybara_interactor.rb
73
105
  - lib/balboa/interactor/command/fetch_last_punch_command.rb
@@ -76,8 +108,9 @@ files:
76
108
  - lib/balboa/interactor/interactor_builder.rb
77
109
  - lib/balboa/interactor/interactor_wrapper.rb
78
110
  - lib/balboa/version.rb
111
+ - spec/balboa/capybara_interactor_spec.rb
79
112
  - spec/balboa/cli/application_spec.rb
80
- - spec/balboa/interactor_spec.rb
113
+ - spec/balboa/interactor/interactor_wrapper_spec.rb
81
114
  - spec/balboa_spec.rb
82
115
  - spec/spec_helper.rb
83
116
  homepage: