expansions 0.1.7 → 0.1.8

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.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/bin/expands +1 -1
  4. data/expansions.gemspec +1 -1
  5. data/lib/{core → expansions}/cli_interface.rb +3 -1
  6. data/lib/expansions/copy.rb +40 -0
  7. data/lib/{core → expansions}/erb_template_file.rb +3 -1
  8. data/lib/expansions/expansion.rb +101 -0
  9. data/lib/{core/kernel.rb → expansions/expansions.rb} +1 -1
  10. data/lib/expansions/file.rb +33 -0
  11. data/lib/{core → expansions}/file_merge.rb +21 -9
  12. data/lib/{core → expansions}/mustache_template_file.rb +3 -1
  13. data/lib/{core → expansions}/startup.rb +5 -3
  14. data/lib/{core → expansions}/string.rb +1 -1
  15. data/lib/{core → expansions}/template_processors.rb +12 -7
  16. data/lib/expansions/template_visitor.rb +29 -0
  17. data/lib/{core → expansions}/version.rb +1 -1
  18. data/lib/expansions.rb +18 -18
  19. data/spec/specs/copy_spec.rb +10 -5
  20. data/spec/specs/copy_to_target_spec.rb +2 -0
  21. data/spec/specs/erb_template_file_spec.rb +2 -2
  22. data/spec/specs/kernel_spec.rb +41 -42
  23. data/spec/specs/mustache_template_file_spec.rb +1 -1
  24. metadata +40 -57
  25. data/.rvmrc +0 -1
  26. data/lib/core/copy.rb +0 -19
  27. data/lib/core/expansion.rb +0 -79
  28. data/lib/core/file.rb +0 -32
  29. data/lib/core/template_visitor.rb +0 -18
  30. /data/lib/{core → expansions}/array.rb +0 -0
  31. /data/lib/{core → expansions}/copy_to_target.rb +0 -0
  32. /data/lib/{core → expansions}/enumerable_extensions.rb +0 -0
  33. /data/lib/{core → expansions}/log.rb +0 -0
  34. /data/lib/{core → expansions}/shell.rb +0 -0
  35. /data/lib/{core → expansions}/shell_action_against_file.rb +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3cc0f8fb5b6756a603b7b6b30a6b942d257aa59a
4
+ data.tar.gz: 2d70f8c6d4290a71a00b7ffeca23e91f2846300f
5
+ SHA512:
6
+ metadata.gz: 2df60f75fae3f8dfc6f2c88391009cc8594f201623deaeaca5197e81db151ff9b9932fbeb62924fee19ce936603d0cde8bc155a83be4034d8915323c378f240c
7
+ data.tar.gz: 99111bcefad4f829eb1ec08d1e269162bb557d57d4446323c9a7a8f897d7f11c2b835989de8feca7181c97bd258bdaa23c204a3979d768d6021fe817f47bc64c
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
1
  pkg
2
2
  .bundle
3
3
  Gemfile.lock
4
+ .rvmrc
5
+ .ruby-version
6
+ .ruby-gemset
data/bin/expands CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'expansions'
4
4
 
5
- Expansions::CLIInterface.new.run(ARGV)
5
+ Expansions::CLIInterface.run(ARGV)
data/expansions.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib",__FILE__)
3
- require "core/version"
3
+ require "expansions/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "expansions"
@@ -1,5 +1,7 @@
1
1
  module Expansions
2
- class CLIInterface
2
+ module CLIInterface
3
+ extend self
4
+
3
5
  def get_expansion_file_name(args)
4
6
  return args.count > 0 ? args[0] : "ExpansionFile"
5
7
  end
@@ -0,0 +1,40 @@
1
+ module Expansions
2
+ class Copy
3
+ include ArrayFu
4
+
5
+ array :sources do
6
+ read_and_write
7
+
8
+ mutator :folder do |item|
9
+ register(item,true)
10
+ end
11
+
12
+ mutator :contents do |item|
13
+ register(item, false)
14
+ end
15
+
16
+ mutator :all_contents_in do |set_of_folders|
17
+ set_of_folders.each do |item|
18
+ contents(item)
19
+ end
20
+ end
21
+
22
+ mutator :all_folders_in do |set_of_folders|
23
+ set_of_folders.each do |item|
24
+ folder(item)
25
+ end
26
+ end
27
+ end
28
+
29
+ def initialize(copy_target)
30
+ array :sources do
31
+ process_using :run, copy_target
32
+ end
33
+ initialize_arrayfu
34
+ end
35
+
36
+ def register(folder, copy_containing_folder=false)
37
+ @sources.push(copy_containing_folder ? folder : File.join(folder,'.'))
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,7 @@
1
1
  module Expansions
