35
The NetBeans TM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers Sun Microsystems TS-5249

The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before

Tor Norbye and Brian LeonardSr. Software EngineersSun Microsystems TS-5249

Page 2: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 2

Learn how to jump-start your Ruby and Rails development using NetBeans™ software

Page 3: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 3

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java™ class libraryDeploymentFutures

Page 4: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 4

Project Creation / Rails Generators

Start from scratch or work with existing sourcesGenerate project artifacts• Scaffolds• Models• Controllers• Migrations• Integration tests

Page 5: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 5

Rails Project Creation

Page 6: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 6

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java class libraryDeploymentFutures

Page 7: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 7

Editing: Code Completion

Code Completion for all the Rails APIs...and any custom Ruby Gems you've installed...and your own modules, classes and methodsParameter completion!• On database table parameters in ActiveRecord calls• Hash key completion: Known symbols like :order, :group and so on

for the various methods that take options hashes• Hash value completion: When the hash key is something like

:controller, lists the available controller names; when the hash key is a boolean, lists :true and :false, and so on.

Page 8: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 8

Editing: Active Record Code Completion

NetBeans software studies your database migrations filesIf present, it also studies your schema dump fileIt builds up a logical model of your database modelsCode completion for your model classes will include the dynamic database propertiesCode completion will also include the dynamically added finder methods

Page 9: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 9

Editing: Enhanced Documentation

Custom RDoc rendering recognizes code samples and syntax highlights them – not just for Ruby but for ERb as wellRDoc handling supports reformatting comments as wellCtrl-Space to show the comment you're editing as RDoc

RDoc NetBeans

Page 10: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 10

Rails Quickfixes

Quickfixes are integrated with the tasklist• Open the tasklist to scan all files in your projects for problems

Rails Deprecations Check• Finds references to deprecated Rails functions and describes the

suggested change• Detects usages of fields when you should be using the attribute

Actions without Views• In controller files, it checks whether a method corresponds to a

view, and if not, adds a quickfix to create a view for the methodRuby Quickfixes• Detection of many common programming mistakes, deprecation

checks for APIS outside of Rails, and various code transformations such as reversing double negatives, converting between {} and do/end blocks, etc.

Page 11: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 11

ERb Editing

ERb files are also known as RHTML files – the JavaServer Pages™ (JSP™) technology of the Ruby world, with Ruby embedded inside <% %> tagsAll the Ruby editing features work in the Ruby scriptlets tooSpell checking of your HTML (user visible) textFormatting, including compound indentation<h1>Header</h1><div> <%# This line was indented by the <div> block %> <span>HTML here</span> <% if true %> <span>HTML indented further by Ruby</span> <% end %> <span>More HTML here</span></div>

Page 12: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 12

ERb Editing: Other Languages

Support for multiple embedded languages in your ERb:• JavaScript™ programming language editing, CSS, HTML

JavaScript programming language editing includes most of the same features we have for Ruby – formatting, code completion, go to declaration, quickfixes, ...YAML file editingHAML (experimental)

Page 13: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 13

Editing: Type Analysis

If NetBeans software IDE knows the types of your parameters, code completion etc. can be more accurate within the methodIf NetBeans software IDE knows the return types from your methods, it can do a better job with expressions calling your methodUse Type Hints in your documentation to help the IDE• #:arg:parameterName=>type• #:return:=>type

The type information is also used for other IDE features, such as Go To Declaration.

Page 14: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 14

Code Sample: Type Hints

## Creates an +n+ by +n+ identity matrix.# Matrix.identity(2)# => 1 0# 0 1# #:arg:n=>Fixnum #:return:=>Matrix def Matrix.identity(n) Matrix.scalar(n, 1)end

Page 15: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 15

Navigation

Go To Declaration: Ctrl-click on classes, methods, fields and variables to jump to its declaration (Ctrl-B)• Also works for references in documentation• Knows about Rails-style references like :partial =>, :controller=>

