aina 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aina +4 -0
- data/lib/aina/addable.rb +9 -3
- data/lib/aina/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: 1f74db6cccb4e55a0dcc50e35ba247f9fc4e334d
|
4
|
+
data.tar.gz: abb397bd128d8c751e025497e7e58e0786f38e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a49993a6a3f8b3d8f90b4f7d1f8b2424ccf6c4856f4526ddc826f51ed02dcf72f8a19d175a607f76d9b250d80e3f9e37fa11cf6fa0ab20654eaba33154d9d7e
|
7
|
+
data.tar.gz: 5b3f44b1c3f998457219f1f8a92c7c1b45e8fac61f638d006f751f65da8155a42f067ebd9adc405cf44e465cd138d070b8d4529a33ff4cd6278094e161003565
|
data/bin/aina
CHANGED
@@ -50,6 +50,10 @@ command [:generate, :g] do |c|
|
|
50
50
|
element = Object.const_get(Generable.class_name_for @type).new(@name, options)
|
51
51
|
unless File.exists?(element.file)
|
52
52
|
element.generate
|
53
|
+
unless args.empty?
|
54
|
+
add = Addable.new(@name, args)
|
55
|
+
add.add_custom_fields
|
56
|
+
end
|
53
57
|
else
|
54
58
|
raise Exception, "A #{@type} named #{element.name} already exists. Action aborted."
|
55
59
|
end
|
data/lib/aina/addable.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class Addable
|
2
2
|
attr_accessor :name, :aina_version, :fields
|
3
3
|
|
4
|
+
VALID_TYPES = %w(text url email textarea datetime datetime-local radio checkbox select)
|
5
|
+
|
4
6
|
def initialize(name, fields = nil)
|
5
7
|
@type = 'post_type'
|
6
8
|
@name = validate_name(name)
|
@@ -13,8 +15,12 @@ class Addable
|
|
13
15
|
@fields = Array.new
|
14
16
|
fields.each do |f|
|
15
17
|
a = f.split(':')
|
16
|
-
|
17
|
-
|
18
|
+
if ! a[1].nil? and VALID_TYPES.include? a[1]
|
19
|
+
@fields << {key: a[0], type: a[1]}
|
20
|
+
else
|
21
|
+
raise Exception, "Type was missing for #{a[0]}" if a[1].nil?
|
22
|
+
raise Exception, "#{a[1]} is not a valid type. Valid types are #{VALID_TYPES.join(', ')}"
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
@@ -24,7 +30,7 @@ class Addable
|
|
24
30
|
a += "'#{f[:key]}' => array(\n"
|
25
31
|
a += " 'label' => '#{f[:key].capitalize}',\n"
|
26
32
|
a += " 'type' => '#{f[:type]}',\n"
|
27
|
-
a += " 'options' => array('option_1', 'option_2'
|
33
|
+
a += " 'options' => array( 'option_1' => __('Option One'), 'option_2' => __('Option One') ),\n" if %w(radio checkbox select).include?(f[:type])
|
28
34
|
a += "),\n"
|
29
35
|
end
|
30
36
|
a
|
data/lib/aina/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carles Jove i Buxeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|