mjollnir 0.0.1 → 0.1.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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Mjolnir
1
+ # Mjollnir
2
2
 
3
3
  A gem for prepending and appending text to rails generated files.
4
4
 
@@ -1,3 +1,3 @@
1
1
  module Mjollnir
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/mjollnir.rb CHANGED
@@ -8,28 +8,29 @@ module Mjollnir
8
8
  def template(source, *args, &block)
9
9
  inside_template do
10
10
  super
11
+ if File.exists?("lib/mjollnir") && File.directory?("lib/mjollnir")
12
+ target_file = args.first|| source.sub(/\.tt$/, '')
11
13
 
12
- target_file = args.first|| source.sub(/\.tt$/, '')
13
-
14
- prependable = ERB.new(::File.binread("lib/mjollnir/prepend.rb"), nil, '-', '@output_buffer')
15
- appendable = ERB.new(::File.binread("lib/mjollnir/append.rb"), nil, '-', '@output_buffer')
14
+ prependable = ERB.new(::File.binread("lib/mjollnir/prepend.rb"), nil, '-', '@output_buffer')
15
+ appendable = ERB.new(::File.binread("lib/mjollnir/append.rb"), nil, '-', '@output_buffer')
16
16
 
17
- target_file_type = target_file.split('.').pop
17
+ target_file_type = target_file.split('.').pop
18
18
 
19
- commentstarts = Hash[*File.read('lib/mjollnir/comment_starts.csv').split(/[, \n]+/)]
20
- commentends = Hash[*File.read('lib/mjollnir/comment_ends.csv').split(/[, \n]+/)]
21
- universal_comment_start = commentstarts[target_file_type]
22
- universal_comment_end = commentends[target_file_type]
19
+ commentstarts = Hash[*File.read('lib/mjollnir/comment_starts.csv').split(/[, \n]+/)]
20
+ commentends = Hash[*File.read('lib/mjollnir/comment_ends.csv').split(/[, \n]+/)]
21
+ universal_comment_start = commentstarts[target_file_type]
22
+ universal_comment_end = commentends[target_file_type]
23
23
 
24
- # Bind the variables to the ERB results
25
- preargs = [
26
- prependable.result(binding)
27
- ]
28
- postargs = [
29
- appendable.result(binding)
30
- ]
31
- prepend_to_file(target_file, *preargs, &block)
32
- append_to_file(target_file, *postargs, &block)
24
+ # Bind the variables to the ERB results
25
+ preargs = [
26
+ prependable.result(binding)
27
+ ]
28
+ postargs = [
29
+ appendable.result(binding)
30
+ ]
31
+ prepend_to_file(target_file, *preargs, &block)
32
+ append_to_file(target_file, *postargs, &block)
33
+ end
33
34
  end
34
35
  end
35
36
  puts "Whosoever holds this hammer, if he be worthy, shall possess the power of Thor"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mjollnir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-08 00:00:00.000000000 Z
12
+ date: 2012-10-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A gem for prepending and appending generated files from any rails generator,
15
15
  though the power of Thor.