2
- class ERBTemplateFile
2
+ module ERBTemplateFile
3
+ extend self
4
+
3
5
  def prepare_template(template)
4
6
  token_regex = /(@\w[\w\.\_]+\w@)/
5
7
 
@@ -0,0 +1,101 @@
1
+ module Expansions
2
+ class Expansion
3
+ include ArrayFu
4
+
5
+ attr_accessor :copies
6
+ attr_accessor :files_to_merge
7
+ attr_accessor :globber
8
+
9
+ array :cleanup_items do
10
+ readable
11
+ process_using :run_cleanup,:call
12
+ end
13
+
14
+ array :setup_items do
15
+ readable
16
+ process_using :run_setup_items,:call
17
+ end
18
+
19
+ array :executable_files do
20
+ readable
21
+ mutator :register_executable
22
+ process_using :mark_files_executable, Expansions::ShellActionAgainstFile.new("chmod +x")
23
+ end
24
+
25
+ array :files_with_line_endings_to_fix do
26
+ readable
27
+ mutator :fix_line_endings_for
28
+ process_using :fix_line_endings, Expansions::ShellActionAgainstFile.new("d2u")
29
+ end
30
+
31
+ array :folders_to_purge do
32
+ readable
33
+ mutator :register_folder_to_purge
34
+ process_using :purge_targets, Expansions::ShellActionAgainstFile.new("rm -rf")
35
+ end
36
+
37
+ def initialize
38
+ initialize_hashes :files_to_merge,:copies
39
+
40
+ @globber = Proc.new do |path|
41
+ glob(path)
42
+ end
43
+
44
+ initialize_arrayfu
45
+ end
46
+
47
+ def copy_to(target, &block)
48
+ copy_proc = Proc.new do |key|
49
+ Copy.new(CopyToTarget.new(key))
50
+ end
51
+ hash_process(target, copies, copy_proc, &block)
52
+ end
53
+
54
+ def merge_to(target, &block)
55
+ merge_proc = Proc.new do |key|
56
+ FileMerge.new(key)
57
+ end
58
+ hash_process(target, files_to_merge, merge_proc, &block)
59
+ end
60
+
61
+ def look_for_templates_in(path)
62
+ globber.call(path).process_all_items_using(TemplateVisitor.instance)
63
+ end
64
+
65
+ def cleanup(&block)
66
+ cleanup_items << block
67
+ end
68
+
69
+ def before(&block)
70
+ setup_items << block
71
+ end
72
+
73
+ def run
74
+ run_setup_items
75
+ purge_targets
76
+ expand_items
77
+ merge_items
78
+ run_cleanup
79
+ fix_line_endings
80
+ mark_files_executable
81
+ end
82
+
83
+ def hash_process(target,hash,factory,&block)
84
+ symbol = target.to_sym
85
+ hash[symbol] = factory.call(target) unless hash.has_key?(symbol)
86
+ hash[symbol].instance_eval(&block)
87
+ end
88
+
89
+ def expand_items
90
+ copies.process_all_values_using do |copy|
91
+ copy.run
92
+ end
93
+ end
94
+
95
+ def merge_items
96
+ files_to_merge.process_all_values_using do |merge|
97
+ merge.run
98
+ end
99
+ end
100
+ end
101
+ end
@@ -1,4 +1,4 @@
1
- module Kernel
1
+ module Expansions
2
2
  def expand(title = "Expansion",&block)
3
3
  Expansions::Expansion.instance.instance_eval(&block)
4
4
  end
@@ -0,0 +1,33 @@
1
+ class File
2
+ class << self
3
+ def open_for_read(file)
4
+ File.open(file,'r').each do|line|
5
+ yield line
6
+ end
7
+ end
8
+
9
+ def read_all_text(file)
10
+ File.read_all_text_after_skipping_lines(file,0)
11
+ end
12
+
13
+ def read_all_text_after_skipping_lines(file,number_of_lines_to_skip)
14
+ index = 1
15
+ contents = ''
16
+
17
+ if File.exist?(file)
18
+ File.open_for_read(file) do |line|
19
+ contents += line if index > number_of_lines_to_skip
20
+ index+=1
21
+ end
22
+ end
23
+
24
+ return contents
25
+ end
26
+
27
+ def open_for_write(file)
28
+ File.open(file,'w') do|new_file|
29
+ yield new_file
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,19 +1,32 @@
1
1
  module Expansions
