button_form 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in button_form.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :spec
11
+ task :test => [:spec]
data/Readme.md ADDED
@@ -0,0 +1,9 @@
1
+ # FormButton
2
+
3
+ This simple gem will make all your Rails 3 forms use \<button/\> tags instead of \<input type="submit"/\> in your forms.
4
+
5
+ # Usage
6
+
7
+ In your Gemfile:
8
+
9
+ gem 'form_button'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "button_form/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "button_form"
7
+ s.version = ButtonForm::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Josep M. Bach", "Josep Jaume Rey", "Oriol Gual"]
10
+ s.email = ["info@codegram.com"]
11
+ s.homepage = "http://github.com/codegram/form_button"
12
+ s.summary = %q{form_button replaces all <input type="submit"/> tags with <button/> in your forms}
13
+ s.description = %q{form_button replaces all <input type="submit"/> tags with <button/> in your forms}
14
+
15
+ s.rubyforge_project = "button_form"
16
+
17
+ s.add_development_dependency "rspec"
18
+ s.add_runtime_dependency "rails", "~> 3.0"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
@@ -0,0 +1,19 @@
1
+ module ButtonForm
2
+ def self.included(base)
3
+ base.class_eval <<-RUBY
4
+ def submit_tag(value = "Save changes", options = {})
5
+ options.stringify_keys!
6
+
7
+ if disable_with = options.delete("disable_with")
8
+ options["data-disable-with"] = disable_with
9
+ end
10
+
11
+ if confirm = options.delete("confirm")
12
+ options["data-confirm"] = confirm
13
+ end
14
+
15
+ content_tag :button, value, { "type" => "submit", "name" => "commit"}.update(options.stringify_keys)
16
+ end
17
+ RUBY
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module ButtonForm
2
+ class Railtie < Rails::Railtie
3
+ initializer "button_form.configure_rails_initialization" do
4
+ ActionView::Helpers.send(:include,ButtonForm)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module ButtonForm
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'button_form/button_form'
2
+ require 'button_form/railtie' if defined?(Rails)
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ButtonForm do
4
+ subject do
5
+ Class.new do
6
+ include ButtonForm
7
+ end.new
8
+ end
9
+
10
+ it "should respond with a button" do
11
+ options = ActiveSupport::HashWithIndifferentAccess.new
12
+ subject.should respond_to(:submit_tag)
13
+ subject.should_receive(:content_tag).once.with(:button, 'Save changes', anything)
14
+ subject.submit_tag('Save changes', options)
15
+ end
16
+
17
+ it "gets included in ActionView::FormHelpers" do
18
+ ActionView::Helpers.ancestors.should include(ButtonForm)
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'active_support/hash_with_indifferent_access'
5
+
6
+ module ActionView
7
+ module Helpers
8
+ end
9
+ end
10
+
11
+ module Rails
12
+ class Railtie
13
+ def self.initializer(string)
14
+ yield
15
+ end
16
+ end
17
+ end
18
+
19
+ require 'button_form'
20
+ require 'rspec'
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: button_form
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - Josep M. Bach
9
+ - Josep Jaume Rey
10
+ - Oriol Gual
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2011-03-01 00:00:00 +01:00
16
+ default_executable:
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: rspec
20
+ prerelease: false
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: "0"
27
+ type: :development
28
+ version_requirements: *id001
29
+ - !ruby/object:Gem::Dependency
30
+ name: rails
31
+ prerelease: false
32
+ requirement: &id002 !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: "3.0"
38
+ type: :runtime
39
+ version_requirements: *id002
40
+ description: form_button replaces all <input type="submit"/> tags with <button/> in your forms
41
+ email:
42
+ - info@codegram.com
43
+ executables: []
44
+
45
+ extensions: []
46
+
47
+ extra_rdoc_files: []
48
+
49
+ files:
50
+ - .gitignore
51
+ - Gemfile
52
+ - Rakefile
53
+ - Readme.md
54
+ - button_form.gemspec
55
+ - lib/button_form.rb
56
+ - lib/button_form/button_form.rb
57
+ - lib/button_form/railtie.rb
58
+ - lib/button_form/version.rb
59
+ - spec/button_form_spec.rb
60
+ - spec/spec_helper.rb
61
+ has_rdoc: true
62
+ homepage: http://github.com/codegram/form_button
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ requirements: []
83
+
84
+ rubyforge_project: button_form
85
+ rubygems_version: 1.5.2
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: form_button replaces all <input type="submit"/> tags with <button/> in your forms
89
+ test_files:
90
+ - spec/button_form_spec.rb
91
+ - spec/spec_helper.rb