Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sue445/itest5ch

5ch (a.k.a. 2ch) reader via itest.5ch.net
https://github.com/sue445/itest5ch

2ch 5ch gem

Last synced: 6 days ago
JSON representation

5ch (a.k.a. 2ch) reader via itest.5ch.net

Awesome Lists containing this project

README

        

# Itest5ch

5ch (a.k.a. 2ch) reader via http://itest.5ch.net/

[![Gem Version](https://badge.fury.io/rb/itest5ch.svg)](https://badge.fury.io/rb/itest5ch)
[![test](https://github.com/sue445/itest5ch/actions/workflows/test.yml/badge.svg)](https://github.com/sue445/itest5ch/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/sue445/itest5ch/badge.svg)](https://coveralls.io/github/sue445/itest5ch)
[![Maintainability](https://api.codeclimate.com/v1/badges/14a81b3f7da11e475242/maintainability)](https://codeclimate.com/github/sue445/itest5ch/maintainability)

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'itest5ch'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install itest5ch

## Usage

### [Itest5ch::Board](lib/itest5ch/board.rb)

#### Get all boards

```ruby
category_boards = Itest5ch::Board.all
#=> {"地震"=>
[#,
#,
#,
#,
#],
"おすすめ"=>
[#,
#,
#,
#,
#,
#,
#,
#],
```

#### Get boards of a category

```ruby
boards = Itest5ch::Board.find_category_boards("おすすめ")
#=> [#,
#,
#,
#,
#,
#,
#,
#]
```

#### Get a board
```ruby
board = Itest5ch::Board.find("スマートフォン")

# or

board = Itest5ch::Board.find("smartphone")
```

### [Itest5ch::Thread](lib/itest5ch/thread.rb)
#### Get threads
```ruby
threads = board.threads
```

#### Get a thread
```ruby
# with PC url
thread = Itest5ch::Thread.new("http://egg.5ch.net/test/read.cgi/smartphone/0000000000")

# or

# with Smartphone url
thread = Itest5ch::Thread.new("http://itest.5ch.net/egg/test/read.cgi/smartphone/0000000000")
```

### [Itest5ch::Comment](lib/itest5ch/comment.rb)
```ruby
comments = thread.comments
```

### [Itest5ch::Config](lib/itest5ch/config.rb)
```ruby
Itest5ch.config.user_agent = "XXXX"
```

* `user_agent` : User Agent

## ProTip
When `Time.zone` is initialized, `Itest5ch::Comment#date` returns `ActiveSupport::TimeWithZone` instead of `Time` (requirements `activesupport`)

```ruby
comment.date
#=> 2018-03-06 12:34:56 +0900
comment.date.class
#=> Time
```

```ruby
require "active_support/time"
Time.zone = "Tokyo"

comment.date
#=> Tue, 06 Mar 2018 12:34:56 JST +09:00
comment.date.class
#=> ActiveSupport::TimeWithZone
```

## 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](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/itest5ch.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).