to_quickform 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +8 -98
- data/lib/to_quickform/erb_factory.rb +8 -0
- data/lib/to_quickform/erb_templates.rb +5 -0
- data/lib/to_quickform/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 472bee2e9c8b28462114e72a754288b81b023a6d
|
4
|
+
data.tar.gz: d16dda85ab2d34520a2aab0109b098b4df2a3e05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e417c2880afdbee3708be94c93530767ada4df347cfd198869e3593271ad584669ad0d57300b1379a5026c081ba244a2c3abc44f854ff8815742113bb3466836
|
7
|
+
data.tar.gz: c99221caf26b28bef77233e23ef4f6b7981b84a4dcdde64576059474457f0aecfe97134d2f9425eaf41ece085e56ad3ecce0aa87a7257f1685fc215e070567d6
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
###
|
23
|
+
### Parsing an YAML/JSON
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
generator = ToQuickform.YAML(yaml)
|
@@ -39,116 +39,26 @@ See https://github.com/tsmsogn/to_quickform/blob/master/spec/fixtures/sample.jso
|
|
39
39
|
|
40
40
|
```ruby
|
41
41
|
generator.to_set_defaults
|
42
|
-
# $form->setDefaults(array(
|
43
|
-
# 'gender' => 'female'
|
44
|
-
# ));
|
45
42
|
```
|
46
43
|
|
44
|
+
Output https://github.com/tsmsogn/to_quickform/blob/master/spec/fixtures/set_defaults.txt
|
45
|
+
|
47
46
|
### Creating addElement()/createElement() codes
|
48
47
|
|
49
48
|
```ruby
|
50
49
|
generator.to_create_element
|
51
|
-
# // name
|
52
|
-
# $form->addElement('text', 'name', '', '');
|
53
|
-
# // mail
|
54
|
-
# $form->addElement('text', 'mail', '', '');
|
55
|
-
# // mail_conf
|
56
|
-
# $form->addElement('text', 'mail_conf', '', '');
|
57
|
-
# // gender
|
58
|
-
# $tmp = array();
|
59
|
-
# $tmp[] = $form->createElement('radio', '', '', '女性', 'female');
|
60
|
-
# $tmp[] = $form->createElement('radio', '', '', '男性', 'male');
|
61
|
-
# $form->addGroup($tmp, 'gender', '', '');
|
62
|
-
# // zip_code
|
63
|
-
# $tmp = array();
|
64
|
-
# $tmp[] = $form->createElement('text', '', '', 'maxlength="3"', '');
|
65
|
-
# $tmp[] = $form->createElement('text', '', '', 'maxlength="4"', '');
|
66
|
-
# $form->addGroup($tmp, 'zip_code', '', ' - ');
|
67
|
-
# // state
|
68
|
-
# $form->addElement('select', 'state', '', array(
|
69
|
-
# '' => '選択してください',
|
70
|
-
# 1 => '北海道',
|
71
|
-
# 2 => '青森県',
|
72
|
-
# 3 => '岩手県',
|
73
|
-
# 4 => '宮城県',
|
74
|
-
# 5 => '秋田県',
|
75
|
-
# 6 => '山形県',
|
76
|
-
# 7 => '福島県',
|
77
|
-
# 8 => '茨城県',
|
78
|
-
# 9 => '栃木県',
|
79
|
-
# 10 => '群馬県',
|
80
|
-
# 11 => '埼玉県',
|
81
|
-
# 12 => '千葉県',
|
82
|
-
# 13 => '東京都',
|
83
|
-
# 14 => '神奈川県',
|
84
|
-
# 15 => '新潟県',
|
85
|
-
# 16 => '富山県',
|
86
|
-
# 17 => '石川県',
|
87
|
-
# 18 => '福井県',
|
88
|
-
# 19 => '山梨県',
|
89
|
-
# 20 => '長野県',
|
90
|
-
# 21 => '岐阜県',
|
91
|
-
# 22 => '静岡県',
|
92
|
-
# 23 => '愛知県',
|
93
|
-
# 24 => '三重県',
|
94
|
-
# 25 => '滋賀県',
|
95
|
-
# 26 => '京都府',
|
96
|
-
# 27 => '大阪府',
|
97
|
-
# 28 => '兵庫県',
|
98
|
-
# 29 => '奈良県',
|
99
|
-
# 30 => '和歌山県',
|
100
|
-
# 31 => '鳥取県',
|
101
|
-
# 32 => '島根県',
|
102
|
-
# 33 => '岡山県',
|
103
|
-
# 34 => '広島県',
|
104
|
-
# 35 => '山口県',
|
105
|
-
# 36 => '徳島県',
|
106
|
-
# 37 => '香川県',
|
107
|
-
# 38 => '愛媛県',
|
108
|
-
# 39 => '高知県',
|
109
|
-
# 40 => '福岡県',
|
110
|
-
# 41 => '佐賀県',
|
111
|
-
# 42 => '長崎県',
|
112
|
-
# 43 => '熊本県',
|
113
|
-
# 44 => '大分県',
|
114
|
-
# 45 => '宮崎県',
|
115
|
-
# 46 => '鹿児島県',
|
116
|
-
# 47 => '沖縄県'
|
117
|
-
# ), 'class="p-region"');
|
118
|
-
# // city
|
119
|
-
# $form->addElement('text', 'city', '', 'class="p-locality"');
|
120
|
-
# // address
|
121
|
-
# $form->addElement('text', 'address', '', 'class="p-street-address p-extended-address"');
|
122
|
-
# // pc
|
123
|
-
# $tmp = array();
|
124
|
-
# $tmp[] = $form->createElement('checkbox', 'windows', '', 'Windows', '');
|
125
|
-
# $tmp[] = $form->createElement('checkbox', 'linux', '', 'Linux', '');
|
126
|
-
# $form->addGroup($tmp, 'pc', '', '');
|
127
|
-
# // note
|
128
|
-
# $form->addElement('textarea', 'note', '', '');
|
129
|
-
# // privacy_policy
|
130
|
-
# $form->addElement('checkbox', 'privacy_policy', '', '同意する');
|
131
50
|
```
|
132
51
|
|
133
|
-
|
52
|
+
Output https://github.com/tsmsogn/to_quickform/blob/master/spec/fixtures/create_element.txt
|
53
|
+
|
54
|
+
### Creating addRule()/addGrouoRule() codes
|
134
55
|
|
135
56
|
```ruby
|
136
57
|
generator.to_add_rule
|
137
|
-
# $form->addRule('name', '名前を入力してください', 'required');
|
138
|
-
# $form->addRule('mail', 'メールアドレスを入力してください', 'required');
|
139
|
-
# $form->addRule('mail', '正しいメールアドレスを入力してください', 'regex', '/^[^@]+@[^.]+\..+$/');
|
140
|
-
# $form->addRule(array('mail', 'mail_conf'), 'メールアドレスが一致しません', 'compare');
|
141
|
-
# $form->addRule('mail_conf', '確認用メールアドレスを入力してください', 'required');
|
142
|
-
# $form->addRule('mail_conf', '正しい確認用メールアドレスを入力してください', 'regex', '/^[^@]+@[^.]+\..+$/');
|
143
|
-
# $form->addRule('gender', '性別を選択してください', 'required');
|
144
|
-
# $form->addGroupRule('zip_code', '郵便番号を入力してください', 'required');
|
145
|
-
# $form->addGroupRule('zip_code', '郵便番号を数字で入力してください', 'numeric');
|
146
|
-
# $form->addRule('state', '都道府県を選択してください', 'required');
|
147
|
-
# $form->addRule('city', '市区町村を入力してください', 'required');
|
148
|
-
# $form->addRule('pc', 'PCを選択してください', 'required');
|
149
|
-
# $form->addRule('privacy_policy', '「同意する」にチェックしてください', 'required');
|
150
58
|
```
|
151
59
|
|
60
|
+
Output https://github.com/tsmsogn/to_quickform/blob/master/spec/fixtures/add_rule.txt
|
61
|
+
|
152
62
|
## Development
|
153
63
|
|
154
64
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -44,14 +44,22 @@ module ToQuickform
|
|
44
44
|
ToQuickform::ERBTemplates::BASIC_CHECKBOX_ELEMENT_TEMPLATE
|
45
45
|
when "group"
|
46
46
|
ToQuickform::ERBTemplates::BASIC_GROUP_ELEMENT_TEMPLATE
|
47
|
+
when "hidden"
|
48
|
+
ToQuickform::ERBTemplates::BASIC_VALUE_ELEMENT_TEMPLATE
|
49
|
+
when "password"
|
50
|
+
ToQuickform::ERBTemplates::BASIC_ELEMENT_TEMPLATE
|
47
51
|
when "radio"
|
48
52
|
ToQuickform::ERBTemplates::BASIC_RADIO_ELEMENT_TEMPLATE
|
53
|
+
when "reset"
|
54
|
+
ToQuickform::ERBTemplates::BASIC_VALUE_ELEMENT_TEMPLATE
|
49
55
|
when "select"
|
50
56
|
ToQuickform::ERBTemplates::BASIC_SELECT_ELEMENT_TEMPLATE
|
51
57
|
when "text"
|
52
58
|
ToQuickform::ERBTemplates::BASIC_ELEMENT_TEMPLATE
|
53
59
|
when "textarea"
|
54
60
|
ToQuickform::ERBTemplates::BASIC_ELEMENT_TEMPLATE
|
61
|
+
when "submit"
|
62
|
+
ToQuickform::ERBTemplates::BASIC_VALUE_ELEMENT_TEMPLATE
|
55
63
|
end
|
56
64
|
end
|
57
65
|
end
|
@@ -46,6 +46,11 @@ PHP
|
|
46
46
|
BASIC_SELECT_ELEMENT_TEMPLATE = <<PHP
|
47
47
|
// <%= element.name %>
|
48
48
|
$form->addElement('<%= element.type %>', '<%= element.name %>', '', <%= ToPhpArray.dump(element.value, { :wrap => true }) %>, '<%= element.attribute %>');
|
49
|
+
PHP
|
50
|
+
|
51
|
+
BASIC_VALUE_ELEMENT_TEMPLATE = <<PHP
|
52
|
+
// <%= element.name %>
|
53
|
+
$form->addElement('<%= element.type %>', '<%= element.name %>', '<%= element.value %>', '<%= element.attribute %>');
|
49
54
|
PHP
|
50
55
|
|
51
56
|
BASIC_CREATE_ELEMENT_TEMPLATE = <<PHP
|
data/lib/to_quickform/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_quickform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tsmsogn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|