iron_hammer 0.3.6 → 0.3.7

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/PostInstall.txt CHANGED
@@ -17,8 +17,7 @@ $ rake iron:test:unit
17
17
  --- rakefile.rb
18
18
  require 'iron_hammer'
19
19
 
20
- @anvil = Anvil.load_solution_from '.'
21
- @anvil.load_projects_from_solution
20
+ @anvil = Anvil.load_from '.'
22
21
  @hammer = Hammer.new :visual_studio_path => VISUAL_STUDIO_PATH
23
22
  sh @hammer.build @anvil.solution
24
23
  sh @hammer.test *@anvil.test_projects
data/README.rdoc CHANGED
@@ -20,9 +20,7 @@ Iron Hammer gathers together three components to help automate the build, test a
20
20
  == SYNOPSIS:
21
21
 
22
22
  # Reading the solution file information from the current directory
23
- a = Anvil.load_solution_from '.'
24
- # Reading the project information based on the solution read before
25
- a.load_projects_from_solution
23
+ a = Anvil.load_from '.'
26
24
  # Initializing a new Hammer
27
25
  h = Hammer.new
28
26
  # Getting the command line for building a solution
@@ -32,7 +30,8 @@ Iron Hammer gathers together three components to help automate the build, test a
32
30
 
33
31
  == REQUIREMENTS:
34
32
 
35
- rubyzip2 (>= 2.0.1)
33
+ rubyzip2 (>= 2.0.1)
34
+ builder (>= 2.1.2)
36
35
 
37
36
  == INSTALL:
38
37
 
@@ -44,7 +43,7 @@ Iron Hammer gathers together three components to help automate the build, test a
44
43
 
45
44
  MACSkeptic Iron-Hammer
46
45
 
47
- Copyright (c) 2010 Mozair Alves do Carmo Junior, http://codevil.com/
46
+ Copyright (c) 2010 Mozair Alves do Carmo Junior, http://codevil.com
48
47
 
49
48
  Permission is hereby granted, free of charge, to any person obtaining
50
49
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ $hoe = Hoe.spec 'iron_hammer' do
12
12
  self.rubyforge_name = self.name
13
13
  self.extra_deps = [['rubyzip2','>= 2.0.1'],
14
14
  ['builder', '>= 2.1.2']]
15
- self.version = '0.3.6'
15
+ self.version = '0.3.7'
16
16
  end
17
17
 
18
18
  require 'newgem/tasks'
@@ -5,26 +5,11 @@ require 'iron_hammer/solutions/solution_file'
5
5
  module IronHammer
6
6
  class Anvil
7
7
  attr_accessor :solution
8
- attr_accessor :projects
9
8
 
10
- def initialize params={}
11
- @solution = params[:solution]
12
- @projects = params[:projects]
13
- end
14
-
15
- def load_projects_from_solution
16
- @projects = @projects || []
17
- @solution.file.projects.each do |p|
18
- @projects << IronHammer::Projects::ProjectFile.type_of(
19
- @solution.path,
20
- path = p[:path],
21
- csproj = p[:csproj]).
22
- send(:new, p)
23
- end
24
- end
25
-
26
- def self.load_solution_from *path
27
- pattern = File.join path, '*.sln'
9
+ def self.load_from *path
10
+ target = path
11
+ target = '.' if path.nil? || path.empty?
12
+ pattern = File.join target, '*.sln'
28
13
  entries = Dir[pattern]
29
14
  anvil = Anvil.new(
30
15
  :solution => IronHammer::Solutions::Solution.new(
@@ -34,13 +19,30 @@ module IronHammer
34
19
  )
35
20
  ) unless entries.nil? || entries.empty?
36
21
  end
22
+
23
+ def projects
24
+ @projects ||= (@solution.file.projects.collect do |p|
25
+ ProjectFile.load_from(root_path = @solution.path, project_path = p[:path], csproj = p[:csproj]).type.new(p)
26
+ end)
27
+ end
37
28
 
38
29
  def dll_projects
39
- @projects.select {|p| p.is_a? DllProject}
30
+ @dll_projects ||= projects.select {|p| p.is_a? DllProject}
40
31
  end
41
32
 
42
33
  def test_projects
43
- @projects.select {|p| p.is_a? TestProject}
34
+ @test_projects ||= projects.select {|p| p.is_a? TestProject}
35
+ end
36
+
37
+ def load_projects_from_solution #deprecated!
38
+ Kernel::warn '[DEPRECATION] `load_projects_from_solution` is deprecated and now it is a no-op. ' +
39
+ 'Please, just use `projects` instead - they will be loaded in a lazy fashion ;)'
40
+ end
41
+
42
+ private
43
+ def initialize params={}
44
+ @solution = params[:solution]
45
+ @projects = params[:projects]
44
46
  end
45
47
  end unless defined? Anvil
46
48
  end
@@ -23,7 +23,7 @@ module IronHammer
23
23
  end
24
24
 
25
25
  def dependencies
