bootstrap_datepicker_tag 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 020f99b8edb6ba06c5b0d80dbae63ac7b1c28992
4
+ data.tar.gz: 88fa9b19f5d5fbee2d53d71f3f631dd3d38d3fff
5
+ SHA512:
6
+ metadata.gz: 170dafa038aa17ef48bcd4ba7e2c634566d51402d0c5ae3a9b85f6c7538a2897bf8851d9439113691d0efb73882bf3bd2f92a2f199fb9f5c3613794b18c01470
7
+ data.tar.gz: 2f1f36b00f0be86e41f2c934eeb3f29627c6f5115eebc59ee96e4c9d05263ed7e64d595081040962b9152cd7f5e91afbfcff7a54a57687c8af4661dd438e6506
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.semver ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 1
5
+ :special: ''
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootstrap-datepicker-tag.gemspec
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Y.Zemlyanukhin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Bootstrap::Datepicker::Tag
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bootstrap-datepicker-tag'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bootstrap-datepicker-tag
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "bootstrap_datepicker_tag"
10
+ spec.version = BootstrapDatepickerTag::Version::VERSION
11
+ spec.authors = ["Y.Zemlyanukhin"]
12
+ spec.email = ["yaroslav.zemlyanuhin@gmail.com", "y.zemlyanukhin@mdterra.org"]
13
+ spec.description = %q{View helper that alow to select date from calendar using bootstrap library}
14
+ spec.summary = %q{Tag helper for bootstrap datepicker}
15
+ spec.homepage = ""
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rails'
25
+ spec.add_development_dependency 'rspec', '2.9.0'
26
+ spec.add_development_dependency 'rspec-rails'
27
+
28
+ spec.add_runtime_dependency 'bootstrap-datepicker-rails'
29
+ end
data/lib/app/helper.rb ADDED
@@ -0,0 +1,26 @@
1
+ module BootstrapDatepickerTag
2
+ module Helper
3
+ DEF_OPTS = {
4
+ size: 30
5
+ }
6
+
7
+ def datepicker_input_tag(name, value = nil, opts = {})
8
+ options = DEF_OPTS.merge(opts)
9
+ dp_options, tf_options = split_options(options)
10
+ html = text_field_tag(name, value, tf_options)
11
+ method = "datepicker"
12
+ html += javascript_tag "jQuery(document).ready(function(){jQuery('##{name}').#{method}(#{dp_options.to_json})});", type: "text/javascript"
13
+ html.html_safe
14
+ end
15
+
16
+ private
17
+ def available_datepicker_options
18
+ [:language, :format, :autoclose ]
19
+ end
20
+
21
+ def split_options(options)
22
+ tf_options = options.slice!(*available_datepicker_options)
23
+ return options, tf_options
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ # BootstrapDatepickerTag
2
+ require "app/helper.rb"
3
+
4
+ module BootstrapDatepickerTag
5
+ class Railtie < Rails::Railtie
6
+ initializer "BootstrapDatepickerTag" do
7
+ ActionController::Base.helper(BootstrapDatepickerTag::Helper) #should i remove this string?
8
+ ActionView::Base.send(:include, BootstrapDatepickerTag::Helper)
9
+ end
10
+ end
11
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "semver"
2
+
3
+ module BootstrapDatepickerTag
4
+ module Version
5
+ VERSION = '0.1.1'
6
+ end
7
+ end
@@ -0,0 +1,50 @@
1
+ require 'pp'
2
+ require 'spec_helper'
3
+ require 'app/helper'
4
+
5
+ ActionView::Base.send(:include, BootstrapDatepickerTag::Helper)
6
+
7
+ current_value = Time.now.utc
8
+ current_value_date = current_value.to_date
9
+ tomorrow_value_date = (current_value + 1.day).to_date
10
+
11
+
12
+ describe BootstrapDatepickerTag do
13
+
14
+ let :valid_response_input do
15
+ "<input id=\"foo\" name=\"foo\" size=\"30\" type=\"text\" />"
16
+ end
17
+
18
+ let :valid_response_input_with_value do
19
+ "<input id=\"foo\" name=\"foo\" size=\"30\" type=\"text\" value=\"#{ tomorrow_value_date }\" />"
20
+ end
21
+
22
+ let :valid_response_javascript do
23
+ "<script type=\"text/javascript\">\n//<![CDATA[\njQuery(document).ready(function(){jQuery('#foo').datepicker({})});\n//]]>\n</script>"
24
+ end
25
+
26
+ describe BootstrapDatepickerTag::Helper, :type => :view do
27
+
28
+ let :datepicker_input_tag_template do
29
+ <<-EOTEMPLATE
30
+ <%= datepicker_input_tag(:foo) %>
31
+ EOTEMPLATE
32
+ end
33
+
34
+ let :datepicker_input_tag_with_value_template do
35
+ <<-EOTEMPLATE
36
+ <%= datepicker_input_tag(:foo, "#{ tomorrow_value_date }") %>
37
+ EOTEMPLATE
38
+ end
39
+
40
+ it "should return a valid code when calling from the helper tag" do
41
+ render :inline => datepicker_input_tag_template
42
+ rendered.strip.should == valid_response_input + valid_response_javascript
43
+ end
44
+
45
+ it "should return a valid code when calling from the helper tag with value" do
46
+ render :inline => datepicker_input_tag_with_value_template
47
+ rendered.strip.should == valid_response_input_with_value + valid_response_javascript
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_support'
2
+ require 'active_record'
3
+ require 'active_support/deprecation'
4
+ require 'action_view'
5
+ require 'rspec/rails/adapters'
6
+ require 'rspec/rails/example/rails_example_group'
7
+ require 'rspec/rails/matchers'
8
+ require 'rspec/rails/example/view_example_group'
9
+ require 'rspec/rails/mocks'
10
+
11
+
12
+ plugin_spec_dir = File.dirname(__FILE__)
13
+ #ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
14
+
15
+ RSpec.configure do |c|
16
+ c.include RSpec::Rails::ViewExampleGroup, :type => :view
17
+ end
18
+
19
+
20
+ # Class used in the tests to mock a model
21
+ class Foo
22
+ extend ActiveModel::Naming
23
+ include ActiveModel::Conversion
24
+
25
+ def persisted?
26
+ false
27
+ end
28
+
29
+ # Mocking an attribute
30
+ def att1
31
+
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootstrap_datepicker_tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Y.Zemlyanukhin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.9.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bootstrap-datepicker-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: View helper that alow to select date from calendar using bootstrap library
84
+ email:
85
+ - yaroslav.zemlyanuhin@gmail.com
86
+ - y.zemlyanukhin@mdterra.org
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .semver
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bootstrap_datepicker_tag.gemspec
98
+ - lib/app/helper.rb
99
+ - lib/bootstrap_datepicker_tag.rb
100
+ - lib/version.rb
101
+ - spec/bootstrap_datepicker_tag_spec.rb
102
+ - spec/spec_helper.rb
103
+ homepage: ''
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.1.11
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Tag helper for bootstrap datepicker
127
+ test_files:
128
+ - spec/bootstrap_datepicker_tag_spec.rb
129
+ - spec/spec_helper.rb