carpentry 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem "rails", "3.0.7"
4
+ gem "rake", "~> 0.9.2"
5
+ gem "capybara", ">= 0.4.0"
6
+
7
+ gem "autotest-standalone"
8
+ gem "rspec-rails"
@@ -0,0 +1,55 @@
1
+ Carpentry
2
+ =========
3
+
4
+ ____________________________________
5
+ / Carpentry – handcrafted prototypes \
6
+ \ with ease /
7
+ ------------------------------------
8
+ \ ^__^
9
+ \ (oo)\_______
10
+ (__)\ )\/\
11
+ ||----w |
12
+ || ||
13
+
14
+
15
+ Installation
16
+ ------------
17
+
18
+ Add Carpentry to Gemfile:
19
+
20
+ gem "carpentry"
21
+
22
+ Run the generator to create the prototypes folder:
23
+
24
+ rails generate carpentry:install
25
+
26
+
27
+ Usage
28
+ -----
29
+
30
+ Put your views in app/views/carpentry/prototypes and view them in
31
+ browser at /p/path_to_file.
32
+
33
+ Examples:
34
+
35
+ | URI Path | File path |
36
+ |--------------|----------------------------------------------------|
37
+ | /p | app/views/carpentry/prototypes/index.html.erb |
38
+ | /p/home | app/views/carpentry/prototypes/home.html.haml |
39
+ | /p/posts/new | app/views/carpentry/prototypes/posts/new.html.slim |
40
+
41
+ All available Rails helpers work nicely. Pure prototyping bliss!
42
+
43
+
44
+ Gotchas
45
+ -------
46
+
47
+ When rendering a partial, you must specify the full path
48
+ (e.g. `carpentry/prototypes/posts/form`) unless the partial is in
49
+ `app/views/carpentry/prototypes/`.
50
+
51
+
52
+ License
53
+ -------
54
+
55
+ MIT License. Copyright 2011 Kisko Labs.
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake'
10
+ require 'rake/task'
11
+
12
+ require 'rspec/core'
13
+ require 'rspec/core/rake_task'
14
+
15
+ RSpec::Core::RakeTask.new(:spec)
16
+ Bundler::GemHelper.install_tasks
17
+
18
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ module Carpentry
2
+ class PrototypesController < ApplicationController
3
+ before_filter :before_carpentry,
4
+ :if => proc { respond_to?(:before_carpentry, true) }
5
+
6
+ def serve
7
+ env["carpentry.prototype"] = true
8
+ render "carpentry/prototypes/#{params[:file_path]}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ namespace "p", :module => :carpentry do
3
+ root :to => "prototypes#serve", :file_path => "index"
4
+ match "/*file_path" => "prototypes#serve"
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require "carpentry/no_robots_middleware"
2
+
3
+ module Carpentry
4
+ class Engine < ::Rails::Engine
5
+ config.app_middleware.use NoRobotsMiddleware
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module Carpentry
2
+ class NoRobotsMiddleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ status, headers, response = @app.call(env)
9
+
10
+ if env["carpentry.prototype"] && status == 200
11
+ no_robots_tag = %{<meta name="robots" content="noindex, nofollow"/>\n}
12
+ response.body = response.body.sub("</head>", "#{no_robots_tag}</head>")
13
+ end
14
+
15
+ [status, headers, response]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Carpentry
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,10 @@
1
+ module Carpentry
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ def create_directory_with_gitkeep
5
+ empty_directory "app/views/carpentry/prototypes"
6
+ create_file "app/views/carpentry/prototypes/.gitkeep"
7
+ end
8
+ end
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carpentry
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Joao Carlos
9
+ - "Vesa V\xC3\xA4nsk\xC3\xA4"
10
+ - Matias Korhonen
11
+ - Antti Salonen
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2011-06-07 00:00:00 Z
17
+ dependencies: []
18
+
19
+ description: Handcrafted prototypes for Rails.
20
+ email:
21
+ - contact@kiskolabs.com
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - app/controllers/carpentry/prototypes_controller.rb
30
+ - lib/carpentry/no_robots_middleware.rb
31
+ - lib/carpentry/version.rb
32
+ - lib/carpentry.rb
33
+ - lib/generators/carpentry/install/install_generator.rb
34
+ - config/routes.rb
35
+ - Rakefile
36
+ - Gemfile
37
+ - README.md
38
+ homepage: https://github.com/kiskolabs/carpentry
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: -3962878218693987690
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.3
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Protyping engine for Rails.
68
+ test_files: []
69
+