imptastic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nikolay Kondratyev
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,21 @@
1
+ # Imptastic
2
+
3
+ Custom formtastic inputs
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'imptastic'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install imptastic
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ class ImageInput < Formtastic::Inputs::FileInput
2
+ def image_html_options
3
+ {class: 'image'}.merge(options.fetch(:image_html, {}))
4
+ end
5
+
6
+ def to_html
7
+ input_wrapping do
8
+ label_html <<
9
+ image_html <<
10
+ builder.file_field(method, input_html_options)
11
+ end
12
+ end
13
+
14
+ protected
15
+ def image_html
16
+ return ''.html_safe if builder.object.new_record?
17
+ image = options[:image]
18
+
19
+ url = case image
20
+ when Symbol
21
+ builder.object.send(image)
22
+ when Proc
23
+ image.call(builder.object)
24
+ else
25
+ image.to_s
26
+ end
27
+
28
+ builder.template.image_tag(url, image_html_options).html_safe
29
+ end
30
+ end
data/imptastic.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'imptastic/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "imptastic"
8
+ gem.version = Imptastic::VERSION
9
+ gem.authors = ["Nikolay Kondratyev"]
10
+ gem.email = ["nkondratyev@yandex.ru"]
11
+ gem.description = %q{Custom formtastic inputs}
12
+ gem.summary = %q{Custom formtastic inputs}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency('formtastic', '~> 2.2')
21
+ gem.add_dependency('railties', '~> 3.0')
22
+ end
data/lib/imptastic.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'imptastic/engine'
2
+ require 'imptastic/version'
3
+
4
+ module Imptastic
5
+ end
@@ -0,0 +1,4 @@
1
+ module Imptastic
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Imptastic
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imptastic
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Nikolay Kondratyev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ type: :runtime
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '2.2'
21
+ none: false
22
+ name: formtastic
23
+ prerelease: false
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: '2.2'
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
31
+ type: :runtime
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: '3.0'
37
+ none: false
38
+ name: railties
39
+ prerelease: false
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '3.0'
45
+ none: false
46
+ description: Custom formtastic inputs
47
+ email:
48
+ - nkondratyev@yandex.ru
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - app/inputs/image_input.rb
59
+ - imptastic.gemspec
60
+ - lib/imptastic.rb
61
+ - lib/imptastic/engine.rb
62
+ - lib/imptastic/version.rb
63
+ homepage: ''
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ hash: 4153450942434013182
76
+ version: '0'
77
+ none: false
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ hash: 4153450942434013182
85
+ version: '0'
86
+ none: false
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.25
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Custom formtastic inputs
93
+ test_files: []