aina 0.3.1 → 0.4.0
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/bin/aina +4 -3
- data/lib/aina.rb +43 -43
- data/lib/aina/generable.rb +1 -1
- data/lib/aina/generable/base.rb +6 -6
- data/lib/aina/generable/types/template.rb +16 -0
- data/lib/aina/version.rb +1 -1
- data/templates/page_template.php +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 777ecbb66ab8549f2260e94e85c9142c3d4750b7
|
4
|
+
data.tar.gz: a1218454e0ae08658c4c1f4e6674472d6b4c95cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
data/lib/aina.rb
CHANGED
@@ -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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
data/lib/aina/generable.rb
CHANGED
data/lib/aina/generable/base.rb
CHANGED
@@ -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
|
-
@
|
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
|
-
@
|
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
|
-
|
49
|
+
text.gsub!(/#{replace}/, self.send(attribute))
|
50
50
|
end
|
51
|
-
File.open(@file, "w") {|file| file.puts
|
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}/#{
|
83
|
+
Dir.pwd + "/#{@dir}/#{name}.php"
|
84
84
|
else
|
85
|
-
Dir.pwd + "/#{
|
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
|
+
|
data/lib/aina/version.rb
CHANGED
@@ -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.
|
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-
|
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: []
|