SlideShare uma empresa Scribd logo
1 de 30
My month with Ruby
Who is this guy?
- Alex Tomovski
- Backend Developer (primarily)
- Scala, Java, Groovy
- Recently crossed to the dark side… JS
How did I end up coding Ruby?
- Joined Wix in the summer.
- No project was waiting for me.
- Finally after two weeks I got a call…
How did the colleagues react when I
told them I’ll be doing Ruby?
Some of them got creative :)
What was I supposed to build?
- Thin Rest Wrapper
- But why?
- Make developers life easier.
- Annoying request signing logic
- Document and provide examples for the APIs
The API
Where do you start???
- Book: The Ruby Programming language
- IRB
- Setup the project
- Look at other examples/tools
- www.ruby-toolbox.com
Setting up the project
- Bundler and Rake
- Love at first sight (especially for bundler)
I want less of this: and more of this:
Hello World!
- Tests
- RSpec + Guard
- Tests run in the background
- Immediate feedback
- WIN!
Testing a dynamic language
- Paranoia!
- What happens if someone
passes the wrong type?
- Guard statements
everywhere?
- Wait do I care?
Integration (e2e) Tests
- Easier refactoring
- Faster bug discovery
- VCR
- https://github.com/vcr/vcr
- Records HTTP Interactions
- Fast re-execution
- Helps with debugging
VCR Cassette
First Impressions
- Easy to learn
- Readability
- Super FUN!
Guard Statements!
Mutability
- Hard to come back to it
- Side effects
- Freeze?
Blocks? Lambdas? Procs?
Vision
- One entry point (the client)
- Minimal configuration
- Optional extensive configuration
Structuring the gem
- Modules
- Mixins
REST Client VS. Faraday
- Ease of use
- Extensibility
- Plugable middleware
- Configuration
Faraday
Classes or Hashes?
- Response handling
Classes
- Easy data access
- Hard to create
Introducing Hashie
- Best of two worlds
- https://github.com/intridea/hashie
Hashie Example
Too much magic
- It was all great until this:
/hashie/dash.rb:41:in `block in property': wrong number of arguments (1 for 0)
(ArgumentError)
from /hashie-3.2.0/lib/hashie/hash.rb:48:in `flexibly_convert_to_hash'
from /hashie-3.2.0/lib/hashie/hash.rb:34:in `block in to_hash'
from /hashie-3.2.0/lib/hashie/hash.rb:20:in `each'
from /hashie-3.2.0/lib/hashie/hash.rb:20:in `to_hash'
from /hashie-3.2.0/lib/hashie/hash.rb:42:in `to_json'
A day latter…
Monkey Patching
And we’re Almost :) done
- Final thoughts:
- Threading
- Meta programming
- Would I use Ruby again?
Thank you!
Questions, Comments?
Repo: https://github.com/wix/wix-hive-ruby

Mais conteúdo relacionado

Mais procurados

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystemYukti Kaura
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisYork Tsai
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming LanguageJaeju Kim
 
Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Vinci Rufus
 
Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerJames Ford
 
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoNode.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoAziz Ali
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Michał Konarski
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJSTim Sommer
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
Crate Packaging Standalone Ruby Applications
Crate  Packaging Standalone Ruby ApplicationsCrate  Packaging Standalone Ruby Applications
Crate Packaging Standalone Ruby Applicationsrailsconf
 
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBBuilding a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBVivochaLabs
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with BlackfireMarko Mitranić
 
NodePDX Slides
NodePDX SlidesNodePDX Slides
NodePDX SlidesKyle Drake
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for RubistsSagiv Ofek
 

Mais procurados (20)

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
NodeJS
NodeJSNodeJS
NodeJS
 
EhTrace -- RoP Hooks
EhTrace -- RoP HooksEhTrace -- RoP Hooks
EhTrace -- RoP Hooks
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and Redis
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
 
Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2Re-thinking Performance tuning with HTTP2
Re-thinking Performance tuning with HTTP2
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Virtualisation - Vagrant and Docker
Virtualisation - Vagrant and DockerVirtualisation - Vagrant and Docker
Virtualisation - Vagrant and Docker
 
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup ChicagoNode.js: Whats the Big Deal? Presented and JS Meetup Chicago
Node.js: Whats the Big Deal? Presented and JS Meetup Chicago
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Crate Packaging Standalone Ruby Applications
Crate  Packaging Standalone Ruby ApplicationsCrate  Packaging Standalone Ruby Applications
Crate Packaging Standalone Ruby Applications
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBBuilding a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDB
 