2
2
  class FileMerge
3
+ include ArrayFu
3
4
  attr_accessor :read_original_contents
4
5
 
5
- def initialize(output_file)
6
- array :before_files do|a|
7
- a.read_and_write
8
- a.mutator :add_before_original_contents do |file| add_merge_file(@before_files,file) end
9
- a.mutator :add do|file| add_before_original_contents(file) end
6
+ array :before_files do
7
+ read_and_write
8
+
9
+ mutator :add_before_original_contents do |file|
10
+ add_merge_file(@before_files,file)
10
11
  end
11
- array :after_files do|a|
12
- a.read_and_write
13
- a.mutator :add_after_original_contents do|file| add_merge_file(@after_files,file) end
12
+
13
+ mutator :add do |file|
14
+ add_before_original_contents(file)
15
+ end
16
+ end
17
+
18
+ array :after_files do
19
+ read_and_write
20
+
21
+ mutator :add_after_original_contents do |file|
22
+ add_merge_file(@after_files,file)
14
23
  end
24
+ end
25
+
26
+ def initialize(output_file)
15
27
  @output_file = output_file
16
28
  @read_original_contents = true
29
+ initialize_arrayfu
17
30
  end
18
31
 
19
32
  def dont_read_original_file_contents
@@ -44,7 +57,6 @@ module Expansions
44
57
  end
45
58
  end
46
59
 
47
- :private
48
60
  def add_merge_file(items,file)
49
61
  return if items.include?(file)
50
62
  items << file if File.exists?(file)
@@ -1,5 +1,7 @@
1
1
  module Expansions
2
- class MustacheTemplateFile
2
+ module MustacheTemplateFile
3
+ extend self
4
+
3
5
  def process(args)
4
6
  template = File.read_all_text(args[:input])
5
7
 
@@ -6,10 +6,12 @@ module Expansions
6
6
  TemplateVisitor,
7
7
  Expansion,
8
8
  Shell
9
- ].each{|item| item.send(:include,Singleton)}
9
+ ].each do |item|
10
+ item.send(:include, Singleton)
11
+ end
10
12
 
11
- TemplateProcessors.instance.register_processor(:erb,ERBTemplateFile.new)
12
- TemplateProcessors.instance.register_processor(:mustache,MustacheTemplateFile.new)
13
+ TemplateProcessors.instance.register_processor(:erb,ERBTemplateFile)
14
+ TemplateProcessors.instance.register_processor(:mustache,MustacheTemplateFile)
13
15
 
14
16
  enable_logging
15
17
  end
@@ -1,5 +1,5 @@
1
1
  class String
2
2
  def as_home_file
3
- File.join(ENV["HOME"],self)
3
+ File.join(ENV["HOME"], self)
4
4
  end
5
5
  end
@@ -1,22 +1,27 @@
1
1
  module Expansions
2
2
  class TemplateProcessors
3
- def initialize(processors = {})
3
+ attr_reader :processors
4
+
5
+ def initialize(processors={})
4
6
  @processors = processors
5
7
  end
6
8
 
7
9
  def get_processor_for(file_name)
8
10
  template_type = File.extname(file_name).gsub(/\./,'').to_sym
9
- raise "There is no processor for #{file_name}" unless processor_exists_for(template_type)
10
- return @processors[template_type]
11
+
12
+ raise "There is no processor for #{file_name}" unless processor?(template_type)
13
+
14
+ return processors[template_type]
11
15
  end
12
16
 
13
17
  def register_processor(template_type,processor)
14
- raise "The processor for the template already exists" if processor_exists_for(template_type)
15
- @processors[template_type.to_sym] = processor
18
+ raise "The processor for the template already exists" if processor?(template_type)
19
+
20
+ processors[template_type.to_sym] = processor
16
21
  end
17
22
 
18
- def processor_exists_for(template_type)
19
- return @processors.has_key?(template_type.to_sym)
23
+ def processor?(template_type)
24
+ return processors.has_key?(template_type.to_sym)
20
25
  end
