Project

green_day

0.01
The project is in a healthy, maintained state
CLI tool for AtCoder and Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

GreenDay

Green Day creates workspaces and tests for Atcoder contests (日本語で解説した記事はこちら)

Installation

Add this line to your application's Gemfile:

gem 'green_day'

And then execute:

$ bundle

Or install it yourself as:

$ gem install green_day

Usage

login(this command stores your cookie as .cookie-store in current directory)

$ bundle exec green_day login

If you want to delete session, remove .cookie-store

This command creates directory and spec.

$ bundle exec green_day new <contest-name>

For example

$ bundle exec green_day new abc150
 abc150
 ├── A.rb
 ├── B.rb
 ├── C.rb
 ├── D.rb
 ├── E.rb
 ├── F.rb
 └── spec
     ├── A_spec.rb
     ├── B_spec.rb
     ├── C_spec.rb
     ├── D_spec.rb
     ├── E_spec.rb
     └── F_spec.rb

Example of output spec

RSpec.describe 'abc150/A.rb' do
  it 'test with "2 900\n"' do
    if ENV['GD_REPL']
      File.chmod(0o755, 'abc150/A.rb')
      system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "2 900\n\\004"; interact'))
    else
      io = IO.popen('ruby abc150/A.rb', 'w+')
      io.puts("2 900\n")
      io.close_write
      expect(io.readlines.join).to eq("Yes\n")
    end
  end

  it 'test with "1 501\n"' do
    if ENV['GD_REPL']
      File.chmod(0o755, 'abc150/A.rb')
      system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "1 501\n\\004"; interact'))
    else
      io = IO.popen('ruby abc150/A.rb', 'w+')
      io.puts("1 501\n")
      io.close_write
      expect(io.readlines.join).to eq("No\n")
    end
  end

  it 'test with "4 2000\n"' do
    if ENV['GD_REPL']
      File.chmod(0o755, 'abc150/A.rb')
      system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "4 2000\n\\004"; interact'))
    else
      io = IO.popen('ruby abc150/A.rb', 'w+')
      io.puts("4 2000\n")
      io.close_write
      expect(io.readlines.join).to eq("Yes\n")
    end
  end

end

Debugging with REPL

You can debug your code with sample input and REPL by setting GD_REPL environment variable.

$ GD_REPL=1 bundle exec rspec abc150/spec/A_spec.rb

abc150/A.rb
spawn ruby abc150/A.rb
2 900

From: abc150/A.rb @ line 2 :

    1: a, b = gets.split.map(&:to_i)
 => 2: binding.irb
    3: puts "Yes"

irb(main):001:0> a
=> 2

Development

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/QWYNG/green_day. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the GreenDay project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.