generate scaffold
invoke active_record
create db/migrate/20160201025849_create_projects.rb
create app/models/project.rb
invoke test_unit
create test/models/project_test.rb
create test/fixtures/projects.yml
invoke resource_route
route resources :projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parses configuration out from the "heroku config" command, and converts to command-line input | |
# for the "heroku config:add" command. It escapes $ characters. | |
def parse(config_text) | |
config_line_regex = /([^:]+):(.*)/ | |
config_text.split("\n").map do |line| | |
line_match = line.match(config_line_regex) | |
[line_match[1], line_match[2]] | |
end.map do |name, value| | |
"#{name.strip}=\"#{value.strip.gsub("$", "\\$")}\"" | |
end.join(" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Usage: speedtest [city]" | |
echo "Default city: Montreal" | |
echo "Examples:" | |
echo "$ speedtest Chicago" | |
echo "$ speedtest 'New York'\n" | |
[[ $1 ]] && city="$1" || city='Montreal' | |
echo "Speedtesting $city... Please be patient as this may take a minute or more depending on the Internet connection..." | |
speedtest-cli --list | grep -i "$city" | sed 's/^\([^\)]*\).*$/\1/' | sed -n '1,1p' | xargs speedtest-cli --share --server | grep 'Share results:' | grep 'Share results:' | sed 's/^Share results: \(.*\)$/\1/' | xargs open | |
echo "Done. If no report image has been opened, then please try again with another city." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def prefix-of? | |
(fn [chunk full] | |
(or | |
(empty? chunk) | |
(and | |
(= | |
(take 1 chunk) | |
(take 1 full) | |
) | |
(prefix-of? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "glimmer" | |
class Person | |
attr_accessor :country, :country_options | |
def initialize | |
self.country_options=["", "Canada", "US", "Mexico"] | |
self.country = "Canada" | |
end | |
Usage
Usage: glimmer [--setup] [application_ruby_file_path.rb]
Example 1: glimmer hello_combo.rb
This runs the Glimmer application hello_combo.rb If the SWT Jar is missing, it downloads it and sets it up first.
Example 2: glimmer --setup hello_combo.rb
This performs setup and then runs the Glimmer application hello_combo.rb It downloads and sets up the SWT jar whether missing or not.
Logging
Glimmer comes with a Ruby Logger accessible via Glimmer.logger
Its level of logging defaults to Logger::WARN
It may be configured to show a different level of logging as follows:
Glimmer.logger.level = Logger::DEBUG
This results in more verbose debugging log to STDOUT, which is helpful in troubleshooting Glimmer DSL syntax when needed.
Example log:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
describe "Glimmer Tree Data Binding" do | |
include Glimmer | |
include_package 'org.eclipse.swt' | |
include_package 'org.eclipse.swt.widgets' | |
include_package 'org.eclipse.swt.layout' | |
before do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shell { | |
tree(:virtual, :border) { | |
items bind(company, :owner), tree_properties(children: :people, text: :name) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe UltraLightWizard do | |
let(:app_rails_ref) {File.expand_path(File.join(__FILE__, '..', '..', '..', 'fixtures', 'ref_rails_app'))} | |
let(:app_rails_copy) {app_rails_ref.sub('ref', 'copy')} | |
before do | |
FileUtils.rm_rf app_rails_copy | |
FileUtils.cp_r app_rails_ref, app_rails_copy | |
end | |
after do | |
FileUtils.rm_rf app_rails_copy | |
end |