SlideShare una empresa de Scribd logo
1 de 45
Monkeybars
     in the manor
What do you think?
    about




      Java?
DIE, DIE           DIE, DIE          DIE, DIE


                  DIE, DIE
    DIE, DIE                         DIE, DIE

                      DIE, DIE
                                 DIE, DIE
  DIE, DIE



                   DIE, DIE

       DIE, DIE                  DIE, DIE
                     DIE, DIE
What do you think?
    About




    JRuby?
What do you think?
     About




     JRuby?
    (it’s not so bad really)
Before...

JRuby Installed

Netbeans Downloaded

Gems
Before...

JRuby Installed

Netbeans Downloaded

Gems
Before...

JRuby Installed

Netbeans Downloaded

Gems
Before...

JRuby Installed

Netbeans Downloaded

Gems
Twitter Client
  The Spec

 •Login
 •Report errors
 •Display friend tweets
 •Post tweets
Creating...
the app
Initial Setup
        + scaffolding



$> monkeybars projectname
$> cd projectname
$> rawr install
  (choose option 2)
$> jruby -S rake generate ALL='src/login'
Install Gems
          and freeze Gems




$>   jruby -S gem install twitter
$>   cd lib/ruby
$>   jruby -S gem unpack twitter
$>   jruby -S gem unpack hpricot
Skeleton App
  will look something like this
Net Beans
        New Project



1. Import Existing Java project with sources
2. Add JRuby complete library
3. Add Swing..




                                     Net
                                     Beans
Net Beans
        New Project



1. Import Existing Java project with sources
2. Add JRuby complete library
3. Add Swing..



         LIVE DEMO!

                                     Net
                                     Beans
Under the hood
   Like Rails but not as you know it




       M VC
Under the hood
   Like Rails but not as you know it




       M VC
username.text


                             View
             password.text

              login_button




                                     username
Controller                   Model   password
Sample Code
     a quick look




controllers, models, views
     event handling
Controller
class LoginController < ApplicationController
  set_model 'LoginModel'
  set_view 'LoginView'
  set_close_action :exit

  def login_button_action_performed
    model, view_transfer = view_state

    if @user = model.login(model.username, model.password)
      TweetController.instance.setup(model)
      TweetController.instance.open
      close
    else
      transfer[:errors] = model.errors
      signal(:login_failed)
    end

  end
end
Model
class LoginModel
  attr_accessor :username, :password, :message, :errors, :user


  def login(username, password)
    begin
      @user = Twitter::Base.new(username, password)
      @user.timeline
      self
    rescue Twitter::CantConnect => e
      @errors ||= []
      @errors << $!.to_s
      return false
    end

  end

end
View
class LoginView < ApplicationView
  set_java_class 'login.LoginFrame'
  map :view => quot;username.textquot;, :model => :username
  map :view => quot;password.textquot;, :model => :password



  define_signal :name => :login_failed, :handler => :login_failed

  def login_failed(model, transfer)
    message.text = transfer[:errors].to_s
  end
                                                         nom
end
                                                      nom..
The App
pre alpha 0.333333333333
Result
Package
       For cross platform distro

                    rawr install


                               Text




2: Keep the current Rakefile, and add the rawr content to the top.


                                                             http://rawr.rubyforge.org/
Package
Commands
For cross platform distro




             Text




  Remember to edit your
build_configuration.yaml 1st
Package
        Sample Config
                for RAWR to generate app
# Name of the created jar file
project_name: tweetobix

# Directory to create and place produced project files in
output_dir: package

----------<SNIP>----------------

# Individual files that should be loaded on the classpath
classpath_files:
   - lib/java/jruby-complete.jar
   - lib/java/swing-layout-1.0.3.jar




                see build_configuration.yaml
Tricks
and tips
Why didn’t you
  use the twitter4r gem




        ?
jruby --command gem install twitter4r
      Building native extensions. This could take a while...
   mypath/jruby-1.1.4/lib/ruby/1.8/mkmf.rb:7: JRuby does not
