bootstrap_helpers 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module BootstrapHelpers
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -14,6 +14,15 @@ module BootstrapHelpers
14
14
  end
15
15
  end
16
16
 
17
+ def bootstrap_form_for(form_object, legend='', params={})
18
+ form_for form_object, params do |f|
19
+ concat(content_tag(:fieldset) do
20
+ concat content_tag(:legend, legend)
21
+ yield(f)
22
+ end)
23
+ end
24
+ end
25
+
17
26
  def bootstrap_form_input(title, params={})
18
27
  params[:class]="clearfix #{params[:class]}"
19
28
  content_tag :div, params do
@@ -21,6 +30,15 @@ module BootstrapHelpers
21
30
  end
22
31
  end
23
32
 
33
+ def bootstrap_prepended_input(title, symbol, params={})
34
+ bootstrap_form_input(title, params) do
35
+ concat (content_tag(:div, :class=>'input-prepend') do
36
+ concat concat_tag :span, symbol, :class=>'add-on'
37
+ yield
38
+ end)
39
+ end
40
+ end
41
+
24
42
  def bootstrap_form_actions(params={})
25
43
  params[:class]="actions #{params[:class]}"
26
44
  content_tag :div, params do
data/test_app/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem 'rails', '3.0.10'
7
7
 
8
8
  gem 'sqlite3'
9
9
  gem 'jquery-rails'
10
- gem 'bootstrap_helpers', '0.0.2'
10
+ gem 'bootstrap_helpers', '0.0.3'
11
11
 
12
12
  group :test do
13
13
  gem 'rspec-rails', ">=2.5.0"
@@ -2,7 +2,10 @@ class SamplesController < ApplicationController
2
2
 
3
3
  def index;end
4
4
 
5
- def bootstrap_form_input;end
5
+ def bootstrap_forms_for
6
+ @post = Post.new
7
+ @years = [10.years.ago.year .. 12.years.since.year]
8
+ end
6
9
 
7
10
  def bootstrap_flash_messages
8
11
  flash[:notice]='Example of notice'
@@ -0,0 +1,2 @@
1
+ class Post < ActiveRecord::Base
2
+ end
@@ -0,0 +1,5 @@
1
+ <%= bootstrap_form_for @post, 'Edit post', :url=>'', :html=>{:class=>'sample'} do |f|%>
2
+ <%= bootstrap_form_input("Author") {f.text_field :author}%>
3
+ <%= bootstrap_form_input("Title") {f.text_field :title}%>
4
+ <%= bootstrap_form_input("Year") {f.select :year, @years}%>
5
+ <%end%>
@@ -1,7 +1,7 @@
1
1
  TestApp::Application.routes.draw do
2
2
  root :to=>'Samples#index'
3
3
  controller :samples do
4
- get '/bootstrap_form_input'=>:bootstrap_form_input, :as=>:bootstrap_form_input
4
+ get '/bootstrap_forms_for'=>:bootstrap_forms_for, :as=>:bootstrap_forms_for
5
5
  get '/bootstrap_flash_messages'=>:bootstrap_flash_messages, :as=>:bootstrap_flash_messages
6
6
  end
7
7
  end
@@ -0,0 +1,16 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :posts do |t|
4
+ t.string :author
5
+ t.string :title
6
+ t.integer :year
7
+ t.string :kind
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :posts
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20111117155440) do
14
+
15
+ create_table "posts", :force => true do |t|
16
+ t.string "author"
17
+ t.string "title"
18
+ t.integer "year"
19
+ t.string "kind"
20
+ t.datetime "created_at"
21
+ t.datetime "updated_at"
22
+ end
23
+
24
+ end
@@ -25,4 +25,12 @@ describe SamplesController do
25
25
  page.should_not have_selector("div.alert-message.info")
26
26
  end
27
27
 
28
+ it 'should have form resource' do
29
+ visit bootstrap_forms_for_path
30
+ page.should have_selector("form.sample")
31
+ page.should have_selector("form.sample legend", :text=>'Edit post')
32
+ page.should have_selector("form.sample .clearfix", :count=>3)
33
+ page.should have_selector("form.sample select")
34
+ end
35
+
28
36
  end
@@ -0,0 +1,13 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ one:
4
+ author: MyString
5
+ title: MyString
6
+ year: 1
7
+ kind: MyString
8
+
9
+ two:
10
+ author: MyString
11
+ title: MyString
12
+ year: 1
13
+ kind: MyString
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_helpers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergey Pchelincev
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-17 00:00:00 +02:00
18
+ date: 2011-11-18 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -47,9 +47,11 @@ files:
47
47
  - test_app/app/controllers/application_controller.rb
48
48
  - test_app/app/controllers/samples_controller.rb
49
49
  - test_app/app/helpers/application_helper.rb
50
+ - test_app/app/models/post.rb
50
51
  - test_app/app/views/layouts/application.html.erb
51
52
  - test_app/app/views/samples/bootstrap_flash_messages.html.erb
52
53
  - test_app/app/views/samples/bootstrap_form_input.html.erb
54
+ - test_app/app/views/samples/bootstrap_forms_for.html.erb
53
55
  - test_app/app/views/samples/index.html.erb
54
56
  - test_app/chromedriver.log
55
57
  - test_app/config.ru
@@ -67,6 +69,8 @@ files:
67
69
  - test_app/config/initializers/session_store.rb
68
70
  - test_app/config/locales/en.yml
69
71
  - test_app/config/routes.rb
72
+ - test_app/db/migrate/20111117155440_create_posts.rb
73
+ - test_app/db/schema.rb
70
74
  - test_app/db/seeds.rb
71
75
  - test_app/doc/README_FOR_APP
72
76
  - test_app/lib/tasks/.gitkeep
@@ -95,6 +99,8 @@ files:
95
99
  - test_app/script/rails
96
100
  - test_app/spec/requests/bootstrap_form_input_spec.rb
97
101
  - test_app/spec/spec_helper.rb
102
+ - test_app/test/fixtures/posts.yml
103
+ - test_app/test/unit/post_test.rb
98
104
  - test_app/vendor/plugins/.gitkeep
99
105
  has_rdoc: true
100
106
  homepage: ""