21
26
  end
22
27
  end
@@ -0,0 +1,29 @@
1
+ module Expansions
2
+ class TemplateVisitor
3
+ attr_reader :processors
4
+ attr_reader :file
5
+
6
+ def initialize(args = {})
7
+ @processors = args.fetch(:processor_registry, TemplateProcessors.instance)
8
+ @file = args.fetch(:file, File)
9
+ end
10
+
11
+ def run_using(file_name)
12
+ processor = processors.get_processor_for(file_name)
13
+ generated_name = File.basename(file_name,File.extname(file_name))
14
+ load_settings_file(generated_name)
15
+ generated_name = generated_name.gsub(/\.dotfile/,"")
16
+ generated_name = ".#{generated_name}" if (/\.dotfile/ =~ file_name)
17
+ output = File.join(File.dirname(file_name),generated_name)
18
+ file.delete(output) if file.exists?(output)
19
+ processor.process(:input => file_name,:output => output)
20
+ end
21
+
22
+ def load_settings_file(file_name)
23
+ settings_file = "#{file_name}.settings"
24
+ if File.exist?(settings_file)
25
+ load settings_file
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Expansions
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/expansions.rb CHANGED
@@ -5,21 +5,21 @@ require 'singleton'
5
5
  require 'mustache'
6
6
  require 'arrayfu'
7
7
 
8
- require 'core/array'
9
- require 'core/cli_interface'
10
- require 'core/copy'
11
- require 'core/copy_to_target'
12
- require 'core/enumerable_extensions'
13
- require 'core/erb_template_file'
14
- require 'core/expansion'
15
- require 'core/file'
16
- require 'core/file_merge'
17
- require 'core/kernel'
18
- require 'core/log'
19
- require 'core/mustache_template_file'
20
- require 'core/shell'
21
- require 'core/shell_action_against_file'
22
- require 'core/startup'
23
- require 'core/string'
24
- require 'core/template_processors'
25
- require 'core/template_visitor'
8
+ require 'expansions/array'
9
+ require 'expansions/cli_interface'
10
+ require 'expansions/copy'
11
+ require 'expansions/copy_to_target'
12
+ require 'expansions/enumerable_extensions'
13
+ require 'expansions/erb_template_file'
14
+ require 'expansions/shell_action_against_file'
15
+ require 'expansions/expansion'
16
+ require 'expansions/file'
17
+ require 'expansions/file_merge'
18
+ require 'expansions/log'
19
+ require 'expansions/mustache_template_file'
20
+ require 'expansions/shell'
21
+ require 'expansions/startup'
22
+ require 'expansions/string'
23
+ require 'expansions/template_processors'
24
+ require 'expansions/template_visitor'
25
+ require 'expansions/expansions'
@@ -2,14 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  module Expansions
4
4
  class AFakeVisitor
5
+ include ArrayFu
6
+
7
+ array :sources do|a|
8
+ a.readable
9
+ a.writable
10
+ a.mutator :run_using
11
+ end
12
+
5
13
  def initialize
6
- array :sources do|a|
7
- a.readable
8
- a.writable
9
- a.mutator :run_using
10
- end
14
+ initialize_arrayfu
11
15
  end
12
16
  end
17
+
13
18
  describe Copy do
14
19
  let(:sources){[]}
15
20
  let(:copy_visitor){AFakeVisitor.new}
@@ -11,9 +11,11 @@ module Expansions
11
11
  Shell.stub(:instance).and_return(shell)
12
12
  @sut = CopyToTarget.new(target)
13
13
  end
14
+
14
15
  before (:each) do
15
16
  @sut.run_using(source)
16
17
  end
18
+
17
19
  it "should copy the source to the target" do
18
20
  shell.should have_received(:run,"cp -rf #{source} #{target}")
19
21
  end
@@ -9,7 +9,7 @@ This is the second line @item@
9
9
  original
10
10
  end
11
11
  context "when preparing a template" do
12
- let(:sut){ERBTemplateFile.new}
12
+ let(:sut){ERBTemplateFile}
13
13
 
14
14
  before (:each) do
15
15
  @result = sut.prepare_template(@original_template)
@@ -28,7 +28,7 @@ This is the second line <%= item %>
28
28
  let(:item){"yo"}