support native extensions. Check wiki.jruby.org for alternatives.
                    (NotImplementedError)
     from mypath/jruby-1.1.4/lib/ruby/1.8/mkmf.rb:1:in `require'
                          from extconf.rb:1
               ERROR: Error installing twitter4r:
            ERROR: Failed to build gem native extension.
    mypath/jruby-1.1.4/bin/jruby extconf.rb install twitter4r


 Gem files will remain installed in /mypath/jruby-1.1.4/lib/ruby/
            gems/1.8/gems/json-1.1.3 for inspection.
 Results logged to mypath/jruby-1.1.4/lib/ruby/gems/1.8/gems/
         json-1.1.3/ext/json/ext/parser/gem_make.out
Requiring Gems
                   Frozen
require 'manifest'
# Add vendored gems to load path and require them automatically
Dir[File.expand_path(File.dirname(__FILE__) + quot;/../lib/ruby/**quot;)].map
do |dir|
  lib = quot;#{dir}/libquot;
  lib = dir if lib =~ /.w+$/ #File.directory? is broken in current
JRuby for dirs inside jars
  $: << lib

  gem_name = File.basename(dir.gsub(/-d+.d+.d+$/, ''))
  gem_path = dir + quot;/lib/quot; + gem_name + quot;.rbquot;
  begin
    require gem_path if File.exists? gem_path
  rescue
     p quot;could not load gem #{gem_path}quot;
  end
end
Gotchas
       a few


java.lang.NullPointerException: null




                                build paths
gems
-1’s
  The not so good
        bits



• Assumes knowledge of Java
• Quirky MVC
• Learning curve
• Early days...
+1’s
        The good
        bits


• GUI Builder (using Netbeans)
• Interface with mature Java libs
• It’s all Ruby!
• Cross platform distribution
• No platform dependancy on Ruby
• Cutting edge
Blinked?
     Go here




http://tweetobix.com
   Steps plus code to download
Fin.




martinbtt
         http://www.beyondthetype.com

Más contenido relacionado

Destacado

Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)martinbtt
 
Lessons Learnt From Working With Rails
Lessons Learnt From Working With RailsLessons Learnt From Working With Rails
Lessons Learnt From Working With Railsmartinbtt
 
스타트링크 (Startlink) 소개 2015
스타트링크 (Startlink) 소개 2015스타트링크 (Startlink) 소개 2015
스타트링크 (Startlink) 소개 2015Startlink
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsBarry Feldman
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome EconomyHelge Tennø
 

Destacado (6)

Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)
 
Lessons Learnt From Working With Rails
Lessons Learnt From Working With RailsLessons Learnt From Working With Rails
Lessons Learnt From Working With Rails
 
스타트링크 (Startlink) 소개 2015
스타트링크 (Startlink) 소개 2015스타트링크 (Startlink) 소개 2015
스타트링크 (Startlink) 소개 2015
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Similar a Monkeybars in the Manor

Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Tse-Ching Ho
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRubyFrederic Jean
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahNick Plante
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09Michael Neale
 
Socket applications
Socket applicationsSocket applications
Socket applicationsJoão Moura
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformniyof97
 
Damage Control
Damage ControlDamage Control
Damage Controlsintaxi
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplosvinibaggio
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0Jan Sifra
 
Audit your reactive applications
Audit your reactive applicationsAudit your reactive applications
Audit your reactive applicationsOCTO Technology
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]RootedCON
 
Boxen: How to Manage an Army of Laptops and Live to Talk About It
Boxen: How to Manage an Army of Laptops and Live to Talk About ItBoxen: How to Manage an Army of Laptops and Live to Talk About It
Boxen: How to Manage an Army of Laptops and Live to Talk About ItPuppet
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Anton Arhipov
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 

Similar a Monkeybars in the Manor (20)

Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Ugo Cei Presentation
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei Presentation
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
Damage Control
Damage ControlDamage Control
Damage Control
 
Aprendendo solid com exemplos
Aprendendo solid com exemplosAprendendo solid com exemplos
Aprendendo solid com exemplos
 
Extjs Howto
Extjs HowtoExtjs Howto
Extjs Howto
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 
Audit your reactive applications
Audit your reactive applicationsAudit your reactive applications
Audit your reactive applications
 
Java introduction
Java introductionJava introduction
Java introduction
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
Boxen: How to Manage an Army of Laptops and Live to Talk About It
Boxen: How to Manage an Army of Laptops and Live to Talk About ItBoxen: How to Manage an Army of Laptops and Live to Talk About It
Boxen: How to Manage an Army of Laptops and Live to Talk About It
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 

Último

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Último (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

Monkeybars in the Manor

  • 1. Monkeybars in the manor
  • 2.
  • 3. What do you think? about Java?
  • 4. DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE DIE, DIE
  • 5.
  • 6.
  • 7. What do you think? About JRuby?
  • 8. What do you think? About JRuby? (it’s not so bad really)
  • 13. Twitter Client The Spec •Login •Report errors •Display friend tweets •Post tweets
  • 15. Initial Setup + scaffolding $> monkeybars projectname $> cd projectname $> rawr install (choose option 2) $> jruby -S rake generate ALL='src/login'
  • 16. Install Gems and freeze Gems $> jruby -S gem install twitter $> cd lib/ruby $> jruby -S gem unpack twitter $> jruby -S gem unpack hpricot
  • 17. Skeleton App will look something like this
  • 18. Net Beans New Project 1. Import Existing Java project with sources 2. Add JRuby complete library 3. Add Swing.. Net Beans
  • 19. Net Beans New Project 1. Import Existing Java project with sources 2. Add JRuby complete library 3. Add Swing.. LIVE DEMO! Net Beans
  • 20. Under the hood Like Rails but not as you know it M VC
  • 21. Under the hood Like Rails but not as you know it M VC
  • 22. username.text View password.text login_button username Controller Model password
  • 23. Sample Code a quick look controllers, models, views event handling
  • 24. Controller class LoginController < ApplicationController set_model 'LoginModel' set_view 'LoginView' set_close_action :exit def login_button_action_performed model, view_transfer = view_state if @user = model.login(model.username, model.password) TweetController.instance.setup(model) TweetController.instance.open close else transfer[:errors] = model.errors signal(:login_failed) end end end
  • 25. Model class LoginModel attr_accessor :username, :password, :message, :errors, :user def login(username, password) begin @user = Twitter::Base.new(username, password) @user.timeline self rescue Twitter::CantConnect => e @errors ||= [] @errors << $!.to_s return false end end end
  • 26. View class LoginView < ApplicationView set_java_class 'login.LoginFrame' map :view => quot;username.textquot;, :model => :username map :view => quot;password.textquot;, :model => :password define_signal :name => :login_failed, :handler => :login_failed def login_failed(model, transfer) message.text = transfer[:errors].to_s end nom end nom..
  • 27. The App pre alpha 0.333333333333
  • 28.
  • 30. Package For cross platform distro rawr install Text 2: Keep the current Rakefile, and add the rawr content to the top. http://rawr.rubyforge.org/
  • 31. Package Commands For cross platform distro Text Remember to edit your build_configuration.yaml 1st
  • 32. Package Sample Config for RAWR to generate app # Name of the created jar file project_name: tweetobix # Directory to create and place produced project files in output_dir: package ----------<SNIP>---------------- # Individual files that should be loaded on the classpath classpath_files: - lib/java/jruby-complete.jar - lib/java/swing-layout-1.0.3.jar see build_configuration.yaml
  • 34.
  • 35. Why didn’t you use the twitter4r gem ?
  • 36. jruby --command gem install twitter4r Building native extensions. This could take a while... mypath/jruby-1.1.4/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError) from mypath/jruby-1.1.4/lib/ruby/1.8/mkmf.rb:1:in `require' from extconf.rb:1 ERROR: Error installing twitter4r: ERROR: Failed to build gem native extension. mypath/jruby-1.1.4/bin/jruby extconf.rb install twitter4r Gem files will remain installed in /mypath/jruby-1.1.4/lib/ruby/ gems/1.8/gems/json-1.1.3 for inspection. Results logged to mypath/jruby-1.1.4/lib/ruby/gems/1.8/gems/ json-1.1.3/ext/json/ext/parser/gem_make.out
  • 37. Requiring Gems Frozen require 'manifest' # Add vendored gems to load path and require them automatically Dir[File.expand_path(File.dirname(__FILE__) + quot;/../lib/ruby/**quot;)].map do |dir| lib = quot;#{dir}/libquot; lib = dir if lib =~ /.w+$/ #File.directory? is broken in current JRuby for dirs inside jars $: << lib gem_name = File.basename(dir.gsub(/-d+.d+.d+$/, '')) gem_path = dir + quot;/lib/quot; + gem_name + quot;.rbquot; begin require gem_path if File.exists? gem_path rescue p quot;could not load gem #{gem_path}quot; end end
  • 38. Gotchas a few java.lang.NullPointerException: null build paths gems
  • 39. -1’s The not so good bits • Assumes knowledge of Java • Quirky MVC • Learning curve • Early days...
  • 40.
  • 41. +1’s The good bits • GUI Builder (using Netbeans) • Interface with mature Java libs • It’s all Ruby! • Cross platform distribution • No platform dependancy on Ruby • Cutting edge
  • 42.
  • 43. Blinked? Go here http://tweetobix.com Steps plus code to download
  • 44.
  • 45. Fin. martinbtt http://www.beyondthetype.com