SlideShare a Scribd company logo
1 of 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

More Related Content

Viewers also liked

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ø
 

Viewers also liked (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 to 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 to 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
 

Recently uploaded

Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPTiSEO AI
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandIES VE
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jNeo4j
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 

Recently uploaded (20)

Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 

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