aina 0.3.1 → 0.4.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: db21e4343a920a1d5951e3d6f078818626c4cc99
4
- data.tar.gz: bab1e169e9148830547d0808106d344299fe78c9
3
+ metadata.gz: 777ecbb66ab8549f2260e94e85c9142c3d4750b7
4
+ data.tar.gz: a1218454e0ae08658c4c1f4e6674472d6b4c95cc
5
5
  SHA512:
6
- metadata.gz: 75cb5a61346befb320b56659ca3a0283ba8fb87ec19462a3ccee9f55729cd9039ac6fcfe2ba94a2a16b90d3cdac2f9c35519dd1ea93c5fba9d0d15ee3d6fcca3
7
- data.tar.gz: f3ac885478fbf93a3ff07344b5c6f52d03b3a2ab553ef6e9673935fe80df39d37f98307008507a1a7679bcf9f4ac4d22b7c029bfa3324e602e706abf9407de7e
6
+ metadata.gz: 33ed2de1d86828cafcd629c45a8f29fef14443801e11532fa86a71343c80ed3013fe4e1a2f2133110014c697b031892db02f7b559487509aa425dc84de89f8d2
7
+ data.tar.gz: b1f8612835c38e20d72e3297c3e07c257305fce6b6a72e7dd11c897f9970955716ebdbed03027358efe47ca4b67ab88482430a85e154be2f0f3a2ca57e189c40
data/bin/aina CHANGED
@@ -39,7 +39,7 @@ command [:generate, :g] do |c|
39
39
  c.action do |global_options,options,args|
40
40
  @type = args.shift
41
41
  @name = args.shift
42
-
42
+
43
43
  if @type.nil?
44
44
  raise NoMethodError, 'You need to generate something'
45
45
  elsif @name.nil?
@@ -57,7 +57,7 @@ command [:generate, :g] do |c|
57
57
  else
58
58
  raise Exception, "A #{@type} named #{element.name} already exists. Action aborted."
59
59
  end
60
-
60
+
61
61
  output = "A #{@type} with name #{element.name} has been succesfully generated"
62
62
  if options[:i]
63
63
  output += ". Also, Aina's framework has been added.\n"
@@ -65,7 +65,8 @@ command [:generate, :g] do |c|
65
65
 
66
66
  puts output
67
67
  else
68
- raise Exception, "#{@type} is not a generable piece of code. Options are: #{Generable.generable_types.join(', ')}"
68
+ raise Exception, "#{@type} is not a generable piece of code. " <<
69
+ "Options are: #{Generable.generable_types.join(', ')}"
69
70
  end
70
71
  end
71
72
  end
