has_bootstrap 0.0.2 → 0.1.0
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/Gemfile +8 -0
- data/Gemfile.lock +25 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +27 -0
- data/Rakefile +25 -58
- data/has_bootstrap.gemspec +58 -0
- data/init.rb +2 -1
- data/lib/has_bootstrap/model.rb +57 -0
- data/lib/has_bootstrap/railtie.rb +11 -0
- data/lib/has_bootstrap/version.rb +14 -0
- data/lib/has_bootstrap.rb +5 -47
- metadata +102 -48
- data/README +0 -21
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.8.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rdoc
|
10
|
+
json (1.7.5)
|
11
|
+
magic_encoding (0.0.2)
|
12
|
+
rake (10.0.2)
|
13
|
+
rdoc (3.12)
|
14
|
+
json (~> 1.4)
|
15
|
+
whitespace (2.0.4)
|
16
|
+
yard (0.8.2.1)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
jeweler (~> 1.8.3)
|
23
|
+
magic_encoding (~> 0.0.2)
|
24
|
+
whitespace (~> 2.0.4)
|
25
|
+
yard (~> 0.8.2.1)
|
data/{LICENSE → LICENSE.md}
RENAMED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# HasBootstrap [](https://secure.travis-ci.org/#!/tbpro/has_bootstrap)
|
2
|
+
|
3
|
+
Add bootstrap functionality to your ActiveRecord models
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'has_bootstrap'
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
class Color < ActiveRecord::Base
|
15
|
+
has_bootstrap(
|
16
|
+
{ id: 1, name: 'red' },
|
17
|
+
{ id: 2, name: 'blue' },
|
18
|
+
{ id: 3, name: 'green' }
|
19
|
+
)
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Credits
|
24
|
+
|
25
|
+
The project <tt>has_bootstrap</tt> have been inspired by pluginaweek. Take a look at the [git repositories](https://github.com/pluginaweek).
|
26
|
+
|
27
|
+
Copyright (c) 2011 Thomas Boerger <tboerger@tbpro.de>
|
data/Rakefile
CHANGED
@@ -2,67 +2,34 @@
|
|
2
2
|
# Copyright (c) 2011. All rights reserved.
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
require 'rubygems/package_task'
|
6
|
-
require 'rubygems/specification'
|
7
|
-
require 'rake'
|
8
|
-
require 'rake/testtask'
|
9
|
-
require 'rdoc/task'
|
10
|
-
require 'rcov/rcovtask'
|
11
|
-
require 'date'
|
12
|
-
|
13
|
-
GEM_TITLE = 'has_bootstrap'
|
14
|
-
GEM_VERSION = '0.0.2'
|
15
|
-
|
16
|
-
spec = Gem::Specification.new do |s|
|
17
|
-
s.name = GEM_TITLE
|
18
|
-
s.version = GEM_VERSION
|
19
|
-
s.platform = Gem::Platform::RUBY
|
20
|
-
s.extra_rdoc_files = ['README', 'LICENSE']
|
21
|
-
s.rdoc_options << '--line-numbers' << '--main=README'
|
22
|
-
s.summary = 'Has bootstrap'
|
23
|
-
s.description = 'Bootstrap for ActiveRecord models'
|
24
|
-
s.author = 'Thomas Boerger'
|
25
|
-
s.email = 'tboerger@tbpro.de'
|
26
|
-
s.homepage = 'http://github.com/tbpro/has_bootstrap'
|
27
|
-
s.files = %w(LICENSE README Rakefile init.rb) + Dir.glob('{app,generators,lib,test}/**/*')
|
28
|
-
s.test_files = Dir["test/**/*_test.rb"]
|
29
|
-
end
|
30
5
|
|
31
|
-
|
32
|
-
|
6
|
+
begin
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
12
|
+
exit e.status_code
|
33
13
|
end
|
34
14
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
15
|
+
require 'rake'
|
16
|
+
require 'jeweler'
|
17
|
+
require 'yard'
|
18
|
+
|
19
|
+
$:.push File.expand_path('../lib', __FILE__)
|
20
|
+
require 'has_bootstrap/version'
|
21
|
+
|
22
|
+
Jeweler::Tasks.new do |gem|
|
23
|
+
gem.name = 'has_bootstrap'
|
24
|
+
gem.version = HasBootstrap::Version::STRING
|
25
|
+
gem.homepage = 'https://github.com/tbpro/has_bootstrap'
|
26
|
+
gem.license = 'MIT'
|
27
|
+
gem.summary = %Q{Bootstrap for ActiveRecord models}
|
28
|
+
gem.email = 'tboerger@tbpro.de'
|
29
|
+
gem.authors = ['Thomas Boerger']
|
48
30
|
end
|
49
31
|
|
50
|
-
|
51
|
-
|
52
|
-
# t.libs << 'lib'
|
53
|
-
# t.test_files = spec.test_files
|
54
|
-
# t.verbose = true
|
55
|
-
#end
|
56
|
-
|
57
|
-
#desc 'Rcov for gem'
|
58
|
-
#Rcov::RcovTask.new(:rcov) do |t|
|
59
|
-
# t.libs << 'lib'
|
60
|
-
# t.test_files = spec.test_files
|
61
|
-
# t.rcov_opts << '--exclude="^(?!lib/|app/)"'
|
62
|
-
# t.verbose = true
|
63
|
-
#end
|
32
|
+
Jeweler::RubygemsDotOrgTasks.new
|
33
|
+
YARD::Rake::YardocTask.new
|
64
34
|
|
65
|
-
|
66
|
-
task :default do
|
67
|
-
puts `rake -T`.grep(/^[^(].*$/)
|
68
|
-
end
|
35
|
+
task :default => :version
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "has_bootstrap"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Thomas Boerger"]
|
12
|
+
s.date = "2012-11-28"
|
13
|
+
s.email = "tboerger@tbpro.de"
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE.md",
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"Gemfile",
|
20
|
+
"Gemfile.lock",
|
21
|
+
"LICENSE.md",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"has_bootstrap.gemspec",
|
25
|
+
"init.rb",
|
26
|
+
"lib/has_bootstrap.rb",
|
27
|
+
"lib/has_bootstrap/model.rb",
|
28
|
+
"lib/has_bootstrap/railtie.rb",
|
29
|
+
"lib/has_bootstrap/version.rb"
|
30
|
+
]
|
31
|
+
s.homepage = "https://github.com/tbpro/has_bootstrap"
|
32
|
+
s.licenses = ["MIT"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = "1.8.24"
|
35
|
+
s.summary = "Bootstrap for ActiveRecord models"
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_development_dependency(%q<yard>, ["~> 0.8.2.1"])
|
42
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
43
|
+
s.add_development_dependency(%q<magic_encoding>, ["~> 0.0.2"])
|
44
|
+
s.add_development_dependency(%q<whitespace>, ["~> 2.0.4"])
|
45
|
+
else
|
46
|
+
s.add_dependency(%q<yard>, ["~> 0.8.2.1"])
|
47
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
48
|
+
s.add_dependency(%q<magic_encoding>, ["~> 0.0.2"])
|
49
|
+
s.add_dependency(%q<whitespace>, ["~> 2.0.4"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<yard>, ["~> 0.8.2.1"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
54
|
+
s.add_dependency(%q<magic_encoding>, ["~> 0.0.2"])
|
55
|
+
s.add_dependency(%q<whitespace>, ["~> 2.0.4"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
data/init.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# Created by Thomas Boerger on 2012-11-28.
|
3
|
+
# Copyright (c) 2011. All rights reserved.
|
4
|
+
|
5
|
+
module HasBootstrap
|
6
|
+
module Model
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def has_bootstrap(*records)
|
14
|
+
primary_key = self.primary_key.to_sym
|
15
|
+
records.flatten!
|
16
|
+
|
17
|
+
ids = records.map { |record| record[primary_key] }.compact
|
18
|
+
delete_all(ids.any? ? ["#{primary_key} NOT IN (?)", ids] : nil)
|
19
|
+
|
20
|
+
existing = all.inject({}) do |existing, record|
|
21
|
+
existing[record.send(primary_key)] = record
|
22
|
+
existing
|
23
|
+
end
|
24
|
+
|
25
|
+
records.map! do |attributes|
|
26
|
+
attributes.symbolize_keys!
|
27
|
+
defaults = attributes.delete(:defaults)
|
28
|
+
|
29
|
+
record = if record = existing[attributes[primary_key]]
|
30
|
+
if defaults
|
31
|
+
attributes.merge! defaults.delete_if do |attribute, value|
|
32
|
+
record.send("#{attribute}?")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
record.attributes = attributes
|
37
|
+
record
|
38
|
+
else
|
39
|
+
attributes.merge!(defaults) if defaults
|
40
|
+
new(attributes)
|
41
|
+
end
|
42
|
+
|
43
|
+
record.send(
|
44
|
+
"#{primary_key}=",
|
45
|
+
attributes[primary_key]
|
46
|
+
)
|
47
|
+
|
48
|
+
record.save!
|
49
|
+
record
|
50
|
+
end
|
51
|
+
|
52
|
+
records
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# Created by Thomas Boerger on 2012-11-28.
|
3
|
+
# Copyright (c) 2011. All rights reserved.
|
4
|
+
|
5
|
+
module HasBootstrap
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
ActiveSupport.on_load :active_record do
|
8
|
+
include HasBootstrap::Model
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# Created by Thomas Boerger on 2012-11-28.
|
3
|
+
# Copyright (c) 2011. All rights reserved.
|
4
|
+
|
5
|
+
module HasBootstrap
|
6
|
+
module Version
|
7
|
+
MAJOR = 0
|
8
|
+
MINOR = 1
|
9
|
+
PATCH = 0
|
10
|
+
BUILD = nil
|
11
|
+
|
12
|
+
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
13
|
+
end
|
14
|
+
end
|
data/lib/has_bootstrap.rb
CHANGED
@@ -1,53 +1,11 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
1
2
|
# Created by Thomas Boerger on 2011-07-01.
|
2
3
|
# Copyright (c) 2011. All rights reserved.
|
3
4
|
|
4
5
|
module HasBootstrap
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
extend HasBootstrap::ClassMethods
|
9
|
-
include HasBootstrap::InstanceMethods
|
10
|
-
end
|
11
|
-
|
12
|
-
primary_key = self.primary_key.to_sym
|
13
|
-
records.flatten!
|
14
|
-
|
15
|
-
ids = records.map { |record| record[primary_key] }.compact
|
16
|
-
delete_all(ids.any? ? ["#{primary_key} NOT IN (?)", ids] : nil)
|
17
|
-
|
18
|
-
existing = all.inject({}) { |existing, record| existing[record.send(primary_key)] = record; existing }
|
19
|
-
|
20
|
-
records.map! do |attributes|
|
21
|
-
attributes.symbolize_keys!
|
22
|
-
defaults = attributes.delete(:defaults)
|
23
|
-
|
24
|
-
record = if record = existing[attributes[primary_key]]
|
25
|
-
attributes.merge!(defaults.delete_if { |attribute, value| record.send("#{attribute}?") }) if defaults
|
26
|
-
record.attributes = attributes
|
27
|
-
|
28
|
-
record
|
29
|
-
else
|
30
|
-
attributes.merge!(defaults) if defaults
|
31
|
-
new(attributes)
|
32
|
-
end
|
33
|
-
|
34
|
-
record.send("#{primary_key}=", attributes[primary_key])
|
35
|
-
|
36
|
-
record.save!
|
37
|
-
record
|
38
|
-
end
|
39
|
-
|
40
|
-
records
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module ClassMethods
|
45
|
-
end
|
46
|
-
|
47
|
-
module InstanceMethods
|
48
|
-
end
|
6
|
+
autoload :Version, 'has_bootstrap/version'
|
7
|
+
autoload :Railtie, 'has_bootstrap/railtie'
|
8
|
+
autoload :Model, 'has_bootstrap/model'
|
49
9
|
end
|
50
10
|
|
51
|
-
|
52
|
-
extend HasBootstrap::MacroMethods
|
53
|
-
end
|
11
|
+
require 'has_bootstrap/railtie' if defined? Rails
|
metadata
CHANGED
@@ -1,71 +1,125 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_bootstrap
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Thomas Boerger
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: yard
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.2.1
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.2.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jeweler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.8.3
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.8.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: magic_encoding
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.0.2
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.2
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: whitespace
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.0.4
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.0.4
|
78
|
+
description:
|
22
79
|
email: tboerger@tbpro.de
|
23
80
|
executables: []
|
24
|
-
|
25
81
|
extensions: []
|
26
|
-
|
27
|
-
|
28
|
-
- README
|
29
|
-
|
30
|
-
|
31
|
-
-
|
32
|
-
-
|
82
|
+
extra_rdoc_files:
|
83
|
+
- LICENSE.md
|
84
|
+
- README.md
|
85
|
+
files:
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
88
|
+
- LICENSE.md
|
89
|
+
- README.md
|
33
90
|
- Rakefile
|
91
|
+
- has_bootstrap.gemspec
|
34
92
|
- init.rb
|
35
93
|
- lib/has_bootstrap.rb
|
36
|
-
|
37
|
-
|
38
|
-
|
94
|
+
- lib/has_bootstrap/model.rb
|
95
|
+
- lib/has_bootstrap/railtie.rb
|
96
|
+
- lib/has_bootstrap/version.rb
|
97
|
+
homepage: https://github.com/tbpro/has_bootstrap
|
98
|
+
licenses:
|
99
|
+
- MIT
|
39
100
|
post_install_message:
|
40
|
-
rdoc_options:
|
41
|
-
|
42
|
-
- --main=README
|
43
|
-
require_paths:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
44
103
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
105
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
segments:
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
segments:
|
52
111
|
- 0
|
53
|
-
|
54
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
hash: -2672859310885189518
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
114
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
63
119
|
requirements: []
|
64
|
-
|
65
120
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.
|
121
|
+
rubygems_version: 1.8.24
|
67
122
|
signing_key:
|
68
123
|
specification_version: 3
|
69
|
-
summary:
|
124
|
+
summary: Bootstrap for ActiveRecord models
|
70
125
|
test_files: []
|
71
|
-
|
data/README
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# has_bootstrap
|
2
|
-
|
3
|
-
Add bootstrap functionality to your ActiveRecord models.
|
4
|
-
|
5
|
-
## Install
|
6
|
-
|
7
|
-
gem 'has_bootstrap'
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
class Color < ActiveRecord::Base
|
12
|
-
has_bootstrap(
|
13
|
-
{:id => 1, :name => 'red'},
|
14
|
-
{:id => 2, :name => 'blue'},
|
15
|
-
{:id => 3, :name => 'green'}
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
## Credits
|
20
|
-
|
21
|
-
The project <tt>has_bootstrap</tt> have been inspired by pluginaweek. Take a look at the [git repositories](https://github.com/pluginaweek).
|