29
29
  let(:file){fake}
30
30
  let(:file_name){"blah.rb"}
31
- let(:sut){ERBTemplateFile.new}
31
+ let(:sut){ERBTemplateFile}
32
32
 
33
33
  before (:each) do
34
34
  @filesystem = RelativeFileSystem.new
@@ -1,56 +1,55 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Kernel
4
- describe Kernel do
5
- context "when globbing for files" do
6
- before (:each) do
7
- @file_system = RelativeFileSystem.new
8
- @file_system.write_file("1.rb","sdfsdfsdf")
9
- @file_system.write_file("2.rb","sdfsdfsdf")
10
- (1..2).each do|item|
11
- @file_system.write_file("#{item}.rb","sdfsdf")
12
- @file_system.write_file(".#{item}","sdfsdf")
13
- (1..2).each do|folder|
14
- new_folder = RelativeFileSystem.file_name("#{folder}")
15
- file = File.join(new_folder,"#{folder}.rb")
16
- @file_system.write_file(file,"sdfsd")
17
- end
3
+ include Expansions
4
+ describe Expansions do
5
+ context "when globbing for files" do
6
+ before (:each) do
7
+ @file_system = RelativeFileSystem.new
8
+ @file_system.write_file("1.rb","sdfsdfsdf")
9
+ @file_system.write_file("2.rb","sdfsdfsdf")
10
+ (1..2).each do|item|
11
+ @file_system.write_file("#{item}.rb","sdfsdf")
12
+ @file_system.write_file(".#{item}","sdfsdf")
13
+ (1..2).each do|folder|
14
+ new_folder = RelativeFileSystem.file_name("#{folder}")
15
+ file = File.join(new_folder,"#{folder}.rb")
16
+ @file_system.write_file(file,"sdfsd")
18
17
  end
19
18
  end
19
+ end
20
20
 
21
- after (:each) do
22
- @file_system.teardown
23
- end
21
+ after (:each) do
22
+ # @file_system.teardown
23
+ end
24
24
 
25
- context "and no block is given" do
26
- before (:each) do
27
- @result = glob(File.join(RelativeFileSystem.base_path,"**/*"))
28
- end
25
+ context "and no block is given" do
26
+ before (:each) do
27
+ @result = glob(File.join(RelativeFileSystem.base_path,"**/*"))
28
+ end
29
29
 
30
- it "should return all files in path including dotfiles" do
31
- @result.count.should == 38
32
- end
30
+ it "should return all files in path including dotfiles" do
31
+ @result.count.should == 16
33
32
  end
34
- context "and a block is given" do
35
- before (:each) do
36
- @items_visited = 0
37
- end
38
- before (:each) do
39
- @result = glob(File.join(RelativeFileSystem.base_path,"**/*")) do |file|
40
- @items_visited += 1
41
- end
33
+ end
34
+ context "and a block is given" do
35
+ before (:each) do
36
+ @items_visited = 0
37
+ end
38
+ before (:each) do
39
+ @result = glob(File.join(RelativeFileSystem.base_path,"**/*")) do |file|
40
+ @items_visited += 1
42
41
  end
42
+ end
43
43
 
44
- it "should return all files in path including dotfiles" do
45
- @result.count.should == 38
46
- end
44
+ it "should return all files in path including dotfiles" do
45
+ @result.count.should == 16
46
+ end
47
47
 
48
- it "should have run the block against each file" do
49
- @items_visited.should == 38
50
- end
51
-
48
+ it "should have run the block against each file" do
49
+ @items_visited.should == 16
52
50
  end
53
51
 
54
52
  end
55
- end
56
- end
53
+
54
+ end
55
+ end
@@ -11,7 +11,7 @@ This is the second line {{ item }}
11
11
  end
12
12
  context "when processing" do
13
13
  let(:item){"yo"}
14
- let(:sut){MustacheTemplateFile.new}
14
+ let(:sut){MustacheTemplateFile}
15
15
 
16
16
  configatron.configure_from_hash :hello => "world"
17
17
 
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expansions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
5
- prerelease:
4
+ version: 0.1.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Develop With Passion®
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-25 00:00:00.000000000 Z
11
+ date: 2013-06-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: guard
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: guard-rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fakes-rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rb-notifu
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: configatron
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: 2.9.0
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: 2.9.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: mustache
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: arrayfu
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: Automation utitlity that I use to support cross platform file maintenance
@@ -132,33 +117,32 @@ extensions: []
132
117
  extra_rdoc_files: []
