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 +4 -0
- data/Gemfile +4 -0
- data/Rakefile +11 -0
- data/Readme.md +9 -0
- data/button_form.gemspec +24 -0
- data/lib/button_form/button_form.rb +19 -0
- data/lib/button_form/railtie.rb +7 -0
- data/lib/button_form/version.rb +3 -0
- data/lib/button_form.rb +2 -0
- data/spec/button_form_spec.rb +20 -0
- data/spec/spec_helper.rb +20 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
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
data/button_form.gemspec
ADDED
@@ -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
|
data/lib/button_form.rb
ADDED
@@ -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
|
data/spec/spec_helper.rb
ADDED
@@ -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
|