Permalink
Browse files

init commit - rename formatter to qrcode

  • Loading branch information...
0 parents commit 32370a467517ab6fc8ef8c2cc2a0624e6cb27836 @samvincent committed Apr 1, 2011
Showing with 9,892 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +11 −0 Gemfile
  3. +101 −0 Gemfile.lock
  4. +20 −0 MIT-LICENSE
  5. +3 −0 README.rdoc
  6. +29 −0 Rakefile
  7. +41 −0 lib/rqrcode_svg.rb
  8. +9 −0 rqrcode_svg.gemspec
  9. +7 −0 test/dummy/Rakefile
  10. +3 −0 test/dummy/app/controllers/application_controller.rb
  11. +8 −0 test/dummy/app/controllers/home_controller.rb
  12. +2 −0 test/dummy/app/helpers/application_helper.rb
  13. +2 −0 test/dummy/app/views/home/index.html.erb
  14. 0 test/dummy/app/views/home/index.svg.erb
  15. +14 −0 test/dummy/app/views/layouts/application.html.erb
  16. +4 −0 test/dummy/config.ru
  17. +45 −0 test/dummy/config/application.rb
  18. +10 −0 test/dummy/config/boot.rb
  19. +22 −0 test/dummy/config/database.yml
  20. +5 −0 test/dummy/config/environment.rb
  21. +26 −0 test/dummy/config/environments/development.rb
  22. +49 −0 test/dummy/config/environments/production.rb
  23. +35 −0 test/dummy/config/environments/test.rb
  24. +7 −0 test/dummy/config/initializers/backtrace_silencers.rb
  25. +10 −0 test/dummy/config/initializers/inflections.rb
  26. +5 −0 test/dummy/config/initializers/mime_types.rb
  27. +7 −0 test/dummy/config/initializers/secret_token.rb
  28. +8 −0 test/dummy/config/initializers/session_store.rb
  29. +5 −0 test/dummy/config/locales/en.yml
  30. +4 −0 test/dummy/config/routes.rb
  31. +26 −0 test/dummy/public/404.html
  32. +26 −0 test/dummy/public/422.html
  33. +26 −0 test/dummy/public/500.html
  34. 0 test/dummy/public/favicon.ico
  35. +2 −0 test/dummy/public/javascripts/application.js
  36. +965 −0 test/dummy/public/javascripts/controls.js
  37. +974 −0 test/dummy/public/javascripts/dragdrop.js
  38. +1,123 −0 test/dummy/public/javascripts/effects.js
  39. +6,001 −0 test/dummy/public/javascripts/prototype.js
  40. +191 −0 test/dummy/public/javascripts/rails.js
  41. 0 test/dummy/public/stylesheets/.gitkeep
  42. +6 −0 test/dummy/script/rails
  43. +20 −0 test/integration/navigation_test.rb
  44. +7 −0 test/rqrcode_svg_test.rb
  45. +5 −0 test/support/integration_case.rb
  46. +22 −0 test/test_helper.rb
