formic 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.1
data/formic.gemspec ADDED
@@ -0,0 +1,146 @@
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 = %q{formic}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Vinh Tran"]
12
+ s.date = %q{2011-10-14}
13
+ s.description = %q{use formic to generate markup from sematic syntax. formic DRY your template and make it readable. It also seperate the sematic of the content from the actual markup, make it possible to render multiple view for the same content}
14
+ s.email = %q{vtran@realestate.com.au}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "formic.gemspec",
25
+ "javascripts/jquery-1.6.2.min.js",
26
+ "javascripts/jquery-ui-1.8.16.custom.min.js",
27
+ "lib/formic.rb",
28
+ "lib/formic/base.rb",
29
+ "lib/formic/button.rb",
30
+ "lib/formic/checkbox.rb",
31
+ "lib/formic/file.rb",
32
+ "lib/formic/form.rb",
33
+ "lib/formic/helper.rb",
34
+ "lib/formic/hidden.rb",
35
+ "lib/formic/input.rb",
36
+ "lib/formic/list.rb",
37
+ "lib/formic/list_item.rb",
38
+ "lib/formic/list_items.rb",
39
+ "lib/formic/password.rb",
40
+ "lib/formic/railtie.rb",
41
+ "lib/formic/selection.rb",
42
+ "lib/formic/tab.rb",
43
+ "lib/formic/tab_panel.rb",
44
+ "lib/formic/textarea.rb",
45
+ "spec/formic/base_spec.rb",
46
+ "spec/formic/button_spec.rb",
47
+ "spec/formic/checkbox_spec.rb",
48
+ "spec/formic/file_spec.rb",
49
+ "spec/formic/form_spec.rb",
50
+ "spec/formic/helper_spec.rb",
51
+ "spec/formic/hidden_spec.rb",
52
+ "spec/formic/input_spec.rb",
53
+ "spec/formic/list_item_spec.rb",
54
+ "spec/formic/list_items_spec.rb",
55
+ "spec/formic/list_spec.rb",
56
+ "spec/formic/password_spec.rb",
57
+ "spec/formic/selection_spec.rb",
58
+ "spec/formic/tab_panel_spec.rb",
59
+ "spec/formic/tab_spec.rb",
60
+ "spec/formic/textarea_spec.rb",
61
+ "spec/formic_spec_helper.rb",
62
+ "spec/spec_helper.rb",
63
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png",
64
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png",
65
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_flat_10_000000_40x100.png",
66
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png",
67
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png",
68
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png",
69
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png",
70
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png",
71
+ "stylesheets/jquery-ui/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png",
72
+ "stylesheets/jquery-ui/ui-lightness/images/ui-icons_222222_256x240.png",
73
+ "stylesheets/jquery-ui/ui-lightness/images/ui-icons_228ef1_256x240.png",
74
+ "stylesheets/jquery-ui/ui-lightness/images/ui-icons_ef8c08_256x240.png",
75
+ "stylesheets/jquery-ui/ui-lightness/images/ui-icons_ffd27a_256x240.png",
76
+ "stylesheets/jquery-ui/ui-lightness/images/ui-icons_ffffff_256x240.png",
77
+ "stylesheets/jquery-ui/ui-lightness/jquery-ui-1.8.16.custom.css",
78
+ "views/formic/default/_button.html.haml",
79
+ "views/formic/default/_form.html.haml",
80
+ "views/formic/default/_hidden.html.haml",
81
+ "views/formic/default/_input.html.haml",
82
+ "views/formic/default/_list.html.haml",
83
+ "views/formic/default/_list_item.html.haml",
84
+ "views/formic/default/_list_items.html.haml",
85
+ "views/formic/default/_selection.html.haml",
86
+ "views/formic/default/_tab.html.haml",
87
+ "views/formic/default/_tab_panel.html.haml",
88
+ "views/formic/default/_textarea.html.haml"
89
+ ]
90
+ s.homepage = %q{http://github.com/vinhtiensinh/formic}
91
+ s.licenses = ["MIT"]
92
+ s.require_paths = ["lib"]
93
+ s.rubygems_version = %q{1.5.2}
94
+ s.summary = %q{formic is a html markup generator}
95
+ s.test_files = [
96
+ "spec/formic/base_spec.rb",
97
+ "spec/formic/button_spec.rb",
98
+ "spec/formic/checkbox_spec.rb",
99
+ "spec/formic/file_spec.rb",
100
+ "spec/formic/form_spec.rb",
101
+ "spec/formic/helper_spec.rb",
102
+ "spec/formic/hidden_spec.rb",
103
+ "spec/formic/input_spec.rb",
104
+ "spec/formic/list_item_spec.rb",
105
+ "spec/formic/list_items_spec.rb",
106
+ "spec/formic/list_spec.rb",
107
+ "spec/formic/password_spec.rb",
108
+ "spec/formic/selection_spec.rb",
109
+ "spec/formic/tab_panel_spec.rb",
110
+ "spec/formic/tab_spec.rb",
111
+ "spec/formic/textarea_spec.rb",
112
+ "spec/formic_spec_helper.rb",
113
+ "spec/spec_helper.rb"
114
+ ]
115
+
116
+ if s.respond_to? :specification_version then
117
+ s.specification_version = 3
118
+
119
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
120
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
121
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
122
+ s.add_runtime_dependency(%q<rr>, [">= 0"])
123
+ s.add_runtime_dependency(%q<rspec>, [">= 0"])
124
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
125
+ s.add_runtime_dependency(%q<simplecov>, [">= 0"])
126
+ s.add_runtime_dependency(%q<jeweler>, ["~> 1.5.2"])
127
+ else
128
+ s.add_dependency(%q<i18n>, [">= 0"])
129
+ s.add_dependency(%q<haml>, [">= 0"])
130
+ s.add_dependency(%q<rr>, [">= 0"])
131
+ s.add_dependency(%q<rspec>, [">= 0"])
132
+ s.add_dependency(%q<activesupport>, [">= 0"])
133
+ s.add_dependency(%q<simplecov>, [">= 0"])
134
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
135
+ end
136
+ else
137
+ s.add_dependency(%q<i18n>, [">= 0"])
138
+ s.add_dependency(%q<haml>, [">= 0"])
139
+ s.add_dependency(%q<rr>, [">= 0"])
140
+ s.add_dependency(%q<rspec>, [">= 0"])
141
+ s.add_dependency(%q<activesupport>, [">= 0"])
142
+ s.add_dependency(%q<simplecov>, [">= 0"])
143
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
144
+ end
145
+ end
146
+
data/lib/formic/base.rb CHANGED
@@ -32,7 +32,7 @@ module Formic
32
32
 
33
33
  def method_missing method, *args, &block
34
34
  _initialize *args, &block
35
- self.options[:class].push method.to_s
35
+ self.add_class(method.to_s)
36
36
  return self
37
37
  end
38
38
 
@@ -57,6 +57,10 @@ module Formic
57
57
  @options.merge!(new_options).merge!(:class => classes)
58
58
  end
59
59
 
60
+ def add_class classname
61
+ self.options[:class].push classname
62
+ end
63
+
60
64
  def options
61
65
  @options[:class] = @options[:class].uniq
62
66
  return @options
data/lib/formic/helper.rb CHANGED
@@ -24,7 +24,7 @@ module Formic
24
24
  :form,
25
25
  :tab_panel,
26
26
  :button,
27
- :textarea,
27
+ :textarea
28
28
  )