@@ -7,47 +7,47 @@ Dir.glob(File.dirname(__FILE__) + "/aina/generable/types/*.rb") { |file| requir
7
7
  Dir.glob(File.expand_path('..') + "/templates/*") { |file| require file }
8
8
 
9
9
  module Aina
10
- def self.aina_version
11
- Aina::VERSION
12
- end
13
-
14
- def self.install(output = false)
15
- unless Dir.exists?(Dir.pwd + '/inc')
16
- Dir.mkdir(Dir.pwd + '/inc')
17
- end
18
-
19
- # Install Aina
20
- unless self.is_installed?
21
- text = File.read(Aina::TEMPLATES_DIR + '/aina_framework.php')
22
-
23
- ['{{aina_version}}'].each do |replace|
24
- attribute = replace.gsub(/[{}]/, '')
25
- @output = text.gsub!(/#{replace}/, self.send(attribute))
26
- end
27
-
28
- File.open(Dir.pwd + "/inc/aina.php", "w") {|file| file.puts @output}
29
-
30
- message = "Aina has been installed in your WordPress theme.\n"
31
- message += "\n\nIf you want your post type to be automatically included, put this is functions.php:\n"
32
- message += "function aina_post_types() {\n"
33
- message += " return array('your_post_type', 'another_post_type', 'etc');\n"
34
- message += "}\n"
35
- else
36
- message = "Aina was already installed in your WordPress theme ;-)\n"
37
- end
38
-
39
- # Include Aina
40
- unless functions_php_exists?
41
- create_empty_functions_php
42
- end
43
- File.open(functions_php, "a+") {|file| file.puts aina_inclusion}
44
-
45
- if output
46
- puts message
47
- end
48
- end
49
-
50
- def self.is_installed?
51
- File.exists?(Dir.pwd + "/inc/aina.php")
52
- end
10
+ def self.aina_version
11
+ Aina::VERSION
12
+ end
13
+
14
+ def self.install(output = false)
15
+ unless Dir.exists?(Dir.pwd + '/inc')
16
+ Dir.mkdir(Dir.pwd + '/inc')
17
+ end
18
+
19
+ # Install Aina
20
+ unless self.is_installed?
21
+ text = File.read(Aina::TEMPLATES_DIR + '/aina_framework.php')
22
+
23
+ ['{{aina_version}}'].each do |replace|
24
+ attribute = replace.gsub(/[{}]/, '')
25
+ @output = text.gsub!(/#{replace}/, self.send(attribute))
26
+ end
27
+
28
+ File.open(Dir.pwd + "/inc/aina.php", "w") {|file| file.puts @output}
29
+
30
+ message = "Aina has been installed in your WordPress theme.\n"
31
+ message += "\n\nIf you want your post type to be automatically included, put this is functions.php:\n"
32
+ message += "function aina_post_types() {\n"
33
+ message += " return array('your_post_type', 'another_post_type', 'etc');\n"
34
+ message += "}\n"
35
+ else
36
+ message = "Aina was already installed in your WordPress theme ;-)\n"
37
+ end
38
+
39
+ # Include Aina
40
+ unless functions_php_exists?
41
+ create_empty_functions_php
42
+ end
43
+ File.open(functions_php, "a+") {|file| file.puts aina_inclusion}
44
+
45
+ if output
46
+ puts message
47
+ end
48
+ end
49
+
50
+ def self.is_installed?
51
+ File.exists?(Dir.pwd + "/inc/aina.php")
52
+ end
53
53
  end
@@ -49,7 +49,7 @@ module Generable
49
49
  end
50
50
 
51
51
  def get_replacements
52
- @replacements
52
+ @replacements || []
53
53
  end
54
54
 
55
55
  def after_generate(*callbacks)
@@ -4,7 +4,7 @@ class Generable::Base
4
4
  attr_reader :name, :template, :file, :aina_version, :supports
5
5
 
6
6
  def initialize(name, options=nil)
7
- @name = format_name(name)
7
+ @original_name = format_name(name)
8
8
  @options = options
9
9
  @aina_version = Aina::VERSION
10
10
  @template = self.template
@@ -22,7 +22,7 @@ class Generable::Base
22
22
  end
23
23
 
24
24
  def name
25
- @name.split(' ').join('_').downcase
25
+ @original_name
26
26
  end
27
27
 
28
28
  def set_custom_vars
@@ -46,9 +46,9 @@ class Generable::Base
46
46
  text = File.read(@template)
47
47
  replacements.each do |replace|
48
48
  attribute = replace.gsub(/[{}]/, '')
49
- @output = text.gsub!(/#{replace}/, self.send(attribute))
49
+ text.gsub!(/#{replace}/, self.send(attribute))
50
50
  end
51
- File.open(@file, "w") {|file| file.puts @output}
51
+ File.open(@file, "w") {|file| file.puts text}
52
52
 
53
53
  after_generate
54
54
  end
@@ -80,9 +80,9 @@ class Generable::Base
80
80
  unless Dir.exists?(Dir.pwd + '/' + @dir)
81
81
  Dir.mkdir(Dir.pwd + '/' + @dir)
82
82
  end
83
- Dir.pwd + "/#{@dir}/#{@name}.php"
83
+ Dir.pwd + "/#{@dir}/#{name}.php"
84
84
  else
85
- Dir.pwd + "/#{@name}.php"
85
+ Dir.pwd + "/#{name}.php"
86
86
  end
87
87
  end
88
88
  end
@@ -0,0 +1,16 @@
1
+ class Template < Generable::Base
2
+ template "page_template.php"
3
+ replacements %w(display_name)
4
+
5
+ def name
6
+ "template-#{@original_name}"
7
+ end
8
+
9
+ def display_name
10
+ @original_name.
11
+ split("_").
12
+ map { |w| w.capitalize! }.
13
+ join(" ")
14
+ end
15
+ end
16
+
@@ -1,3 +1,3 @@
1
1
  module Aina
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -0,0 +1,22 @@
1
+ <?php
2
+ /**
3
+ * Template Name: {{display_name}}
4
+ * Generated with Aina. Version {{aina_version}}
5
+ */
6
+
7
+ get_header(); ?>
8
+
9
+ <div id="primary" class="content-area">
10
+ <main id="main" class="site-main" role="main">
11
+
12
+ <?php while ( have_posts() ) : the_post(); ?>
13
+
14
+ <?php get_template_part( 'content', 'page' ); ?>
15
+
16
+ <?php endwhile; // end of the loop. ?>
17
+
18
+ </main><!-- #main -->
19
+ </div><!-- #primary -->
20
+
21
+ <?php get_footer(); ?>
22
+
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.3.1
4
+ version: 0.4.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: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -83,11 +83,13 @@ files:
83
83
  - lib/aina/generable.rb
84
84
  - lib/aina/generable/base.rb
85
85
  - lib/aina/generable/types/post_type.rb
86
+ - lib/aina/generable/types/template.rb
86
87
  - lib/aina/globals.rb
87
88
  - lib/aina/support.rb
88
89
  - lib/aina/version.rb
89
90
  - templates/add.php
90
91
  - templates/aina_framework.php
92
+ - templates/page_template.php
91
93
  - templates/post_type.php
92
94
  homepage: http://joanielena.cat
93
95
  licenses: []