26
- @dependencies ||= ProjectFile.dependencies_of(File.read [@path, @csproj].patheticalize)
26
+ @dependencies ||= file.dependencies
27
27
  end
28
28
 
29
29
  def package params={}
@@ -40,6 +40,14 @@ module IronHammer
40
40
  configuration = params[:configuration]
41
41
  config = (configuration && !configuration.empty? && configuration) || IronHammer::Defaults::CONFIGURATION_RUN
42
42
  end
43
+
44
+ def file
45
+ @file ||= ProjectFile.load_from path_to_csproj
46
+ end
47
+
48
+ def path_to_csproj
49
+ return File.join @path, @csproj
50
+ end
43
51
  end unless defined? GenericProject
44
52
  end
45
53
  end
@@ -10,41 +10,47 @@ require 'iron_hammer/utils/file_system'
10
10
  module IronHammer
11
11
  module Projects
12
12
  class ProjectFile
13
- attr_accessor :type
14
-
13
+ attr_accessor :path
14
+
15
15
  GUID_EVALUATION_ORDER = [AspNetMvcProject, AspNetProject, TestProject]
16
16
  GUID_PATH = '//Project/PropertyGroup/ProjectTypeGuids'
17
17
  REFERENCE_PATH = '//Reference[not(starts_with(@Include, "System"))]'
18
-
19
- def initialize params={}
20
- @type = params[:type] || DllProject
21
- raise ArgumentError.new('type must be a Class') unless @type.class == Class
22
- end
23
-
24
- def self.type_of *path
25
- self.parse(IronHammer::Utils::FileSystem::read_file(*path)).type
18
+
19
+ def self.load_from *path
20
+ ProjectFile.new path
26
21
  end
27
-
28
- def self.parse xml
29
- guids = guids_from xml
30
- ProjectFile.new :type => ((GUID_EVALUATION_ORDER.inject(false) do |result, current|
22
+
23
+ def type
24
+ @type ||= ((GUID_EVALUATION_ORDER.inject(false) do |result, current|
31
25
  result || (guids.include?(ProjectTypes::guid_for(current)) && current)
32
26
  end) || DllProject)
33
27
  end
34
28
 
35
- def self.guids_from xml
36
- doc = REXML::Document.new xml
37
- elem = doc && doc.elements[GUID_PATH]
38
- guids = ((elem && elem.text) || '').split(';').collect { |e| e.upcase }
29
+ def dependencies
30
+ references.collect { |reference| Dependency.from_reference reference }
39
31
  end
40
-
41
- def self.dependencies_of xml
42
- doc = REXML::Document.new xml
43
- references = doc && doc.get_elements(REFERENCE_PATH)
44
- references.map do |reference|
45
- Dependency.from_reference reference
46
- end
47
-
32
+
33
+ private
34
+ def references
35
+ doc && doc.get_elements(REFERENCE_PATH)
36
+ end
37
+
38
+ def doc
39
+ @doc ||= REXML::Document.new xml
40
+ end
41
+
42
+ def xml
43
+ @xml ||= IronHammer::Utils::FileSystem::read_file(*@path)
44
+ end
45
+
46
+ def guids
47
+ return @guids if @guids
48
+ return @guids = [] unless (elem = doc && doc.elements[GUID_PATH]) && elem.text
49
+ @guids = elem.text.split(';').collect { |e| e.upcase }
50
+ end
51
+
52
+ def initialize *path
53
+ @path = path
48
54
  end
49
55
  end unless defined? ProjectFile
50
56
  end
@@ -6,8 +6,7 @@ CLEAN.include("TestResults/**")
6
6
 
7
7
  namespace :iron do
8
8
  task :initialize do
9
- @anvil = Anvil.load_solution_from '.'
10
- @anvil.load_projects_from_solution
9
+ @anvil = Anvil.load_from '.'
11
10
  @hammer = Hammer.new(defined?(VISUAL_STUDIO_PATH) ? {:visual_studio_path => VISUAL_STUDIO_PATH} : {})
12
11
  FileUtils.mkdir 'TestResults' unless (File.exists?('TestResults') && File.directory?('TestResults'))
13
12
  end
@@ -1,5 +1,6 @@
1
1
  require 'builder'
2
2
  require 'rexml/document'
3
+
3
4
  module IronHammer
4
5
  module Utils
5
6
  class IvyBuilder
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mozair Alves do Carmo Junior
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-29 00:00:00 -02:00
12
+ date: 2010-01-30 00:00:00 -02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -125,8 +125,7 @@ post_install_message: |
125
125
  --- rakefile.rb
126
126
  require 'iron_hammer'
127
127
 
128
- @anvil = Anvil.load_solution_from '.'
129
- @anvil.load_projects_from_solution
128
+ @anvil = Anvil.load_from '.'
130
129
  @hammer = Hammer.new :visual_studio_path => VISUAL_STUDIO_PATH
131
130
  sh @hammer.build @anvil.solution
132
131
  sh @hammer.test *@anvil.test_projects