@@ -0,0 +1,6 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
11 Gemfile
@@ -0,0 +1,11 @@
+source "http://rubygems.org"
+
+gem "rails", "3.0.5"
+gem "capybara", ">= 0.4.0"
+gem "sqlite3"
+
+gem "rqrcode"
+
+# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
+# gem 'ruby-debug'
+# gem 'ruby-debug19'
@@ -0,0 +1,101 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.5)
+ actionpack (= 3.0.5)
+ mail (~> 2.2.15)
+ actionpack (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.13)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.5)
+ activesupport (= 3.0.5)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.5)
+ activemodel (= 3.0.5)
+ activesupport (= 3.0.5)
+ activesupport (3.0.5)
+ arel (2.0.9)
+ builder (2.1.2)
+ capybara (0.4.1.2)
+ celerity (>= 0.7.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.27)
+ xpath (~> 0.1.3)
+ celerity (0.8.9)
+ childprocess (0.1.6)
+ ffi (~> 0.6.3)
+ culerity (0.2.14)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
+ i18n (0.4.2)
+ json_pure (1.4.6)
+ mail (2.2.15)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ nokogiri (1.4.4)
+ polyglot (0.3.1)
+ rack (1.2.2)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.5)
+ actionmailer (= 3.0.5)
+ actionpack (= 3.0.5)
+ activerecord (= 3.0.5)
+ activeresource (= 3.0.5)
+ activesupport (= 3.0.5)
+ bundler (~> 1.0)
+ railties (= 3.0.5)
+ railties (3.0.5)
+ actionpack (= 3.0.5)
+ activesupport (= 3.0.5)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ rqrcode (0.3.3)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.1.2)
+ childprocess (~> 0.1.5)
+ ffi (~> 0.6.3)
+ json_pure
+ rubyzip
+ sqlite3 (1.3.3)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.24)
+ xpath (0.1.3)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara (>= 0.4.0)
+ rails (= 3.0.5)
+ rqrcode
+ sqlite3
@@ -0,0 +1,20 @@
+Copyright 2011 YOURNAME
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
+= Rqrcode-svg
+
+This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,29 @@
+# encoding: UTF-8
+require 'rubygems'
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+
+require 'rake'
+require 'rake/rdoctask'
+
+require 'rake/testtask'
+
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
+end
+
+task :default => :test
+
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Rqrcode-svg'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,41 @@
+module RQRCode
+ module SVG
+ require "action_controller"
+ Mime::Type.register "image/svg+xml", :svg
+
+ require 'rqrcode'
+ ActionController::Renderers.add :svg do |string, options|
+ qrcode = RQRCode::QRCode.new(string)
+
+
+ offset = 20
+
+ dimension = (qrcode.module_count*11) + (2*offset)
+
+ head = <<-XML
+<?xml version="1.0" standalone="yes"?>
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="#{dimension}" height="#{dimension}">
+ XML
+
+ res = []
+ qrcode.modules.each_index do |c|
+ tmp = []
+ qrcode.modules.each_index do |r|
+ y = c*11 + offset
+ x = r*11 + offset
+ row = %{<rect width="11" height="11" x="#{x}" y="#{y}" style="fill:#000"/>}
+ col = %{<rect width="11" height="11" x="#{x}" y="#{y}" style="fill:#fff"/>}
+ if qrcode.is_dark(c,r)
+ tmp << row
+ else
+ tmp << col
+ end
+ end
+ res << tmp.join
+ end
+
+ svg = (head + res.join("") + "</svg>")
+ self.response_body = render_to_string(:text => svg, :template => nil)
+ end
+ end
+end
@@ -0,0 +1,9 @@
+# Provide a simple gemspec so you can easily use your enginex
+# project in your rails apps through git.
+Gem::Specification.new do |s|
+ s.name = "rqrcode_svg"
+ s.summary = "Insert Rqrcode-svg summary."
+ s.description = "Insert Rqrcode-svg description."
+ s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
+ s.version = "0.0.1"
+end
@@ -0,0 +1,7 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+require 'rake'
+
+Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,8 @@
+class HomeController < ApplicationController
+ def index
+ respond_to do |format|
+ format.html
+ format.svg { render :svg => "http://www.helloworld.com" }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+<p>Hey, you can download the pdf for this page by clicking the link below:</p>
+<p><%= link_to "SVG", home_path("svg") %></p>
No changes.
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Dummy</title>
+ <%= stylesheet_link_tag :all %>
+ <%= javascript_include_tag :defaults %>
+ <%= csrf_meta_tag %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Dummy::Application
@@ -0,0 +1,45 @@
+require File.expand_path('../boot', __FILE__)
+
+require "active_model/railtie"
+require "active_record/railtie"
+require "action_controller/railtie"
+require "action_view/railtie"
+require "action_mailer/railtie"
+
+Bundler.require
+require "rqrcode_svg"
+
+module Dummy
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+ end
+end
@@ -0,0 +1,10 @@
+require 'rubygems'
+gemfile = File.expand_path('../../../../Gemfile', __FILE__)
+
+if File.exist?(gemfile)
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+end
+
+$:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+# gem install sqlite3
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Dummy::Application.initialize!
@@ -0,0 +1,26 @@
+Dummy::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the webserver when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+end
+
Oops, something went wrong.

0 comments on commit 32370a4

Please sign in to comment.