This example uses thease projects:
The HtmlPageReader goes to html's page and transform that content with mochiweb_html.parse
defmodule Usecase.HtmlPageReader do
This example uses thease projects:
The HtmlPageReader goes to html's page and transform that content with mochiweb_html.parse
defmodule Usecase.HtmlPageReader do
| package com.opportunity.simple.restapi | |
| import javax.persistence.EntityManagerFactory | |
| import com.opportunity.objectives.model.User | |
| import com.opportunity.objectives.usecases.user.{ListUsersUsecase, LoginByFacebookUserUsecase, SaveNewUserUsecase} | |
| import com.opportunity.simple.restapi.response.ProtocolResponse | |
| import com.typesafe.config.Config | |
| class UserAPI(val apiConfig: Config, val entityManagerFactory: EntityManagerFactory) extends Respondable with Authenticable with PersistibleUser { |
| package com.opportunity.objectives.usecases.user | |
| import com.opportunity.objectives.exceptions.UserInvalidException | |
| import com.opportunity.objectives.model.{Friend, User} | |
| import com.opportunity.objectives.persistence.adapter.user.NewUserPersistenceAdapter | |
| class SaveNewFriendsUsecase(persistenceAdapter: NewUserPersistenceAdapter) { | |
| def save(user:User, friends:List[Friend]): User = { | |
| persistenceAdapter.findUserById(user.id) match { |
| /** | |
| * https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html | |
| * https://vimeo.com/43612849 | |
| * https://etorreborre.github.io/specs2/guide/SPECS2-3.7/org.specs2.guide.Matchers.html | |
| * | |
| **/ | |
| package com.opportunity.objectives.usecases.user | |
| import com.opportunity.objectives.exceptions.UserInvalidException | |
| import com.opportunity.objectives.model.{Friend, User} |
| Code.eval_quoted( | |
| quote do: unquote(1) + unquote(1 + 1) | |
| ) | |
| #code to be parsed 1 + (1 + 1) | |
| #result of execution {3, []} |
| def main(args: Array[String]) { | |
| val port = restApiConfig.getInt("port") | |
| println(restApiConfig.getString("resourceBase")) | |
| val server = new Server(port) | |
| val context = new WebAppContext() | |
| context setContextPath "/" | |
| context.setResourceBase(restApiConfig.getString("resourceBase")) | |
| context.setInitParameter(ScalatraListener.LifeCycleKey, "com.opportunity.simple.restapi.ScalatraBootstrap") | |
| context.addEventListener(new ScalatraListener) |
| package com.opportunity.simple.restapi.user | |
| import com.opportunity.simple.restapi.basic.BasicBehaviour | |
| class UserSpec extends BasicBehaviour { | |
| "The user endpoint" should { | |
| args(sequential=true) | |
| "Create new user" ! userEndpointForTest().executeTestCreateNewUser() | |
| "Try create a user with same email" ! userEndpointForTest().executeTestTryCreateAUserWithSameEmail() |
| post("/") { | |
| contentType = "application/json" | |
| authenticated { jsonObject => | |
| val entityManager = entityManagerFactory.createEntityManager() | |
| val userRepository = new UserRepository(entityManager) | |
| val userPersistenceAdapter = new NewUserPersistenceAdapterJPA(userRepository) | |
| val usecase = new NewUserUsecase(userPersistenceAdapter) | |
| val savedUser = usecase.save( User( jsonObject ) ) |
package com.codesimples.jdbc
import com.typesafe.scalalogging.Logger
import org.springframework.transaction.support.{TransactionCallbackWithoutResult, TransactionTemplate}
import org.springframework.transaction.{PlatformTransactionManager, TransactionStatus}| case class UserMeasures(state: Map[String,Any]) { | |
| def gender : String = { | |
| state.getOrElse("usr_genero", "").asInstanceOf[String] | |
| } | |
| def measures: List[Map[String,Any]] = { | |
| state.getOrElse("measures", List[Map[String,Any]]()).asInstanceOf[List[Map[String,Any]]] | |
| } |