<commit_before>import net.databinder.dispatch._

val couch = new Http("localhost", 5984)

object Person extends Doc {
  val name = String('name) 
  val age = Int('age)
  val pets = List[java.lang.String]('pets)
  
  val obj = new Object('objective) {
    val acc = String('accomplished)
  }
}

var p = couch("/people/nathan") >> { new Store(_) }

p = (p << Person.name)(Some("Nathan"))

p = couch("/people/nathan") <<: Revise(p)<commit_msg>scratching<commit_after>// http://minformix.org/blog/index.php?/archives/91-Scala-Querying-an-objects-fields-and-methods-with-reflection.html
import scala.Console._  
import scala.tools.nsc.util.NameTransformer._  
  
class AnyExtras(x: Any) {  
  def methods = methods__.foreach(println _)  
  def fields = fields__.foreach(println _)  
    
  def methods__ = wrapped.getClass  
      .getMethods  
      .toList  
      .map(m => decode(m.toString  
                        .replaceFirst("\\).*", ")")  
                        .replaceAll("[^(]+\\.", "")  
                        .replace("()", "")))  
      .filter(!_.startsWith("$tag"))  
    
  def fields__ = wrapped.getClass  
      .getDeclaredFields  
      .toList  
      .map(m => decode(m.toString.replaceFirst("^.*\\.", "")))  
  
  private def wrapped: AnyRef = x match {  
    case x: Byte => byte2Byte(x)  
    case x: Short => short2Short(x)  
    case x: Char => char2Character(x)  
    case x: Int => int2Integer(x)  
    case x: Long => long2Long(x)  
    case x: Float => float2Float(x)  
    case x: Double => double2Double(x)  
    case x: Boolean => boolean2Boolean(x)  
    case _ => x.asInstanceOf[AnyRef]  
  }  
}  

implicit def any2anyExtras(x: Any) = new AnyExtras(x)  

// disp
import net.databinder.dispatch._

/*
val couch = new Http("localhost", 5984)
object Person extends Doc {
  val name = String('name) 
  val age = Int('age)
  val pets = List[java.lang.String]('pets)
  
  val obj = new Object('objective) {
    val acc = String('accomplished)
  }
}

var p = couch("/people/nathan") >> { new Store(_) }

p = (p << Person.name)(Some("Nathan"))

p = couch("/people/nathan") <<: Revise(p)
*/
{'fraction_non_alphanumeric': 0.16258246936852028, 'fraction_numerical': 0.008953817153628653, 'mean_word_length': 2.6166950596252128, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '106095', 'n_tokens_mistral': 753, 'n_tokens_neox': 736, 'n_words': 155}