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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1ee20e663d5cd2e08e1c012abeeae4ab9428d4d
4
- data.tar.gz: 1cb219d075351636ad8e235e5da73d2335af8e0f
3
+ metadata.gz: 1f74db6cccb4e55a0dcc50e35ba247f9fc4e334d
4
+ data.tar.gz: abb397bd128d8c751e025497e7e58e0786f38e0d
5
5
  SHA512:
6
- metadata.gz: 3bd6f9a5e6709b4e6a32d61ce166509702d1729d87b0728c9abdf290b35b6dad8bc02ea1e89c1fc0579fd59b009ba5aeef748967060b53e50d13e016acffa88b
7
- data.tar.gz: eb5a6b60bd5ecfcf1721d15f89b55fa2fc77a6c72a8d3cf949232353d85e309214d71f4108dd9bf4b48c9638b58a732c0ea64032810f55eddebaab3e68c77023
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
@@ -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
- # TODO: Validate type against a whitelist
17
- @fields << {key: a[0], type: a[1]}
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', 'etc'),\n" if %w(radio checkbox select).include?(f[:type])
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
@@ -1,3 +1,3 @@
1
1
  module Aina
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
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.2.2
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-23 00:00:00.000000000 Z
11
+ date: 2014-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake