lift

Testing json data using Specs2

落花浮王杯 提交于 2021-02-09 18:37:28
问题 I added(In built.sbt) matcher-extra :- "org.specs2" %% "specs2" % "2.3.4" % "test", "org.specs2" % "specs2-matcher-extra_2.10" % "2.3-scalaz-7.1.0-M3", the ("/" the symbols are not resolving) My example test case for Json is looking like below:- package specs.model import org.specs2.mutable.Specification import org.specs2.matcher.JsonMatchers class Json extends Specification with JsonMatchers { "Json Matcher" should { "1st field" in { val json = """{"name":"sagar"}""" json must /("name" ->

RxJava之subscribeOn解惑

不羁的心 提交于 2020-03-02 04:37:28
RxJava之subscribeOn解惑 有一天,我在使用RxJava和Retrofit实现Android上面的网络请求。突然,遇到了一个坑,在过了这些坑之后得到一些经验,觉得需要和大家分享一二。 引子 用Retrofit搭配RxJava的朋友应该都知道,一般实现代码最终大都长得一幅下面的样子。 public interface BeanApi { @GET("bean/{id}") Observable<Bean> getBean(@Path("id") int beanId); } BeanApi api = ···通过Retrofit的create实例化··· api.getBean(1) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( bean -> { // do something on main thread. }, throwable -> { // do something on main thread. } ); 上面的代码形式相信各位都写得很熟了,但是我实在烦透了每个api调用的地方都写一次subscribOn,observeOn。然后,我找到一篇不错的文章—— Don't break the chain: use RxJava's

002-搭建Liftweb项目

落花浮王杯 提交于 2020-03-02 04:31:48
搭建Lift项目 sbt -> sbt + jetty -> sbt + jetty + lift 本章的示例代码在: http://git.oschina.net/yangbajing/lift-book/tree/master/examples/lift-blank 安装Sbt 详细内容请读 附录A. 使用Sbt 创建sbt工程 现在我们重头开始建立一个lift项目,首先需要创建一个sbt工程。我们建立工程目录在: /data/lift-book/examples/lift-blank ,并建立目录结构如下: . ├── project │ ├── Build.scala │ ├── BuildSettings.scala │ ├── Dependencies.scala │ └── plugins.sbt ├── sbt ├── sbt-launch-0.13.0.jar ├── sbt.bat └── src ├── main │ ├── scala │ │ ├── bootstrap │ │ │ └── liftweb │ │ │ └── Boot.scala │ │ └── code │ │ ├── comet/ │ │ ├── helper/ │ │ ├── model/ │ │ └── snippet/ │ └── webapp │ └── WEB-INF │ └─

Liftweb Menu customization

好久不见. 提交于 2020-01-30 23:27:10
问题 I want to create a menu that looks like: HOME | FOO | BAR | ABOUT | CONTACT How might I go about doing this? Here is what I have tried: <lift:Menu.builder ul:class="menu" li_item:class="current" /> and ul.menu li { display: inline; list-style-type: none; text-transform: uppercase; border-right: 1px solid white; padding-right: 5px; } li.current span { background: white; color: black; padding: 5px 5px 3px 5px; font-size: 11px; } li.current a, a:visited, a:link { color: white; padding: 5px 5px

How do I idiomatically handle null checks from within Scala/Lift?

爱⌒轻易说出口 提交于 2020-01-29 07:02:31
问题 Even with the prevalence of the Box and Option monads, we still have to check for null values here and there. The best I've come up with so far is by using the Box#!! method: (Box !! possiblyNull).map(_.toString).openOr("") Is there a better way to do this? I tried using Box's apply method: Box(possiblyNull).map(_.toString).openOr("") But the compiler complained of an ambiguous reference to an overloaded definition, specifically: [InType,OutType](value: InType) (pf: PartialFunction[InType

How do I idiomatically handle null checks from within Scala/Lift?

好久不见. 提交于 2020-01-29 07:00:12
问题 Even with the prevalence of the Box and Option monads, we still have to check for null values here and there. The best I've come up with so far is by using the Box#!! method: (Box !! possiblyNull).map(_.toString).openOr("") Is there a better way to do this? I tried using Box's apply method: Box(possiblyNull).map(_.toString).openOr("") But the compiler complained of an ambiguous reference to an overloaded definition, specifically: [InType,OutType](value: InType) (pf: PartialFunction[InType

How to use logback on Cloudbees

青春壹個敷衍的年華 提交于 2020-01-23 03:34:25
问题 I would like to know if it's possible to use my own logback configuration on Cloubees, I have a default.logback.xml file that works perfectly fine in local, but once I deploy to Cloudbees its being ignored. 回答1: Logging in CloudBees is via stdout and stderror - these are piped via syslog-ng to various systems (not all of which are file based) - so you can configure logging things as you want - but if you want your logs managed - it is best to ensure that things end up in stdout and stderr. 来源

scala/liftweb serializing json

跟風遠走 提交于 2020-01-16 18:34:18
问题 I am using net.liftweb parser for scala I have a json like this { "k1":"v1", "k2":["v21", "v22", "v23"] } k2 is an optional field, json might or might not have it. I extract this into a case class case class MyCC (k1: String, k2: List[String]) When json is converted to case class, if k2 is not present then it is deserialized into empty list. The issue is while converting back to json, how could i make the parser not serialize this field if it is an empty list. 回答1: You should create custom

Using Lift-Json with Case Classes

倾然丶 夕夏残阳落幕 提交于 2020-01-16 18:05:51
问题 I can't seem to write proper case classes for this particular Json payload. I believe it has something to do with the first index in the array, which doesn't have a key string. Any ideas on how to remedy this? For reference, I am using Scala 2.10.4, Akka 2.3.2, Spray 1.3.1 and Lift-Json 2.6. The Json I am attempting to extract is from Mailgun's Events API. Edit: the core question is how do I extract to a case class with no key in the Json? My code follows: import net.liftweb.json._ case class

Keep text in lift snippet

北战南征 提交于 2020-01-16 12:28:37
问题 there is a lift snippet: <lift:Login> <entry:name> No user logged in </entry:name> </lift:Login> I know that I can Helpers.bind the user name if the user is logged in, but how can I preserve the former text enclosed in ? There seems to be no support to project prefixed elements when I see scala api, xhtml \\ "entry:name" yields nothing more than empty Node. So how can I accomplish such goal? EDIT: In case when the user is logged, I want to show: User 123 In the other case, I want to show the