balboa 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.balboa +16 -0
- data/.gitignore +9 -0
- data/.reek +2 -0
- data/.rspec +2 -0
- data/.rubocop.yml +4 -0
- data/.ruby-version +1 -0
- data/.travis.yml +27 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +49 -0
- data/balboa.gemspec +25 -0
- data/bin/balboa +30 -0
- data/bin/setup +6 -0
- data/features/support/env.rb +0 -0
- data/lib/balboa/cli/application.rb +24 -0
- data/lib/balboa/cli/command/last_punch_command.rb +17 -0
- data/lib/balboa/cli/command/make_punch_command.rb +42 -0
- data/lib/balboa/cli/command/star_wars_command.rb +13 -0
- data/lib/balboa/cli/options.rb +59 -0
- data/lib/balboa/interactor/capybara_interactor.rb +31 -0
- data/lib/balboa/interactor/command/last_punch_command.rb +29 -0
- data/lib/balboa/interactor/command/login_command.rb +40 -0
- data/lib/balboa/interactor/command/make_punch_command.rb +56 -0
- data/lib/balboa/interactor/interactor_wrapper.rb +19 -0
- data/lib/balboa/version.rb +5 -0
- data/lib/balboa.rb +24 -0
- data/spec/balboa_spec.rb +9 -0
- data/spec/spec_helper.rb +4 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6389777f55125e6e113361c58984288e122714a4
|
4
|
+
data.tar.gz: fe40b61a04a5d5651a2577ca8ca2055d4b83025b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a60125e822c062ecac8c71f79603c178a5491f9e421ba1bf0072cf1f1bba12637b54a01dfeed51a496471e45794e5ca0de38531fe9aaca1590b991ce86e799b9
|
7
|
+
data.tar.gz: 0bf06f570bd1ff882f52f7c49061483a4b060b0d3a264975e47193092c86257da9a638584312ce373252bddcc8b782a0ea5e2f3f709b73771c3d0e86fd38d9df
|
data/.balboa
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
email: waldyr.araujo@codeminer42.com
|
3
|
+
password: waldyr.araujo@codeminer42.com
|
4
|
+
project: 'API Market Place'
|
5
|
+
start_at: '08:00'
|
6
|
+
lunch_at: '12:00'
|
7
|
+
restart_at: '13:00'
|
8
|
+
leave_at: '17:00'
|
9
|
+
holidays:
|
10
|
+
- 12/06/1992
|
11
|
+
- 12/06/1992
|
12
|
+
- 12/06/1992
|
13
|
+
- 12/06/1992
|
14
|
+
- 12/06/1992
|
15
|
+
- 12/06/1992
|
16
|
+
- 12/06/1992
|
data/.gitignore
ADDED
data/.reek
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
sudo: false
|
2
|
+
cache: bundler
|
3
|
+
language: ruby
|
4
|
+
script: bundle exec rake ci
|
5
|
+
rvm:
|
6
|
+
- 2.3.0
|
7
|
+
- 2.2
|
8
|
+
- 2.1
|
9
|
+
- 2.0
|
10
|
+
matrix:
|
11
|
+
include:
|
12
|
+
- rvm: jruby
|
13
|
+
env: JRUBY_OPTS='--2.0 --server -Xcompile.invokedynamic=false'
|
14
|
+
- rvm: jruby-head
|
15
|
+
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
|
16
|
+
allow_failures:
|
17
|
+
- rvm: jruby
|
18
|
+
- rvm: jruby-head
|
19
|
+
- rvm: rbx-2
|
20
|
+
- rvm: ruby-head
|
21
|
+
- rvm: 1.9.3
|
22
|
+
- rvm: 1.9.2
|
23
|
+
- rvm: 1.8.7
|
24
|
+
fast_finish: true
|
25
|
+
branches:
|
26
|
+
only:
|
27
|
+
- master
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at waldyr.ar@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem 'reek', '~> 4.2.0'
|
8
|
+
gem 'rspec', '~> 3.0'
|
9
|
+
gem 'cucumber', '~> 2.0'
|
10
|
+
gem 'rubocop', '~> 0.41.1'
|
11
|
+
gem 'mutant-rspec', '~> 0.8.8'
|
12
|
+
|
13
|
+
gem 'rake', '~> 10.0'
|
14
|
+
|
15
|
+
gem 'capybara', '~> 2.7.1'
|
16
|
+
gem 'poltergeist', '~> 1.10.0'
|
17
|
+
gem 'phantomjs', '~> 2.1.1.0', require: 'phantomjs/poltergeist'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Waldyr de Souza
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Balboa
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/balboa`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'balboa'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install balboa
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/balboa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
require 'reek/rake/task'
|
8
|
+
require 'cucumber/rake/task'
|
9
|
+
|
10
|
+
namespace :quality do
|
11
|
+
Reek::Rake::Task.new do |t|
|
12
|
+
t.fail_on_error = true
|
13
|
+
t.verbose = false
|
14
|
+
end
|
15
|
+
|
16
|
+
RuboCop::RakeTask.new do |t|
|
17
|
+
t.options << '--display-cop-names'
|
18
|
+
end
|
19
|
+
|
20
|
+
task all: [:rubocop, :reek]
|
21
|
+
end
|
22
|
+
|
23
|
+
namespace :test do
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
25
|
+
|
26
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
27
|
+
t.cucumber_opts = 'features --format progress --color'
|
28
|
+
end
|
29
|
+
|
30
|
+
task :mutant do
|
31
|
+
command = <<-EOS
|
32
|
+
RUBY_THREAD_VM_STACK_SIZE=64000\
|
33
|
+
bundle exec mutant\
|
34
|
+
--include lib\
|
35
|
+
--require balboa\
|
36
|
+
--use rspec\
|
37
|
+
--since master\
|
38
|
+
--jobs 4 'Balboa*'
|
39
|
+
EOS
|
40
|
+
system command
|
41
|
+
abort unless $CHILD_STATUS.success?
|
42
|
+
end
|
43
|
+
|
44
|
+
task all: ['test:spec', 'test:features', :mutant]
|
45
|
+
end
|
46
|
+
|
47
|
+
task ci: ['test:all', 'quality:all']
|
48
|
+
|
49
|
+
task default: :ci
|
data/balboa.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'balboa/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = 'balboa'
|
10
|
+
s.version = Balboa::VERSION
|
11
|
+
s.authors = ['Waldyr de Souza']
|
12
|
+
s.email = ['waldyr.ar@gmail.com']
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.summary = 'Make Balboa do the punches for you'
|
16
|
+
s.description = s.summary
|
17
|
+
|
18
|
+
s.files = `git ls-files -z`.split("\x0")
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.executables = ['balboa']
|
21
|
+
|
22
|
+
s.default_executable = 'balboa'
|
23
|
+
|
24
|
+
s.required_ruby_version = '>= 2.1.0'
|
25
|
+
end
|
data/bin/balboa
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../lib/balboa'
|
5
|
+
|
6
|
+
command = ARGV.shift || 'make_punch'
|
7
|
+
app = Balboa::CLI::Application.new(command)
|
8
|
+
options = Balboa::CLI::Options.parse(ARGV)
|
9
|
+
|
10
|
+
crawler = Balboa::Interactor::CapybaraInteractor.new(options)
|
11
|
+
|
12
|
+
crawler_last_punch = Balboa::Interactor::Command::LastPunchCommand.new
|
13
|
+
crawler_make_punch = Balboa::Interactor::Command::MakePunchCommand.new(options)
|
14
|
+
crawler_login = Balboa::Interactor::Command::LoginCommand.new(options)
|
15
|
+
|
16
|
+
crawler.add_command :last_punch, crawler_last_punch
|
17
|
+
crawler.add_command :make_punch, crawler_make_punch
|
18
|
+
crawler.add_command :login, crawler_login
|
19
|
+
|
20
|
+
interactor = Balboa::Interactor::InteractorWrapper.new(crawler)
|
21
|
+
|
22
|
+
app_last_punch = Balboa::CLI::Command::LastPunchCommand.new(interactor)
|
23
|
+
app_make_punch = Balboa::CLI::Command::MakePunchCommand.new(interactor, options['holidays'])
|
24
|
+
app_star_wars = Balboa::CLI::Command::StarWarsCommand.new
|
25
|
+
|
26
|
+
app.add_command :last_punch, app_last_punch
|
27
|
+
app.add_command :make_punch, app_make_punch
|
28
|
+
app.add_command :star_wars, app_star_wars
|
29
|
+
|
30
|
+
puts app.execute
|
data/bin/setup
ADDED
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'options'
|
4
|
+
|
5
|
+
module Balboa
|
6
|
+
module CLI
|
7
|
+
class Application
|
8
|
+
CommandNotFound = Class.new(RuntimeError)
|
9
|
+
|
10
|
+
def initialize(command_id)
|
11
|
+
@command_id = command_id.to_s
|
12
|
+
@commands = Hash.new { fail CommandNotFound }
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_command(key, command)
|
16
|
+
@commands[key.to_s] = command
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
@commands[@command_id].execute
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Balboa
|
4
|
+
module CLI
|
5
|
+
module Command
|
6
|
+
class MakePunchCommand
|
7
|
+
def initialize(interactor, holidays)
|
8
|
+
@interactor = interactor
|
9
|
+
@holidays = holidays.uniq.map { |holiday| Date.parse(holiday) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
punch_dates.each do |date|
|
14
|
+
if date.saturday? || date.sunday?
|
15
|
+
$stdout.puts "#{date} # WEEKEND"
|
16
|
+
elsif holiday?(date)
|
17
|
+
$stdout.puts "#{date} # HOLIDAY"
|
18
|
+
else
|
19
|
+
@interactor.punch(date)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def punch_dates
|
27
|
+
yesterday = Date.today - 1
|
28
|
+
|
29
|
+
(last_punch_date..yesterday)
|
30
|
+
end
|
31
|
+
|
32
|
+
def holiday?(date)
|
33
|
+
@holidays.include?(date)
|
34
|
+
end
|
35
|
+
|
36
|
+
def last_punch_date
|
37
|
+
Date.parse(@interactor.last_punch) + 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Balboa
|
7
|
+
module CLI
|
8
|
+
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
|
16
|
+
rescue OptionParser::InvalidOption => error
|
17
|
+
$stderr.puts "Error: #{error}"
|
18
|
+
exit ERROR_EXIT_CODE
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(shifted_argv)
|
22
|
+
@parser = OptionParser.new(shifted_argv)
|
23
|
+
@config = Hash.new { fail MissingOptionError }
|
24
|
+
|
25
|
+
configure_parser
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse
|
29
|
+
@parser.parse!
|
30
|
+
|
31
|
+
@config
|
32
|
+
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('-d', '--data PARAMS') do |data|
|
54
|
+
@config.merge!(data)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Balboa
|
4
|
+
module Interactor
|
5
|
+
class CapybaraInteractor
|
6
|
+
def initialize(options)
|
7
|
+
@options = options
|
8
|
+
@commands = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_command(key, command)
|
12
|
+
@commands[key.to_s] = command
|
13
|
+
end
|
14
|
+
|
15
|
+
def last_punch
|
16
|
+
login
|
17
|
+
@commands['last_punch'].execute
|
18
|
+
end
|
19
|
+
|
20
|
+
def punch(date)
|
21
|
+
@commands['make_punch'].execute(date)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def login
|
27
|
+
@commands['login'].execute
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capybara/dsl'
|
4
|
+
|
5
|
+
module Balboa
|
6
|
+
module Interactor
|
7
|
+
module Command
|
8
|
+
class LastPunchCommand
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
def execute
|
12
|
+
punches_path
|
13
|
+
|
14
|
+
find_last_punch_date
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def punches_path
|
20
|
+
visit('/punches')
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_last_punch_date
|
24
|
+
find('tbody tr:first-child td:nth-child(2)').text
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capybara/dsl'
|
4
|
+
|
5
|
+
module Balboa
|
6
|
+
module Interactor
|
7
|
+
module Command
|
8
|
+
class LoginCommand
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
visit_sign_in_path
|
17
|
+
|
18
|
+
fill_form
|
19
|
+
|
20
|
+
confirm
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def visit_sign_in_path
|
26
|
+
visit('/users/sign_in')
|
27
|
+
end
|
28
|
+
|
29
|
+
def fill_form
|
30
|
+
fill_in 'E-mail', with: @options['email']
|
31
|
+
fill_in 'Password', with: @options['password']
|
32
|
+
end
|
33
|
+
|
34
|
+
def confirm
|
35
|
+
click_button 'Sign in'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capybara/dsl'
|
4
|
+
|
5
|
+
module Balboa
|
6
|
+
module Interactor
|
7
|
+
module Command
|
8
|
+
class MakePunchCommand
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute(date)
|
16
|
+
visit_new_punch_path
|
17
|
+
|
18
|
+
fill_first_shift(date)
|
19
|
+
|
20
|
+
visit_new_punch_path
|
21
|
+
|
22
|
+
fill_second_shift(date)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def visit_new_punch_path
|
28
|
+
visit('/punches/new')
|
29
|
+
end
|
30
|
+
|
31
|
+
def fill_first_shift(date)
|
32
|
+
fill_form(date, @options['start_at'], @options['lunch_at'])
|
33
|
+
|
34
|
+
confirm
|
35
|
+
end
|
36
|
+
|
37
|
+
def fill_second_shift(date)
|
38
|
+
fill_form(date, @options['restart_at'], @options['leave_at'])
|
39
|
+
|
40
|
+
confirm
|
41
|
+
end
|
42
|
+
|
43
|
+
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
|
46
|
+
fill_in 'punch[when_day]', with: date.to_s
|
47
|
+
select @options['project'], from: 'punch[project_id]'
|
48
|
+
end
|
49
|
+
|
50
|
+
def confirm
|
51
|
+
click_button 'Criar Punch'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Balboa
|
4
|
+
module Interactor
|
5
|
+
class InteractorWrapper
|
6
|
+
def initialize(interactor)
|
7
|
+
@interactor = interactor
|
8
|
+
end
|
9
|
+
|
10
|
+
def punch(date)
|
11
|
+
@interactor.punch(date)
|
12
|
+
end
|
13
|
+
|
14
|
+
def last_punch
|
15
|
+
@interactor.last_punch
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/balboa.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'balboa/version'
|
4
|
+
|
5
|
+
require_relative 'balboa/interactor/capybara_interactor'
|
6
|
+
require_relative 'balboa/interactor/interactor_wrapper'
|
7
|
+
require_relative 'balboa/interactor/command/last_punch_command'
|
8
|
+
require_relative 'balboa/interactor/command/make_punch_command'
|
9
|
+
require_relative 'balboa/interactor/command/login_command'
|
10
|
+
|
11
|
+
require_relative 'balboa/cli/application'
|
12
|
+
require_relative 'balboa/cli/command/last_punch_command'
|
13
|
+
require_relative 'balboa/cli/command/make_punch_command'
|
14
|
+
require_relative 'balboa/cli/command/star_wars_command'
|
15
|
+
|
16
|
+
require 'phantomjs'
|
17
|
+
require 'capybara/poltergeist'
|
18
|
+
|
19
|
+
Capybara.register_driver :poltergeist do |app|
|
20
|
+
Capybara::Poltergeist::Driver.new(app, phantomjs: Phantomjs.path)
|
21
|
+
end
|
22
|
+
Capybara.default_driver = :poltergeist
|
23
|
+
Capybara.run_server = false
|
24
|
+
Capybara.app_host = 'http://punchclock.cm42.io/'
|
data/spec/balboa_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: balboa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Waldyr de Souza
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Make Balboa do the punches for you
|
14
|
+
email:
|
15
|
+
- waldyr.ar@gmail.com
|
16
|
+
executables:
|
17
|
+
- balboa
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".balboa"
|
22
|
+
- ".gitignore"
|
23
|
+
- ".reek"
|
24
|
+
- ".rspec"
|
25
|
+
- ".rubocop.yml"
|
26
|
+
- ".ruby-version"
|
27
|
+
- ".travis.yml"
|
28
|
+
- CODE_OF_CONDUCT.md
|
29
|
+
- Gemfile
|
30
|
+
- LICENSE.txt
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- balboa.gemspec
|
34
|
+
- bin/balboa
|
35
|
+
- bin/setup
|
36
|
+
- features/support/env.rb
|
37
|
+
- lib/balboa.rb
|
38
|
+
- lib/balboa/cli/application.rb
|
39
|
+
- lib/balboa/cli/command/last_punch_command.rb
|
40
|
+
- lib/balboa/cli/command/make_punch_command.rb
|
41
|
+
- lib/balboa/cli/command/star_wars_command.rb
|
42
|
+
- lib/balboa/cli/options.rb
|
43
|
+
- lib/balboa/interactor/capybara_interactor.rb
|
44
|
+
- lib/balboa/interactor/command/last_punch_command.rb
|
45
|
+
- lib/balboa/interactor/command/login_command.rb
|
46
|
+
- lib/balboa/interactor/command/make_punch_command.rb
|
47
|
+
- lib/balboa/interactor/interactor_wrapper.rb
|
48
|
+
- lib/balboa/version.rb
|
49
|
+
- spec/balboa_spec.rb
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
homepage:
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 2.1.0
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 2.6.4
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Make Balboa do the punches for you
|
75
|
+
test_files: []
|
76
|
+
has_rdoc:
|