133
118
  files:
134
119
  - .gitignore
135
- - .rvmrc
136
120
  - Gemfile
137
121
  - Guardfile
138
122
  - README.md
139
123
  - Rakefile
140
124
  - bin/expands
141
125
  - expansions.gemspec
142
- - lib/core/array.rb
143
- - lib/core/cli_interface.rb
144
- - lib/core/copy.rb
145
- - lib/core/copy_to_target.rb
146
- - lib/core/enumerable_extensions.rb
147
- - lib/core/erb_template_file.rb
148
- - lib/core/expansion.rb
149
- - lib/core/file.rb
150
- - lib/core/file_merge.rb
151
- - lib/core/kernel.rb
152
- - lib/core/log.rb
153
- - lib/core/mustache_template_file.rb
154
- - lib/core/shell.rb
155
- - lib/core/shell_action_against_file.rb
156
- - lib/core/startup.rb
157
- - lib/core/string.rb
158
- - lib/core/template_processors.rb
159
- - lib/core/template_visitor.rb
160
- - lib/core/version.rb
161
126
  - lib/expansions.rb
127
+ - lib/expansions/array.rb
128
+ - lib/expansions/cli_interface.rb
129
+ - lib/expansions/copy.rb
130
+ - lib/expansions/copy_to_target.rb
131
+ - lib/expansions/enumerable_extensions.rb
132
+ - lib/expansions/erb_template_file.rb
133
+ - lib/expansions/expansion.rb
134
+ - lib/expansions/expansions.rb
135
+ - lib/expansions/file.rb
136
+ - lib/expansions/file_merge.rb
137
+ - lib/expansions/log.rb
138
+ - lib/expansions/mustache_template_file.rb
139
+ - lib/expansions/shell.rb
140
+ - lib/expansions/shell_action_against_file.rb
141
+ - lib/expansions/startup.rb
142
+ - lib/expansions/string.rb
143
+ - lib/expansions/template_processors.rb
144
+ - lib/expansions/template_visitor.rb
145
+ - lib/expansions/version.rb
162
146
  - spec/spec_helper.rb
163
147
  - spec/specs/array_spec.rb
164
148
  - spec/specs/copy_spec.rb
@@ -176,27 +160,26 @@ files:
176
160
  - spec/specs/template_visitor_spec.rb
177
161
  homepage: http://www.developwithpassion.com
178
162
  licenses: []
163
+ metadata: {}
179
164
  post_install_message:
180
165
  rdoc_options: []
181
166
  require_paths:
182
167
  - lib
183
168
  required_ruby_version: !ruby/object:Gem::Requirement
184
- none: false
185
169
  requirements:
186
- - - ! '>='
170
+ - - '>='
187
171
  - !ruby/object:Gem::Version
188
172
  version: '0'
189
173
  required_rubygems_version: !ruby/object:Gem::Requirement
190
- none: false
191
174
  requirements:
192
- - - ! '>='
175
+ - - '>='
193
176
  - !ruby/object:Gem::Version
194
177
  version: '0'
195
178
  requirements: []
196
179
  rubyforge_project: expansions
197
- rubygems_version: 1.8.21
180
+ rubygems_version: 2.0.3
198
181
  signing_key:
199
- specification_version: 3
182
+ specification_version: 4
200
183
  summary: Simple Expansion Automation Utility
201
184
  test_files:
202
185
  - spec/spec_helper.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.3@expansions --create