2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire2019 PHP Serbia - Boosting your performance with Blackfire
2019 PHP Serbia - Boosting your performance with Blackfire
 
NodePDX Slides
NodePDX SlidesNodePDX Slides
NodePDX Slides
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 

Semelhante a My Month Learning Ruby

SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking systemJesse Vincent
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the RubyistWill Green
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyKyle Drake
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ilya Grigorik
 
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
Lightweight APIs in mRuby
Lightweight APIs in mRubyLightweight APIs in mRuby
Lightweight APIs in mRubyPivorak MeetUp
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)Bertrand Delacretaz
 
Node Security: The Good, Bad & Ugly
Node Security: The Good, Bad & UglyNode Security: The Good, Bad & Ugly
Node Security: The Good, Bad & UglyBishan Singh
 
Introduction To Rails
Introduction To RailsIntroduction To Rails
Introduction To RailsEric Gruber
 
Docker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker, Inc.
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerJérôme Petazzoni
 

Semelhante a My Month Learning Ruby (20)

SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 
Java
JavaJava
Java
 
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) - Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
Puppet Camp Atlanta 2014: DEV Toolsets for Ops (Beginner) -
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Lightweight APIs in mRuby
Lightweight APIs in mRubyLightweight APIs in mRuby
Lightweight APIs in mRuby
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)Open innovation in software means Open Source (2011 remix)
Open innovation in software means Open Source (2011 remix)
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 
Node Security: The Good, Bad & Ugly
Node Security: The Good, Bad & UglyNode Security: The Good, Bad & Ugly
Node Security: The Good, Bad & Ugly
 
Introduction To Rails
Introduction To RailsIntroduction To Rails
Introduction To Rails
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Docker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in ProductionDocker Online Meetup #3: Docker in Production
Docker Online Meetup #3: Docker in Production
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 

Último

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 

Último (20)

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 

My Month Learning Ruby

