rubyist

A scala goodies for rubyist

License

License

Categories

Categories

Ruby Languages
GroupId

GroupId

sc.ala
ArtifactId

ArtifactId

rubyist_2.11
Last Version

Last Version

0.2.6
Release Date

Release Date

Type

Type

jar
Description

Description

rubyist
A scala goodies for rubyist
Project URL

Project URL

https://github.com/maiha/rubyist
Project Organization

Project Organization

sc.ala
Source Code Management

Source Code Management

https://github.com/maiha/rubyist

Download rubyist_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/sc.ala/rubyist_2.11/ -->
<dependency>
    <groupId>sc.ala</groupId>
    <artifactId>rubyist_2.11</artifactId>
    <version>0.2.6</version>
</dependency>
// https://jarcasting.com/artifacts/sc.ala/rubyist_2.11/
implementation 'sc.ala:rubyist_2.11:0.2.6'
// https://jarcasting.com/artifacts/sc.ala/rubyist_2.11/
implementation ("sc.ala:rubyist_2.11:0.2.6")
'sc.ala:rubyist_2.11:jar:0.2.6'
<dependency org="sc.ala" name="rubyist_2.11" rev="0.2.6">
  <artifact name="rubyist_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='sc.ala', module='rubyist_2.11', version='0.2.6')
)
libraryDependencies += "sc.ala" % "rubyist_2.11" % "0.2.6"
[sc.ala/rubyist_2.11 "0.2.6"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-compiler jar 2.11.7
org.scala-lang : scala-library jar 2.11.7
commons-io : commons-io jar 2.4

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 2.2.1
org.scalamock : scalamock-scalatest-support_2.11 jar 3.2

Project Modules

There are no modules declared in this project.

Build Status Maven Central

rubyist

A scala goodies for rubyist.

Features

This provides following features those are well-known to rubyist.

  • using
  • Object#tap
  • Int#times
  • rescue
  • md5
  • Pathname#{read,write}
  • Hashname
  • Host,CurrentHost
  • String#chomp
  • Tempfile
  • NKF

Usage

using

import sc.ala.rubyist.Using._
import java.io.ByteArrayOutputStream
using(new ByteArrayOutputStream) { out =>
  ...
}
// out.close() will be automatically called

Object#tap

import sc.ala.rubyist.Tap._
val props = new java.util.Properties().tap{_.put("port", "80")}
// => java.util.Properties = {port=80}

Int#times

import sc.ala.rubyist.Times._
3 times { println("ok") }

rescue

import sc.ala.rubyist.Rescue._
val num = "1".toInt           // => 1
val num = "x".toInt           // java.lang.NumberFormatException
val num = "x".toInt rescue 0  // => 0

md5

import sc.ala.rubyist.Digest
Digest.MD5.hexdigest("ruby") // => "58e53d1324eef6265fdb97b08ed9aadf"

Pathname

import sc.ala.rubyist.Pathname
val log = Pathname("log/langs.txt")
log.exists           // => false
log.parent.mkpath
log.write("Ruby\nScala")
log.exists           // => true
log.read()           // => "Ruby\nScala"
log.readlines()      // => List("Ruby", "Scala")

Pathname("hello.txt.sjis", "Shift_JIS").read  // with charset

Hashname

import sc.ala.rubyist.Hashname
val hash = Hashname("data/users/910.xml")
hash.path         // => "data/users/e/20/5ee/e205ee2a5de471a70c1fd1b46033a75f/910.xml"
hash.write("...") // write given string into above file

Host,CurrentHost

import sc.ala.rubyist.CurrentHost
CurrentHost.name     // => moa
CurrentHost.address  // => 192.168.1.5

String#chomp

import sc.ala.rubyist.String._
"abc\n".chomp  // => "abc"

Tempfile

import sc.ala.rubyist.Tempfile
Tempfile("foo"){ tmp:Pathname =>
  tmp.write("hello")
}

NKF

  • This module directly invokes "nkf" external program, so it should be installed.
import sc.ala.rubyist.NKF
val utf8_text = NKF.nkf("-w", sjis_text)

Required

  • tested on scala 2.11.7

Authors: [email protected] Links: http://github.com/maiha/rubyist (forked from s21g/rubyist)

Versions

Version
0.2.6