and :action=> and takes those into account• Ctrl-hover over symbols to read its documentation without jumping

Jump between a file and its test (Ctrl-Shift-T)• Knows about Rails, Rspec, ZenTest and Test::Unit conventions• If filename based search fails, finds tests by class names

regardless of where they are locatedJump between a Controller and its View (Ctrl-Shift-A)• Figures out which view to jump to in a controller based on the caret

offset and parse information for the surrounding codeOpen Type (Ctrl-O)

Page 16: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 16

Navigation: Open Type

Jump to classJump to methods by prefixing with “#”.Various search styles are available.• Prefix: actionc => ActionController::Base• Regular Expression: *Cach*r => ActionCacheFilter• CamelCase (AC::B => ActionController::Base)• #to_s (all methods named to_s across all the classes)• #*load* => all_loaders

Page 17: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 17

Editing/Navigation

Page 18: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 18

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java class libraryDeploymentFutures

Page 19: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 19

Execution and Testing

Run File (Shift-F6). Performs context sensitive action for the current file• For a controller or view or helper, fronts the browser and

shows/reloads the URL corresponding to the given controller or view (starting the Rails server if necessary)

• For a test, runs the test• For an RSpec file, runs the file under RSpec's runner• For migration files, runs rake migration to the migration file's level• For Rakefiles, runs rake on the given rake file• For other files, runs the file using Ruby

Test File (Ctrl-F6). Runs test for this file• If this file is not a test/spec, finds the test for this file and runs that

file instead• Tests are run under test infrastructure, producing green/red

summary results

Page 20: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 20

Execution & Testing

Page 21: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 21

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java class libraryDeploymentFutures

Page 22: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 22

Source Level Debugging!SteppingBreakpointsLocal VariablesCall StackThreadsWatchesBalloon-Evaluation

Get it?

Page 23: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 23

Debugging

Page 24: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 24

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java class libraryDeploymentFutures

Page 25: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 25

Java Integration

Load the high-level Java support (using 'include')Import classes (as with Java class library)Use Java class library just like Ruby classesSet classpath to any 3rd party Java class library

Page 26: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 26

Code Sample

# Load the high-level Java supportinclude Java# Import the classes you want to use (Just as in Java)import java.util.Random# Create an instance of java.util.Randomr = Random.new # Write a random integer to outputputs r.nextInt

Page 27: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 27

Java Integrated development

Page 28: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 28

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java class libraryDeploymentFutures

Page 29: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 29

DeploymentWEBrick is bundled with JRubyThe popular Mongrel server is also supported

Goldspike plugin allows for deployment to Java Servlet extension (Tomcat, GlassFish, etc.)

Page 30: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 30

Deployment to JavaTM Servlet extension

Page 31: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 31

Agenda

Project Generation / Rails GeneratorsEditing/NavigationExecution & TestingDebuggingRails + Java class libraryDeploymentFutures

Page 32: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 32

Future Plans

Better console integrationBetter test runner GUIImproved type analysisMore refactorings and QuickfixesBetter Java integrated developmentSupport for additional Ruby frameworks

Page 33: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 33

Summary

NetBeans software IDE is a first class environment for Ruby and Rails developmentEverything comes bundled to begin developing in Ruby immediatelyWith Ruby running on the Java VM (JRuby), Java integrated development is a snap

Page 34: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 34

For More Information

LAB-8400 Developing (J)Ruby on Rails Applications with the NetBeansTM IDEhttp://wiki.netbeans.org/[email protected]://blogs.sun.com/tor/http://weblogs.java/net/blog/bleonard

Page 35: The NetBeans Ruby IDE: You Thought Rails Development Was ... · The NetBeansTM Ruby IDE: You Thought Rails Development Was Fun Before Tor Norbye and Brian Leonard Sr. Software Engineers

2008 JavaOneSM Conference | java.sun.com/javaone | 35

Tor Norbye and Brian LeonardSr. Software EngineersSun Microsystems, Inc.TS-5249