data/lib/core/copy.rb DELETED
@@ -1,19 +0,0 @@
1
- module Expansions
2
- class Copy
3
- def initialize(copy_target)
4
- array :sources do|a|
5
- a.read_and_write
6
- a.mutator :folder do|item| register(item,true) end
7
- a.mutator :contents do|item| register(item,false) end
8
- a.mutator :all_contents_in do|set_of_folders| set_of_folders.each{|item| contents(item)} end
9
- a.mutator :all_folders_in do|set_of_folders| set_of_folders.each{|item| folder(item)} end
10
- a.process_using :run, copy_target
11
- end
12
- end
13
-
14
- :private
15
- def register(folder,copy_containing_folder = false)
16
- @sources.push(copy_containing_folder ? folder : File.join(folder,'.'))
17
- end
18
- end
19
- end
@@ -1,79 +0,0 @@
1
- module Expansions
2
- class Expansion
3
- attr_accessor :copies,:files_to_merge,:globber
4
-
5
- def initialize
6
- initialize_hashes :files_to_merge,:copies
7
-
8
- @globber = lambda{|path| return glob(path)}
9
-
10
- array :cleanup_items do|a|
11
- a.readable
12
- a.process_using :run_cleanup,:call
13
- end
14
-
15
- array :setup_items do|a|
16
- a.readable
17
- a.process_using :run_setup_items,:call
18
- end
19
-
20
- array :executable_files do|a|
21
- a.mutator :register_executable
22
- a.process_using :mark_files_executable,ShellActionAgainstFile.new("chmod +x")
23
- end
24
-
25
- array :files_with_line_endings_to_fix do|a|
26
- a.mutator :fix_line_endings_for
27
- a.process_using :fix_line_endings,ShellActionAgainstFile.new("d2u")
28
- end
29
-
30
- array :folders_to_purge do|a|
31
- a.mutator :register_folder_to_purge
32
- a.process_using :purge_targets,ShellActionAgainstFile.new("rm -rf")
33
- end
34
- end
35
-
36
- def copy_to target,&block
37
- hash_process(target,@copies,lambda{|key| return Copy.new(CopyToTarget.new(key))},&block)
38
- end
39
-
40
- def merge_to target,&block
41
- hash_process(target,@files_to_merge,lambda{|key| return FileMerge.new(key)},&block)
42
- end
43
-
44
- def look_for_templates_in(path)
45
- @globber.call(path).process_all_items_using(TemplateVisitor.instance)
46
- end
47
-
48
- def cleanup(&block)
49
- @cleanup_items << block
50
- end
51
-
52
- def before(&block)
53
- @setup_items << block
54
- end
55
-
56
- def run
57
- run_setup_items
58
- purge_targets
59
- expand_items
60
- merge_items
61
- run_cleanup
62
- fix_line_endings
63
- mark_files_executable
64
- end
65
-
66
- :private
67
- def hash_process(target,hash,factory,&block)
68
- symbol = target.to_sym
69
- hash[symbol] = factory.call(target) unless hash.has_key?(symbol)
70
- hash[symbol].instance_eval(&block)
71
- end
72
- def expand_items
73
- @copies.process_all_values_using{|copy| copy.run}
74
- end
75
- def merge_items
76
- @files_to_merge.process_all_values_using{|merge| merge.run}
77
- end
78
- end
79
- end
data/lib/core/file.rb DELETED
@@ -1,32 +0,0 @@
1
- class File
2
- def self.open_for_read(file)
3
- File.open(file,'r').each do|line|
4
- yield line
5
- end
6
- end
7
-
8
- def self.read_all_text(file)
9
- File.read_all_text_after_skipping_lines(file,0)
10
- end
11
-
12
- def self.read_all_text_after_skipping_lines(file,number_of_lines_to_skip)
13
- index = 1
14
- contents = ''
15
-
16
- if File.exist?(file)
17
- File.open_for_read(file) do |line|
18
- contents += line if index > number_of_lines_to_skip
19
- index+=1
20
- end
21
- end
22
-
23
- return contents
24
- end
25
-
26
- def self.open_for_write(file)
27
- File.open(file,'w') do|new_file|
28
- yield new_file
29
- end
30
- end
31
-
32
- end
@@ -1,18 +0,0 @@
1
- module Expansions
2
- class TemplateVisitor
3
- def initialize(args = {})
4
- @processor_registry = args.fetch(:processor_registry,TemplateProcessors.instance)
5
- @file = args.fetch(:file,File)
6
- end
7
-
8
- def run_using(file_name)
9
- processor = @processor_registry.get_processor_for(file_name)
10
- generated_name = File.basename(file_name,File.extname(file_name))
11
- generated_name = generated_name.gsub(/\.dotfile/,"")
12
- generated_name = ".#{generated_name}" if (/\.dotfile/ =~ file_name)
13
- output = File.join(File.dirname(file_name),generated_name)
14
- @file.delete(output) if @file.exists?(output)
15
- processor.process(:input => file_name,:output => output)
16
- end
17
- end
18
- end
File without changes
File without changes
File without changes
File without changes
File without changes