29
29
 
30
30
  def get_class symbol
@@ -0,0 +1,29 @@
1
+ require 'forwardable'
2
+
3
+ module Formic
4
+ class ListItems < Base
5
+ default_template 'formic/default/list_items'
6
+
7
+ attr_reader :items
8
+ extend Forwardable
9
+ def_delegators :@items, :size, :push, :pop, :<<, :[], :shift, :unshift, :each, :length, :first, :last
10
+
11
+ def _initialize list=[], options={}, &block
12
+ super &block
13
+ @items = []
14
+
15
+ list.each do |item|
16
+ @items.push ListItem.new(self.page, item, options)
17
+ end
18
+
19
+ return self
20
+ end
21
+
22
+ def add_class class_name
23
+ @items.each do |item|
24
+ item.add_class class_name
25
+ end
26
+ end
27
+
28
+ end
29
+ end
data/lib/formic.rb CHANGED
@@ -14,4 +14,5 @@ require 'formic/tab_panel'
14
14
  require 'formic/tab'
15
15
  require 'formic/list'
16
16
  require 'formic/list_item'
17
+ require 'formic/list_items'
17
18
  require 'formic/railtie' if defined?(Rails)
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Formic::ListItems do
4
+ before(:each) do
5
+ @model = Object.new
6
+ stub(@page).render
7
+
8
+ @options = {}
9
+ @block = Proc.new {}
10
+ end
11
+
12
+ context "#initialize" do
13
+ before(:each) do
14
+ @list_items = Formic::ListItems.new @page
15
+ @list_items.style ['Item 1', 'Item 2'], @options, &@block
16
+ end
17
+
18
+ it "should have template formic/default/list_items" do
19
+ @list_items.template.should == 'formic/default/list_items'
20
+ end
21
+
22
+ it "it should have a list of items with same style, options" do
23
+ @list_items.first.text.should == 'Item 1'
24
+ @list_items.first.options.should == @options.merge(:class => ['list_item', 'style'])
25
+
26
+ @list_items.last.text.should == 'Item 2'
27
+ @list_items.last.options.should == @options.merge(:class => ['list_item', 'style'])
28
+ end
29
+
30
+ it "should have the block" do
31
+ @list_items.content.should == @block
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,2 @@
1
+ - element.each do |item|
2
+ %li{item.options}= item.text
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: formic
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vinh Tran
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-30 00:00:00 +10:00
13
+ date: 2011-10-14 00:00:00 +11:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -104,6 +104,7 @@ files:
104
104
  - README.rdoc