Notas do Editor

  1. Thin Rest Wrapper around a collection of API’s that Wix exposes to third party application developers.
  2. How do you choose tools when you have no experience and no one to ask? You use google :) and find ruby toolbox. This really helped me and almost all (I’ll talk about exceptions in a minute) of the tools that used are based on the stats from this place. IRB - Although scala has the repl and I always found it useful, what I loved about the IRB and found more convenient is the fact that you can simply require gems and play around with them.
  3. Coming from the world of Scala/Java where you need to choose between maven gradle or sbt for your project using bundler and rake was like a dream come true. And what I truly loved about them is the simplicity and the fact that the dependency management is separated from the tasks part! No more xmls or spaghetti code for dependencies, build ,package and test tasks.
  4. Guard running the tests. Amazing when coming from Scala!
  5. No compiler no types I need to test everything! During my first week this was the attitude that I had and I wrote a whole bunch of unit tests that had nothing to do with behaviour! But I quickly realised that I’m trying swim against the tide here. I heard/read various opinions on how you should write more unit tests when you are coding in a dynamic language but what I actually found the most useful are integration tests! But say you had a test that tested the system/component from the outside? Would that help? IMHO it might and it might help you catch bugs faster and thats why we need integration and e2e tests….
  6. As we spoke just a minute more often than not we need to refactor some bits of the system or in this case library. This will involve changing sometimes multiple components and although unit tests are great in this case they were not enough for me to feel comfortable making those changes. Also early in that one month I found myself creating bugs :) and these tests made sure to keep me in line. OK I realised I needed integration and end 2 end tests but I now had to add them to the project. What I wanted was: 1. Fast integration tests to run with guard. 2. E2E tests to exercise the library against a test app. After playing around a bit I realised that the tests in both cases are the same the only thing that was diferent is that I wanted the integration tests to run faster :) And as I already learned by now: There must be a GEM for it :) and there was VCR. Its an awesome tool basically it records the HTTP interactions and enables you to re-execute them in a fast manner locally while you are developing. Exactly what I needed. Another nice thing about VCR was that the interactions were saved as yaml files and were very readable so I found myself looking through them to resolve some issues both on the server and in the library iteslf. OK now that I had the tests set up it was time to actually write the gem…
  7. By this point I’ve already had a few weeks of coding in Ruby… The first impression that I had about the language was how easy it was to pick it up and how naturaly it was to write code in Ruby. The code that I would write was almost like english making it the most redable language I’ve had the pleasure to work with. Not everything is pink in Ruby land though :) Mutability was something that I had to get used to coming from Scala.
  8. Here is the outline of how I wanted the gem to look like: One entry point…. meaning I the client would have to know only about a single class and easily pull it in. Minimal configuration… again I wanted developers to be able to require the gem and be able to start using it in a matter of min without having to go through a ton of documentation. Optional extensive configuration… for more advanced clients I wanted them to be able to configure anything from logging to http timeouts to headers. With that in mind and having looked at a couple of examples :) I set out to write the gem.
  9. First thing that I loved about Ruby was the modules! Lets look at the example of the structure that I was able to give to my code. So lets start with the client it pulls in the Rest API. The rest api defines the different groups of apis that it has. And finally lets look at the first one. One thing that was hard to get used to is that you can call methods from the parent object but that again comes down to me not being used to the dynamic nature of the language :) Now that I had this walking skeleton in place it was time to actually make some http calls and make the first e2e test pass. ??similar to Scala traits they are similar in the sense that modules are mixins and mixins are traits that can have state.
  10. Although the title of the slide looks like there was some battle :) between the two. To be honest there was not after maybe a day playing around with the two these were the takeaways: REST Client is for sure easier to use… It has a simple interface BUT but you pay for that simplicity by the lack of extensibility. This was the thing that made up my mind about Faraday! My code was encapsulated in small “racks” that I pluged in and they did one very specific job! For example the error handling [show slide]. And also it fit nicely with my initial idea to expose a fair amount of configuration to the advanced end user.
  11. Once I had the the whole thing set up and got my first response back from the gem I was not very satisfied with the response… :) I got a hash back… this was not the usage I had in mind. How I actually wanted this gem to work is that the user would receive an object back that he can access. For example: [show example] So I started creating this kind of objects by hand and added some parsing logic to populate them it looked great until moment I actually wanted to send a request to create a contact for example… and that looked like this [show example] and this was also not what I wanted… and if that was not enough I realised that I also need some validation on the objects. And again before long I applied the most valuable lesson in Ruby that I’ve learned so far and that is: If you are doing something complicated stop there is a gem for it :D And there was Introducing hashie the best of two worlds [show example] with hashie I was able to give the flexibility for developers to choose their own style in which they read or create objects.
  12. I was making rapid progress with Hashie. Things were so easy :) I even took it a step further and generated some of the classes from a predefined json schema. Until I got this error. First things first this didnt tell me anything to be honest so I started debugging and after maybe a day or so I figured it out :) one of the responses that I was getting contained a field named method. And guess what hashie did when it found a field like that? Well it declared a method called method :) and kaboom you loose one of the base object methods. And its just a ticking bomb until this pops up somewhere on runtime.
  13. Lets start off with the fact that I had to solve my problem. It was too late to go back and do a reafctor on the library because of one “small” issue. So I resorted to I suppose everyone in this room has done once or twice in their Ruby career and that is Monkey Patching. I suppose you have read heard argued on this subject so I wont take too much of your time and I will break my view on it down to 3 simple points. Obviously the good part is that the language enabled me to go around an issue or to add functionality to a class where needed. This fits nicely with the OOP open closed principle. Well the bad thing here is that I can override or practically erase a behaviour of any class. Thus violating the “closed for modification” part of the open closed principle. Once you monkey patch for the first time it works like heroin :) you just want to do it more and every problem looks like a perfect fit for monkey patching. And if you are not carful you can endup with an ugly unmanageable code base. And although I lack the experience to speak about this in the Ruby world we have something very similar in Scala called implicits which is basically allows you to extend a class with new behaviour. But what happens usually when you learn implicits for the first time is that you use them everywhere you go crazy with them. And then good luck reading the code or debugging through it.