105
105
  - Rakefile
106
106
  - VERSION
107
+ - formic.gemspec
107
108
  - javascripts/jquery-1.6.2.min.js
108
109
  - javascripts/jquery-ui-1.8.16.custom.min.js
109
110
  - lib/formic.rb
@@ -117,6 +118,7 @@ files:
117
118
  - lib/formic/input.rb
118
119
  - lib/formic/list.rb
119
120
  - lib/formic/list_item.rb
121
+ - lib/formic/list_items.rb
120
122
  - lib/formic/password.rb
121
123
  - lib/formic/railtie.rb
122
124
  - lib/formic/selection.rb
@@ -132,6 +134,7 @@ files:
132
134
  - spec/formic/hidden_spec.rb
133
135
  - spec/formic/input_spec.rb
134
136
  - spec/formic/list_item_spec.rb
137
+ - spec/formic/list_items_spec.rb
135
138
  - spec/formic/list_spec.rb
136
139
  - spec/formic/password_spec.rb
137
140
  - spec/formic/selection_spec.rb
@@ -161,6 +164,7 @@ files:
161
164
  - views/formic/default/_input.html.haml
162
165
  - views/formic/default/_list.html.haml
163
166
  - views/formic/default/_list_item.html.haml
167
+ - views/formic/default/_list_items.html.haml
164
168
  - views/formic/default/_selection.html.haml
165
169
  - views/formic/default/_tab.html.haml
166
170
  - views/formic/default/_tab_panel.html.haml
@@ -179,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
183
  requirements:
180
184
  - - ">="
181
185
  - !ruby/object:Gem::Version
182
- hash: 260134870330165761
186
+ hash: -1315801625866261702
183
187
  segments:
184
188
  - 0
185
189
  version: "0"
@@ -206,6 +210,7 @@ test_files:
206
210
  - spec/formic/hidden_spec.rb
207
211
  - spec/formic/input_spec.rb
208
212
  - spec/formic/list_item_spec.rb
213
+ - spec/formic/list_items_spec.rb
209
214
  - spec/formic/list_spec.rb
210
215
  - spec/formic/password_spec.rb
211
216
  - spec/formic/selection_spec.rb