logirel 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.semver CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 6
4
+ :patch: 8
5
5
  :special: ""
data/README.md CHANGED
@@ -1,5 +1,19 @@
1
1
  Let's try and make a gem to create .Net projects easily.
2
2
 
3
+ Getting started
4
+ ===============
5
+ 1. `gem install logirel`
6
+ 1. Go to the project of your choice
7
+ 1. `logirel init`
8
+ 1. You should now answer the questions that logirel poses.
9
+
10
+
11
+ Hacking it
12
+ ==========
13
+ 1. `git clone https://haf@github.com/haf/logirel.git`
14
+ 1. `bundle install`
15
+ 1. `bundle exec rspec spec`
16
+
3
17
  My thinking
4
18
  ===========
5
19
 
@@ -46,4 +60,7 @@ of managing another build is too large.
46
60
 
47
61
  Shoulders of Giants
48
62
  ===================
49
- * http://madduck.net/blog/2007.07.11:creating-a-git-branch-without-ancestry/
63
+ * http://madduck.net/blog/2007.07.11:creating-a-git-branch-without-ancestry/
64
+ * http://rubydoc.info/github/wycats/thor/master/file/README.md
65
+ * https://github.com/radar/guides/blob/master/gem-development.md
66
+ * http://eggsonbread.com/2010/03/28/my-rspec-best-practices-and-tips/
data/Rakefile.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+ require 'rspec/core/rake_task';
4
+ RSpec::Core::RakeTask.new(:spec)
3
5
  # Requires Bundler and adds the
4
6
  #build, install and release
5
7
  #Rake tasks by way of calling Bundler::GemHelper.install_tasks.
data/bin/logirel CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require 'logirel'
3
- Logirel::Application.start
2
+ require 'logirel/cli'
3
+ Logirel::CLI.start
@@ -0,0 +1,82 @@
1
+ require 'semver'
2
+
3
+ namespace :env do
4
+
5
+ task :common do
6
+
7
+ # version management
8
+ fv = version(VERSION_BASE)
9
+ build = ENV['BUILD_NUMBER'] || fv[2]
10
+ revision = ENV['OFFICIAL_RELEASE'] || (fv[3] == 0 ? Time.now.strftime('%j%H') : fv[3]) # (day of year 0-265)(hour 00-24)
11
+
12
+ real_version = [fv[0], fv[1], build, revision]
13
+
14
+ ENV['VERSION'] = VERSION = real_version.join(".")
15
+ ENV['VERSION_INFORMAL'] = VERSION_INFORMAL = real_version.join(".")
16
+ puts "Assembly Version: #{VERSION}."
17
+ puts "##teamcity[buildNumber '#{VERSION}']" # print the version (revision) and build number to ci
18
+
19
+ # configuration management
20
+ ENV['FRAMEWORK'] = FRAMEWORK = ENV['FRAMEWORK'] || (Rake::Win32::windows? ? "net40" : "mono28")
21
+ puts "Framework: #{FRAMEWORK}"
22
+ end
23
+
24
+ # configure the output directories
25
+ task :configure, [:str] do |t, args|
26
+ ENV['CONFIGURATION'] = CONFIGURATION = args[:str]
27
+ Folders[:binaries] = File.join(Folders[:out], FRAMEWORK, args[:str].downcase)
28
+ CLEAN.include(File.join(Folders[:binaries], "*"))
29
+ end
30
+
31
+ task :set_dirs do
32
+ Folders[:proj_out] = File.join(Folders[:src], Projects[:proj][:dir], 'bin', CONFIGURATION)
33
+ CLEAN.include(Folders[:proj_out])
34
+
35
+ # for tests
36
+ Folders[:proj] = File.join(Folders[:src], Projects[:proj][:test_dir], 'bin', CONFIGURATION)
37
+ Files[:proj][:test] = File.join(Folders[:proj_test_out], "#{Projects[:proj][:test_dir]}.dll")
38
+ CLEAN.include(Folders[:proj_test_out])
39
+ end
40
+
41
+ desc "set debug environment variables"
42
+ task :debug => [:common] do
43
+ Rake::Task["env:configure"].invoke('Debug')
44
+ Rake::Task["env:set_dirs"].invoke
45
+ end
46
+
47
+ desc "set release environment variables"
48
+ task :release => [:common] do
49
+ Rake::Task["env:configure"].invoke('Release')
50
+ Rake::Task["env:set_dirs"].invoke
51
+ end
52
+
53
+ desc "set GA envionment variables"
54
+ task :ga do
55
+ puts "##teamcity[progressMessage 'Setting environment variables for GA']"
56
+ ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "4000"
57
+ end
58
+
59
+ desc "set release candidate environment variables"
60
+ task :rc, [:number] do |t, args|
61
+ puts "##teamcity[progressMessage 'Setting environment variables for Release Candidate']"
62
+ arg_num = args[:number].to_i
63
+ num = arg_num != 0 ? arg_num : 1
64
+ ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "#{3000 + num}"
65
+ end
66
+
67
+ desc "set beta-environment variables"
68
+ task :beta, [:number] do |t, args|
69
+ puts "##teamcity[progressMessage 'Setting environment variables for Beta']"
70
+ arg_num = args[:number].to_i
71
+ num = arg_num != 0 ? arg_num : 1
72
+ ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "#{2000 + num}"
73
+ end
74
+
75
+ desc "set alpha environment variables"
76
+ task :alpha, [:number] do |t, args|
77
+ puts "##teamcity[progressMessage 'Setting environment variables for Alpha']"
78
+ arg_num = args[:number].to_i
79
+ num = arg_num != 0 ? arg_num : 1
80
+ ENV['OFFICIAL_RELEASE'] = OFFICIAL_RELEASE = "#{1000 + num}"
81
+ end
82
+ end
data/content/utils.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'fileutils'
2
+
3
+ def commit_data
4
+ begin
5
+ commit = `git log -1 --pretty=format:%H`
6
+ git_date = `git log -1 --date=iso --pretty=format:%ad`
7
+ commit_date = DateTime.parse( git_date ).strftime("%Y-%m-%d %H%M%S")
8
+ rescue
9
+ commit = "git unavailable"
10
+ commit_date = Time.new.strftime("%Y-%m-%d %H%M%S")
11
+ end
12
+ [commit, commit_date]
13
+ end
14
+
15
+
16
+ def copy_files(from_dir, file_pattern, out_dir)
17
+ FileUtils.mkdir_p out_dir unless FileTest.exists?(out_dir)
18
+ Dir.glob(File.join(from_dir, file_pattern)){|file|
19
+ copy(file, out_dir) if File.file?(file)
20
+ }
21
+ end
22
+
23
+ def versions(str)
24
+ str.split(/\r\n|\n/).map{|s|version(s)}.compact.sort
25
+ end
26
+
27
+ def version(str)
28
+ ver = /v?(\d+)\.(\d+)\.(\d+)\.?(\d+)?/i.match(str).to_a()
29
+ ver[1,4].map{|s|s.to_i} unless ver == nil or ver.empty?
30
+ end
@@ -1,19 +1,20 @@
1
- module Logirel
2
- require 'semver'
1
+ require 'semver'
2
+ require 'enumerator'
3
+ require 'net/http'
3
4
 
5
+ module Logirel
4
6
  class Initer
5
-
6
- attr_accessor :root_path
7
7
 
8
- def initialize(root = '.')
9
- @root_path = root
10
- end
8
+ attr_accessor :root_path, :buildscripts_path
9
+
10
+ def initialize(root = '.', buildscripts = 'buildscripts');
11
+ @root_path = root
12
+ @buildscripts_path = buildscripts; end
13
+ def set_root(root); @root_path = root; end
11
14
 
12
15
  def get_commands
13
16
  cmd ||= []
14
- cmd << "gem update"
15
- cmd << "bundle install"
16
- cmd << "bin\NuGet.exe update"
17
+ cmd << "semver init"
17
18
  end
18
19
 
19
20
  def nuget_from_codeplex(cp_ver, gem_ver)
@@ -28,6 +29,74 @@
28
29
  end
29
30
  end
30
31
 
32
+ def create_path_folders(metas, f)
33
+ f.puts %q{
34
+ require File.dirname(__FILE__) + '/project_data'
35
+ root_folder = File.expand_path("#{File.dirname(__FILE__)}/..")
36
+ Folders = \{
37
+ }
38
+ f.puts ":src => " + StrQ.new("src").exec + ","
39
+ f.puts ":out => " + StrQ.new("build").exec + ","
40
+ f.puts ":package => " + StrQ.new("packages").exec + ","
41
+ f.puts ":tools => " + StrQ.new("tools").exec + ","
42
+ f.puts %q{:tests => File.join("build", "tests"),
43
+ :nuget => File.join("build", "nuget"),
44
+ :root => root_folder,
45
+ :binaries => "placeholder - specify build environment",
46
+ }
47
+ f.puts ":#{metas[:ruby_key]}" + " => {"
48
+ f.puts ':nuspec => File.join("build", "nuspec", Projects[' + ":#{metas[:ruby_key]}" + '][' + ":#{metas[:dir]}" + ']),'
49
+ f.puts %q{:out => 'placeholder - specify build environment',
50
+ :test_out => 'placeholder - specify build environment'
51
+ \},\}}
52
+ end
53
+
54
+ def create_path_files(metas, f)
55
+ f.puts "Files = {"
56
+ f.puts ":sln => " + StrQ.new("sln").exec + ","
57
+ f.puts ":#{metas[:ruby_key]} => {"
58
+ f.puts ':nuspec => File.join(Folders[:nuspec], Projects[' + ":#{metas[:ruby_key]}" + '][' + ":#{metas[:id]}" + '].nuspec),'
59
+ f.puts %q{:nunit => File.join(Folders[:nunit], "nunit-console.exe"),
60
+ :ilmerge => File.join(Folders[:tools], "ILMerge.exe")
61
+ \},\}}
62
+ end
63
+
64
+ def create_path_commands(metas, f)
65
+ f.puts %q{Commands = \{
66
+ :nuget => File.join(Folders[:tools], "NuGet.exe")
67
+ \}}
68
+ end
69
+
70
+ def create_path_uris(metas, f)
71
+ f.puts %q{Uris = \{
72
+ :nuget_offical => "http://packages.nuget.org/v1/"
73
+ \}}
74
+ end
75
+
76
+ def init_paths_rb(metas)
77
+ File.open(File.join(@root_path, @buildscripts_path, "paths.rb"), "w") do |f|
78
+ create_path_folders(metas, f)
79
+ create_path_files(metas, f)
80
+ create_path_commands(metas, f)
81
+ create_path_uris(metas, f)
82
+ end
83
+ # File.open(File.join(@root_path, @buildscripts_path, "paths.rb"), "r") do |infile|
84
+ # puts ""
85
+ # puts ""
86
+ # while (line = infile.gets)
87
+ # puts "#{line}"
88
+ # end
89
+ # end
90
+ end
91
+
92
+ def init_environement_rb
93
+ path = File.join(@root_path, @buildscripts_path, "environment.rb")
94
+ File.open(path, "w") do |f|
95
+ f.puts Net::HTTP.get(
96
+ URI.parse('https://raw.github.com/haf/logirel/master/content/environment.rb'))
97
+ end
98
+ end
99
+
31
100
  def parse_folders
32
101
  src = File.join(@root_path, 'src', '*')
33
102
  Dir.
@@ -39,10 +108,75 @@
39
108
  map{|x| File.basename(x) }
40
109
  end
41
110
 
42
- def init_rakefile
43
- File.open(File.join(@root_path, "Rakefile.rb"), "w") do |f|
44
- f.puts "require 'bundler'"
111
+ def init_gemfile
112
+ File.open(File.join(@root_path, "Gemfile"), "w") do |f|
113
+ f.puts 'source "http://rubygems.org"'
114
+ f.puts 'gem "albacore"'
115
+ f.puts 'gem "semver"'
116
+ f.puts 'gem "bundler"'
117
+ end
118
+ end
119
+
120
+ def init_utils
121
+ path = File.join(@root_path, @buildscripts_path, "utils.rb")
122
+ File.open(path, "w") do |f|
123
+ f.puts Net::HTTP.get(
124
+ URI.parse('https://raw.github.com/haf/logirel/master/content/utils.rb'))
45
125
  end
46
126
  end
127
+
128
+ def build_tasks(metas)
129
+
130
+ end
131
+
132
+ def assembly_infos(metas)
133
+
134
+ end
135
+ # asm info for every nuget
136
+ def nugets(metas)
137
+
138
+ end
139
+
140
+ def init_rakefile(metas)
141
+ # puts metas.map{|m| ":build_"+m.ruby_key}
142
+ File.open(File.join(@root_path, @buildscripts_path, "Rakefile.rb"), "w") do |f|
143
+ f.puts %q{
144
+ require 'rubygems'
145
+ require 'bundler'
146
+ Bundler.setup
147
+ Bundler.require # if rake gets a wee bit too slow, you may remove this
148
+ require 'albacore'
149
+ require 'semver'
150
+ require 'rake/clean'
151
+ require '#{buildscripts_path}/project_details'
152
+ require '#{buildscripts_path}/paths'
153
+ require '#{buildscripts_path}/utils'
154
+ require '#{buildscripts_path}/environment'
155
+ task :default => [:release]
156
+ task :debug => ["env:debug", :build]
157
+ task :release => ["env:release", :build]
158
+ task :ci => ["env:release", :build, :package]
159
+ }
160
+ f.puts "task :build => #{metas[:ruby_key]}"
161
+
162
+ f.puts build_tasks(metas)
163
+ end
164
+ end
165
+
166
+ def init_project_details(metadata)
167
+ File.open(File.join(@root_path, @buildscripts_path, "project_details.rb"), "w") do |f|
168
+ f.puts "Projects = {"
169
+ # m = ["my key", value]
170
+ # projects[m[0]] = value
171
+ metadata.keys.each_with_index do |key, index|
172
+ if index == metadata.length-1
173
+ f.puts ":#{key} = #{p(metadata[key])}"
174
+ else
175
+ f.puts ":#{key} = #{p(metadata[key])},"
176
+ end
177
+ end
178
+ f.puts "}"
179
+ end
180
+ end
47
181
  end
48
182
  end
@@ -0,0 +1,77 @@
1
+ require 'logirel/initer'
2
+ require 'logirel/version'
3
+ require 'logirel/q_model'
4
+ require 'uuid'
5
+ require 'thor'
6
+ require 'FileUtils'
7
+
8
+ module Logirel
9
+ class CLI < Thor
10
+
11
+ desc "init", "Convert the current folder's projects (src) into a rake+albacore build"
12
+ def init(root_dir = Dir.pwd)
13
+
14
+ puts "Logirel version #{Logirel::VERSION}"
15
+ curr = Dir.pwd
16
+
17
+ puts ""
18
+ puts "Directories Selection"
19
+ puts "---------------------"
20
+
21
+ folder = lambda { |query, default|
22
+ StrQ.new(query, default, STDIN, lambda { |dir|
23
+ true # perform validation here if you wish
24
+ }, STDOUT)
25
+ }
26
+
27
+ src_folders = Initer.new('./src').parse_folders.inspect
28
+ dir = folder.call("Source Directory. Default contains (#{src_folders})", "./src").exec
29
+ buildscripts = folder.call("Buildscripts Directory", "./buildscripts").exec
30
+ tools = folder.call("Tools Directory", "./tools").exec
31
+ initer = Initer.new(dir)
32
+ initer.buildscripts_path = buildscripts
33
+
34
+ puts ""
35
+ puts "Project Selection"
36
+ puts "-----------------"
37
+
38
+ selected_projs = initer.parse_folders.
39
+ find_all { |f| BoolQ.new(f).exec }
40
+
41
+ puts "Selected: #{selected_projs.inspect}"
42
+
43
+ puts ""
44
+ puts "Project Meta-Data Definitions"
45
+ puts "-----------------------------"
46
+
47
+ puts "initing semver in folder #{dir}"
48
+ `semver init`
49
+
50
+ metas = selected_projs.map do |p|
51
+
52
+ base = File.basename(p)
53
+ p_dir = File.join(dir, base)
54
+
55
+ {
56
+ :dir => p_dir,
57
+ :title => StrQ.new("Title", base).exec,
58
+ :test_dir => StrQ.new("Test Directory", base + ".Tests").exec,
59
+ :description => StrQ.new("Description", "#{base} at commit #{`git log --pretty-format=%H`}").exec,
60
+ :copyright => StrQ.new("Copyright").exec,
61
+ :authors => StrQ.new("Authors").exec,
62
+ :company => StrQ.new("Company").exec,
63
+ :nuget_key => StrQ.new("NuGet key", base).exec,
64
+ :ruby_key => StrQ.new("Ruby key (e.g. 'autotx')").exec,
65
+ :guid => UUID.new
66
+ }
67
+ end
68
+
69
+ initer.init_project_details(metas)
70
+ initer.init_path_rb(metas)
71
+ initer.init_environement_rb
72
+ initer.init_gemfile
73
+ initer.init_utils
74
+ initer.init_rakefile(metas)
75
+ end
76
+ end
77
+ end
@@ -1,43 +1,61 @@
1
1
  module Logirel
2
-
3
2
  class Q
4
- attr_accessor :question
3
+ attr_accessor :question, :default
5
4
  end
6
5
 
7
6
  class BoolQ < Q
8
7
  attr_accessor :pos_answer, :neg_answer
9
8
 
10
- def initialize(question, name)
9
+ def initialize(question,
10
+ default,
11
+ io_source = STDIN,
12
+ io_target = STDOUT)
11
13
  @question = question
12
- #@pos_answer lambda { name }
13
- #@neg_answer lambda { }
14
+ @default = default
15
+ @io_source = io_source
16
+ @io_target = io_target
14
17
  end
18
+
19
+ def default_str
20
+ @default ? "[Yn]" : "[yN]"
21
+ end
15
22
 
16
- def exec
17
- puts @question
18
- #a = gets
19
- #a == 'yes' ? q.pos_answer.call : a == '' ? q.neg_answer.call
23
+ def exec
24
+ @io_target.print @question + " " + default_str
25
+ a = ""
26
+ begin
27
+ a = @io_source.gets.chomp
28
+ end while !a.empty? && !['y', 'n'].include?(a.downcase)
29
+ a.empty? ? @default : (a == 'y')
20
30
  end
21
31
  end
22
32
 
23
33
  class StrQ < Q
24
- attr_accessor :answer, :default
25
-
26
- def initialize(question, default = '.')
34
+ def initialize(question,
35
+ default = nil,
36
+ io_source = STDIN,
37
+ validator = nil,
38
+ io_target = STDOUT)
27
39
  @question = question
28
- @default = default
40
+ @default = default
41
+ @io_source = io_source
42
+ @validator = validator || lambda { |s| true }
43
+ @io_target = io_target
44
+ @answer = ""
29
45
  end
30
46
 
31
- def exec
32
- puts @question
33
- @answer = gets.chomp || @default
47
+ def answer
48
+ @answer.empty? ? @default : @answer
34
49
  end
35
- end
36
-
37
- class Querier
38
- def include_package_for(projects)
39
- projects.
40
- map{ |p| BoolQ.new("Would you like to include the '#{p}' project, dear Sir?", p) }
50
+
51
+ def exec
52
+ @io_target.print @question + " [#{@default}]: "
53
+ begin
54
+ @answer = @io_source.gets.chomp
55
+ end while !@answer.empty? && !@validator.call(@answer)
56
+ @answer = @answer.empty? ? @default : @answer
57
+ @io_target.puts "Chose '#{@answer}'."
58
+ @answer
41
59
  end
42
60
  end
43
61
  end
@@ -0,0 +1,8 @@
1
+ module Logirel
2
+ class Querier
3
+ def include_package_for(projects)
4
+ projects.
5
+ map{ |p| BoolQ.new("Would you like to include the '#{p}' project, dear Sir?", p) }
6
+ end
7
+ end
8
+ end
data/lib/logirel.rb CHANGED
@@ -6,92 +6,5 @@ require 'thor'
6
6
  require 'FileUtils'
7
7
 
8
8
  module Logirel
9
- class Application < Thor
10
-
11
- desc "Convert projects to rake", "Convert the current folder's projects (src) into a rake+albacore build"
12
- def convert
13
-
14
- puts "Logirel version #{Logirel::VERSION}"
15
- curr = Dir.pwd
16
-
17
- puts ""
18
- puts "Directories Selection"
19
- puts "---------------------"
20
-
21
- dir = StrQ.new("Specify src directory (#{Initer.new('./src').parse_folders.inspect})",
22
- "./src",
23
- lambda { |dir| !dir.empty? && Dir.exists?(dir) }).exec
24
-
25
- buildscripts = StrQ.new("Buildscripts Directory", "./buildscripts").exec
26
- tools = StrQ.new("Tools Directory", "./tools").exec
27
-
28
- puts "initing semver in folder above #{dir}"
29
- Dir.chdir File.join(dir, "..")
30
- sh "semver init" do |ok, err|
31
- ok || raise "failed to initialize semver"
32
- end
33
- Dir.chdir curr
34
-
35
- puts ""
36
- puts "Project Selection"
37
- puts "-----------------"
38
-
39
- selected_projs = Initer.new(dir).parse_folders.
40
- map { |f|
41
- BoolQ.new(f, File.basename(f)).exec # TODO: return bool
42
- }
43
-
44
- puts ""
45
- puts "Project Meta-Data Definitions"
46
- puts "-----------------------------"
47
-
48
- metas = selected_projs.map do |p|
49
-
50
- base = File.basename(p)
51
- p_dir = File.join(dir, base)
52
-
53
- {
54
- :dir => p_dir,
55
- :title => StrQ.new("Title", base).exec,
56
- :test_dir => StrQ.new("Test Directory", base + ".Tests").exec,
57
- :description => StrQ.new("Description", "#{base} at commit #{`git log --pretty-format=%H`}").exec,
58
- :copyright => StrQ.new("Copyright").exec,
59
- :authors => StrQ.new("Authors").exec,
60
- :company => StrQ.new("Company").exec,
61
- :nuget_key => StrQ.new("NuGet key", base).exec,
62
- :ruby_key => StrQ.new("Ruby key (e.g. 'autotx')").exec,
63
- :guid => UUID.new
64
- }
65
- end
66
-
67
- # TODO: test whether buildscripts/project_details.rb exists
68
- details_path = File.join(buildscripts, "project_details.rb")
69
- File.new(details_path, "w") do |f|
70
- f.puts %q{
71
- Projects = \{
72
- }
73
- end
74
-
75
- metas.each do |m|
76
- File.open(details_path, "w") do |f|
77
- k = m.ruby_key
78
- m.remove('ruby_key')
79
- f.puts ":#{m.ruby_key} = #{p(m)}"
80
- f.puts ","
81
- end
82
- end
83
-
84
- File.open(details_path, "w") do |f|
85
- f.puts %q{
86
- \}
87
- }
88
- end
89
-
90
- # TODO: paths
91
-
92
- # TODO: Create rakefile!
93
-
94
- # TODO: tasks in rakefile.rb
95
- end
96
- end
9
+ # code here if you want
97
10
  end
@@ -0,0 +1,56 @@
1
+ require 'logirel/initer'
2
+ require 'logirel/version'
3
+ require 'logirel/nuget'
4
+ require 'logirel/initer'
5
+ require 'construct'
6
+ require 'FileUtils'
7
+ require File.dirname(__FILE__) + '/../support/with_sample_projects'
8
+ include Logirel
9
+
10
+ describe Initer, "setting up folder structure" do
11
+
12
+ before(:each) do
13
+ @tmp = "fs-" + rand().to_s
14
+ @tmp_bs = "buildscripts"
15
+ Dir.mkdir(@tmp)
16
+ @r = Initer.new(@tmp, @tmp_bs)
17
+ @r.create_structure
18
+ @bs = File.join(@r.root_path, @r.buildscripts_path)
19
+ end
20
+
21
+ subject { @r }
22
+
23
+ after(:each) do
24
+ FileUtils.rm_rf(@tmp) while Dir.exists?(@tmp)
25
+ end
26
+
27
+ it { should respond_to :root_path }
28
+
29
+ context "when we have an existing project" do
30
+ before {
31
+ abc_projects(@r.root_path)
32
+ }
33
+ it "initer should correctly parse the names of existing projects" do
34
+ @r.parse_folders.should =~ ['A', 'C']
35
+ end
36
+ end
37
+
38
+ it "should create the correct folder structure" do
39
+ @r.create_structure
40
+ Dir.exists?(@bs).should be_true
41
+ Dir.exists?(File.join(@tmp, "src")).should be_true
42
+ end
43
+
44
+ it "should create environment.rb" do
45
+ @r.init_environement_rb
46
+ File.exists?(File.join(@bs, "environment.rb")).should be_true
47
+ end
48
+
49
+ it "should create project_details.rb" do
50
+ @r.init_project_details({
51
+ :ruby_key => "p_ruby",
52
+ :dir => "p_dir"
53
+ })
54
+ File.exists?(File.join(@bs, "project_details.rb")).should be_true
55
+ end
56
+ end
@@ -0,0 +1,35 @@
1
+ # require 'logirel/initer'
2
+ # require 'logirel/version'
3
+ # require 'logirel/nuget'
4
+ # require 'logirel/initer'
5
+ # require 'construct'
6
+ # require 'FileUtils'
7
+
8
+ # describe Logirel::Initer, "when initilizing paths file" do
9
+ # pending "too much of an integration test now"
10
+
11
+ # before(:each) do
12
+ # @tmp = "fs-" + rand().to_s
13
+ # @tmp_bs = "buildscripts"
14
+ # Dir.mkdir(@tmp)
15
+ # @r = Logirel::Initer.new(@tmp, @tmp_bs)
16
+ # @r.create_structure
17
+ # @bs = File.join(@r.root_path, @r.buildscripts_path)
18
+ # end
19
+
20
+ # subject { @r }
21
+
22
+ # after(:each) do
23
+ # FileUtils.rm_rf(@tmp) while Dir.exists?(@tmp)
24
+ # end
25
+
26
+ # it "should be created" do
27
+ # @r.init_paths_rb({
28
+ # :dir => "p_dir",
29
+ # :ruby_key => "p_ruby_key",
30
+ # :id => "p_id"
31
+ # })
32
+ # File.exists?(File.join(@bs, "paths.rb")).should be_true
33
+ # end
34
+
35
+ # end
@@ -0,0 +1,32 @@
1
+ require 'logirel/initer'
2
+ require 'logirel/version'
3
+ require 'logirel/nuget'
4
+ require 'logirel/initer'
5
+ require 'construct'
6
+ require 'FileUtils'
7
+
8
+ describe Logirel::Initer, "when initilizing rake file" do
9
+
10
+ before(:each) do
11
+ @tmp = "fs-" + rand().to_s
12
+ @tmp_bs = "buildscripts"
13
+ Dir.mkdir(@tmp)
14
+ @r = Logirel::Initer.new(@tmp, @tmp_bs)
15
+ @r.create_structure
16
+ @bs = File.join(@r.root_path, @r.buildscripts_path)
17
+ end
18
+
19
+ subject { @r }
20
+
21
+ after(:each) do
22
+ FileUtils.rm_rf(@tmp) while Dir.exists?(@tmp)
23
+ end
24
+
25
+ it "should be created" do
26
+ @r.init_rakefile({
27
+ :ruby_key => "p_ruby_key",
28
+ :test2 => "p_test2"
29
+ })
30
+ File.exists?(File.join(@bs, "Rakefile.rb")).should be_true
31
+ end
32
+ end
data/spec/helpers.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec'
2
+
3
+ RSpec.configure do |c|
4
+ c.mock_with :rspec
5
+ end
@@ -0,0 +1,29 @@
1
+ require 'logirel/initer'
2
+ require 'logirel/version'
3
+ require 'logirel/nuget'
4
+ require 'logirel/initer'
5
+ require 'construct'
6
+ require 'FileUtils'
7
+
8
+ describe Logirel::Initer, "when starting a new project" do
9
+
10
+ before(:each) do
11
+ include Construct::Helpers
12
+ @i = Logirel::Initer.new
13
+ end
14
+
15
+ after(:each) do
16
+ Construct.destroy_all!
17
+ end
18
+
19
+ it "should run the right commands" do
20
+ cmds = @i.get_commands
21
+ cmds.include?("semver init").should be_true
22
+ end
23
+
24
+ it "should be able to know when to download from codeplex" do
25
+ @i.nuget_from_codeplex([1,3], [1,1]).should == true
26
+ @i.nuget_from_codeplex([1,3], [1,4]).should == false
27
+ end
28
+
29
+ end
@@ -0,0 +1,30 @@
1
+ require 'logirel/q_model'
2
+ describe Logirel::BoolQ, "when given input" do
3
+ before(:each) { @out = StringIO.new }
4
+
5
+ it "input says no, second time" do
6
+ io = StringIO.new "x\nn"
7
+ b = BoolQ.new "Yes or no?", true, io, @out
8
+ b.exec.should be_false
9
+ end
10
+ it "input says yet, second time" do
11
+ io = StringIO.new "x\ny"
12
+ b = BoolQ.new "Yes or no?", false, io, @out
13
+ b.exec.should be_true
14
+ end
15
+ it "input says yes" do
16
+ io = StringIO.new "y"
17
+ b = BoolQ.new "Yes or no?", false, io, @out
18
+ b.exec.should be_true
19
+ end
20
+ it "input says no" do
21
+ io = StringIO.new "n"
22
+ b = BoolQ.new("Yes or no?", true, io, @out)
23
+ b.exec.should be_false
24
+ end
25
+ it "input is default" do
26
+ io = StringIO.new "\n"
27
+ b = BoolQ.new("Yes or no?", true, io, @out)
28
+ b.exec.should be_true
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
- require 'logirel/q_model'
2
- require File.dirname(__FILE__) + '/with_sample_projects'
1
+ require 'logirel/querier'
2
+ require File.dirname(__FILE__) + '/../support/with_sample_projects'
3
3
 
4
4
  describe Logirel::Querier, "when getting available directories and having querier return the correct data structures" do
5
5
 
@@ -23,8 +23,10 @@ describe Logirel::Querier, "when getting available directories and having querie
23
23
 
24
24
  it "should not create a query for those project folders without *proj files" do
25
25
  with_sample_projects do |construct|
26
+ # given
26
27
  r = Logirel::Initer.new(construct)
27
28
  folders = r.parse_folders
29
+ # then
28
30
  @q.include_package_for(folders).map{|q| q.question }.
29
31
  each{ |str| str.include?("'B'").should be_false }
30
32
  end
@@ -32,8 +34,10 @@ describe Logirel::Querier, "when getting available directories and having querie
32
34
 
33
35
  it "should return two strings when two questions are asked" do
34
36
  with_sample_projects do |construct|
37
+ # given
35
38
  r = Logirel::Initer.new(construct)
36
39
  folders = r.parse_folders
40
+ # then
37
41
  qs = @q.include_package_for(folders)
38
42
  qs.length.should eq(2)
39
43
  end
@@ -0,0 +1,58 @@
1
+ require 'logirel/q_model'
2
+
3
+ describe Logirel::StrQ, "in its default mode of operation, when reading props" do
4
+ before(:each) { @q = StrQ.new "Q??", "def" }
5
+ subject { @q }
6
+ it { should respond_to :question }
7
+ it { should respond_to :default }
8
+ specify { @q.answer.should eql("def") }
9
+ specify { @q.question.should eql("Q??") }
10
+ end
11
+
12
+ describe Logirel::StrQ, "when feeding it OK input" do
13
+ before(:each) do
14
+ @io = StringIO.new "My Answer"
15
+ @out = StringIO.new
16
+ @validator = double('validator')
17
+ @validator.should_receive(:call).once.
18
+ with(an_instance_of(String)).
19
+ and_return(true)
20
+ end
21
+ subject { StrQ.new("q?", "def", @io, @validator, @out) }
22
+ specify {
23
+ subject.exec.should eql("My Answer") and
24
+ subject.answer.should eql("My Answer")
25
+ }
26
+ end
27
+
28
+ describe Logirel::StrQ, "when feeding it bad input" do
29
+ before(:each) do
30
+ @io = StringIO.new "My Bad Answer\nAnother Bad Answer\nOKAnswer!"
31
+ @out = StringIO.new
32
+
33
+ @validator = double('validator')
34
+ @validator.should_receive(:call).exactly(3).times.
35
+ with(an_instance_of(String)).
36
+ and_return(false, false, true)
37
+ end
38
+ subject { StrQ.new("q?", "def", @io, @validator, @out) }
39
+ specify { subject.exec.should == "OKAnswer!" }
40
+ end
41
+
42
+ describe Logirel::StrQ, "when accepting the defaults" do
43
+ before(:each) do
44
+ @io = StringIO.new "\n"
45
+ @out = StringIO.new
46
+
47
+ @validator = double('validator')
48
+ @validator.should_receive(:call).never.
49
+ with(an_instance_of(String)).
50
+ # the validator should never be called for empty input if we have a default
51
+ and_return(false)
52
+ end
53
+ subject { StrQ.new("q?", "def", @io, @validator, @out) }
54
+ specify {
55
+ subject.exec.should eql("def") and
56
+ subject.answer.should eql("def")
57
+ }
58
+ end
@@ -0,0 +1,29 @@
1
+ require 'construct'
2
+
3
+ def with_sample_projects(&block)
4
+ Construct::within_construct do |c|
5
+ # given files
6
+ c.directory('src/A')
7
+ c.directory('src/B')
8
+ c.directory('src/C')
9
+ c.file('src/A/A.csproj') do |f|
10
+ f.puts "cs proj file ... xml in here"
11
+ end
12
+
13
+ c.file('src/C/HelloWorld.vbproj')
14
+ block.call(c)
15
+ end
16
+ end
17
+
18
+ def abc_projects(in_folder)
19
+ #puts "creating projects A, B and C in #{in_folder}"
20
+ Dir.mkdir(File.join(in_folder, 'src/A'))
21
+ File.open(File.join(in_folder, 'src/A/A.csproj'), "w") do |f|
22
+ f.puts "cs proj file ... xml in here"
23
+ end
24
+ Dir.mkdir(File.join(in_folder, 'src/B'))
25
+ Dir.mkdir(File.join(in_folder, 'src/C'))
26
+ File.open(File.join(in_folder, 'src/C/HelloWorld.vbproj'), "w") do |f|
27
+ f.puts "vb-things"
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logirel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-14 00:00:00.000000000 +02:00
13
- default_executable:
12
+ date: 2011-06-28 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- requirement: &25700928 !ruby/object:Gem::Requirement
16
+ requirement: &19696860 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 2.6.0
23
22
  type: :development
24
23
  prerelease: false
25
- version_requirements: *25700928
24
+ version_requirements: *19696860
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: memoize
28
- requirement: &25700520 !ruby/object:Gem::Requirement
27
+ requirement: &19696584 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: '0'
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *25700520
35
+ version_requirements: *19696584
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: devver-construct
39
- requirement: &25700052 !ruby/object:Gem::Requirement
38
+ requirement: &19696224 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ! '>='
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: '0'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *25700052
46
+ version_requirements: *19696224
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: albacore
50
- requirement: &25699392 !ruby/object:Gem::Requirement
49
+ requirement: &19695828 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,10 +54,10 @@ dependencies:
55
54
  version: 0.2.5
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *25699392
57
+ version_requirements: *19695828
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: semver
61
- requirement: &25698696 !ruby/object:Gem::Requirement
60
+ requirement: &19695396 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ~>
@@ -66,10 +65,10 @@ dependencies:
66
65
  version: 1.0.1
67
66
  type: :runtime
68
67
  prerelease: false
69
- version_requirements: *25698696
68
+ version_requirements: *19695396
70
69
  - !ruby/object:Gem::Dependency
71
70
  name: bundler
72
- requirement: &25698084 !ruby/object:Gem::Requirement
71
+ requirement: &19694976 !ruby/object:Gem::Requirement
73
72
  none: false
74
73
  requirements:
75
74
  - - ~>
@@ -77,10 +76,10 @@ dependencies:
77
76
  version: 1.0.14
78
77
  type: :runtime
79
78
  prerelease: false
80
- version_requirements: *25698084
79
+ version_requirements: *19694976
81
80
  - !ruby/object:Gem::Dependency
82
81
  name: thor
83
- requirement: &25697544 !ruby/object:Gem::Requirement
82
+ requirement: &19694544 !ruby/object:Gem::Requirement
84
83
  none: false
85
84
  requirements:
86
85
  - - ! '>='
@@ -88,10 +87,10 @@ dependencies:
88
87
  version: '0'
89
88
  type: :runtime
90
89
  prerelease: false
91
- version_requirements: *25697544
90
+ version_requirements: *19694544
92
91
  - !ruby/object:Gem::Dependency
93
92
  name: uuid
94
- requirement: &25696932 !ruby/object:Gem::Requirement
93
+ requirement: &19694076 !ruby/object:Gem::Requirement
95
94
  none: false
96
95
  requirements:
97
96
  - - ! '>='
@@ -99,7 +98,7 @@ dependencies:
99
98
  version: '0'
100
99
  type: :runtime
101
100
  prerelease: false
102
- version_requirements: *25696932
101
+ version_requirements: *19694076
103
102
  description: ! "The gem works by having as its dependencies \n everything you need
104
103
  to get started with OSS and proprietary .Net coding.\n The aim of the gem is to
105
104
  allow developers to get up and running quickly\n and provide a nice way of converting
@@ -107,7 +106,6 @@ description: ! "The gem works by having as its dependencies \n everything you n
107
106
  email:
108
107
  - henrik@haf.se
109
108
  executables:
110
- - NuGet.exe
111
109
  - logirel
112
110
  extensions: []
113
111
  extra_rdoc_files: []
@@ -117,25 +115,30 @@ files:
117
115
  - Gemfile
118
116
  - README.md
119
117
  - Rakefile.rb
120
- - TODO.txt
121
- - bin/NuGet.exe
122
118
  - bin/logirel
119
+ - content/environment.rb
120
+ - content/utils.rb
123
121
  - lib/logirel.rb
124
122
  - lib/logirel/Initer.rb
125
123
  - lib/logirel/NuGet.rb
124
+ - lib/logirel/cli.rb
126
125
  - lib/logirel/details_emitter.rb
127
126
  - lib/logirel/logirel.rb
128
127
  - lib/logirel/q_model.rb
128
+ - lib/logirel/querier.rb
129
129
  - lib/logirel/version.rb
130
130
  - logirel.gemspec
131
- - spec/filestructure_spec.rb
132
- - spec/logirel_spec.rb
133
- - spec/nuget_spec.rb
134
- - spec/project_details_spec.rb
135
- - spec/query_spec.rb
136
- - spec/rakefile_init_spec.rb
131
+ - spec/dependencies/nuget_spec.rb
132
+ - spec/filesystem/filestructure_spec.rb
133
+ - spec/filesystem/path_init_spec.rb
134
+ - spec/filesystem/rakefile_init_spec.rb
135
+ - spec/helpers.rb
136
+ - spec/initer_spec.rb
137
+ - spec/queries/bool_query_spec.rb
138
+ - spec/queries/querier_spec.rb
139
+ - spec/queries/string_query_spec.rb
140
+ - spec/support/with_sample_projects.rb
137
141
  - spec/version_spec.rb
138
- - spec/with_sample_projects.rb
139
142
  - vendor/cache/albacore-0.2.5.gem
140
143
  - vendor/cache/devver-construct-1.1.0.gem
141
144
  - vendor/cache/diff-lcs-1.1.2.gem
@@ -149,7 +152,6 @@ files:
149
152
  - vendor/cache/semver-1.0.1.gem
150
153
  - vendor/cache/thor-0.14.6.gem
151
154
  - vendor/cache/uuid-2.3.2.gem
152
- has_rdoc: true
153
155
  homepage: https://github.com/haf/logirel
154
156
  licenses: []
155
157
  post_install_message:
@@ -173,7 +175,7 @@ requirements:
173
175
  - xbuild (on linux) or msbuild (on windows) for csproj files
174
176
  - Access to the internet w/o a proxy! ;)
175
177
  rubyforge_project: logirel
176
- rubygems_version: 1.5.2
178
+ rubygems_version: 1.8.5
177
179
  signing_key:
178
180
  specification_version: 3
179
181
  summary: Logirel's a best-shot for scaffolding versioning for a .Net solution.
data/TODO.txt DELETED
@@ -1,18 +0,0 @@
1
- q
2
-
3
- Path to search
4
- Ensure create_stucture
5
- For each item from path/src, ask if include
6
- For each sln in path/src, ask if setup msbuild task for it
7
- Create Rakefile.rb
8
-
9
- For each include:
10
- concatenate name => { props } to table
11
- props := interactive questioning
12
- include environment.rb file
13
- include paths.rb file
14
- include utils.rb in gem's code
15
-
16
- Gem stuff:
17
-
18
- * Ensude NuGet.exe is included and possible to call from the gem's code.
data/bin/NuGet.exe DELETED
Binary file
@@ -1,18 +0,0 @@
1
- require 'logirel/initer'
2
- require 'logirel/version'
3
- require 'logirel/nuget'
4
- require 'logirel/initer'
5
- require 'construct'
6
- require 'FileUtils'
7
-
8
- describe Logirel::Initer, "when reflecting upon previous project strucure" do
9
- it "should correctly parse the names of existing projects" do
10
-
11
- with_sample_projects do |c|
12
- r = Logirel::Initer.new(c)
13
-
14
- # initer should parse names:
15
- r.parse_folders.should =~ ['A', 'C']
16
- end
17
- end
18
- end
data/spec/logirel_spec.rb DELETED
@@ -1,46 +0,0 @@
1
- require 'logirel/initer'
2
- require 'logirel/version'
3
- require 'logirel/nuget'
4
- require 'logirel/initer'
5
- require 'construct'
6
- require 'FileUtils'
7
-
8
- describe Logirel::Initer, "when starting a new project" do
9
-
10
- before(:each) do
11
- include Construct::Helpers
12
- @i = Logirel::Initer.new
13
- end
14
-
15
- after(:each) do
16
- Construct.destroy_all!
17
- end
18
-
19
- it "should start by performing an upgrade" do
20
- @i.get_commands[0].should eql("gem update")
21
- end
22
-
23
- it "should then proceed running bundle install" do
24
- @i.get_commands[1].should eql("bundle install")
25
- end
26
-
27
- it "should then update nuget" do
28
- @i.get_commands[2].include?('update').should == true
29
- end
30
-
31
- it "should be able to know when to download from codeplex" do
32
- @i.nuget_from_codeplex([1,3], [1,1]).should == true
33
- @i.nuget_from_codeplex([1,3], [1,4]).should == false
34
- end
35
-
36
- it "should create the correct folder structure" do
37
- Construct::within_construct do |c|
38
- r = Logirel::Initer.new(c)
39
- Dir.exists?(c+'buildscripts').should == false
40
- r.create_structure
41
- Dir.exists?(c+'buildscripts').should == true
42
- Dir.exists?(c+'src').should == true
43
- end
44
- end
45
-
46
- end
@@ -1,21 +0,0 @@
1
- require 'logirel'
2
- require 'FileUtils'
3
-
4
- describe Logirel::Initer, "when initilizing project details" do
5
-
6
- before(:each) do
7
- @temp = "buildscripts"
8
- Dir.mkdir(@temp) unless Dir.exists?(@temp)
9
- @r = Logirel::Initer.new(@temp)
10
- end
11
-
12
- after(:each) do
13
- FileUtils.rm_rf(@temp) if Dir.exists?(@temp)
14
- end
15
-
16
- it "should create project_details.rb" do
17
- pending("need impl")
18
- File.exitist?(File.join(@temp, "project_details.rb")).should be_true
19
- end
20
-
21
- end
@@ -1,26 +0,0 @@
1
- require 'logirel/initer'
2
- require 'logirel/version'
3
- require 'logirel/nuget'
4
- require 'logirel/initer'
5
- require 'construct'
6
- require 'FileUtils'
7
-
8
- describe Logirel::Initer, "when initilizing rake file" do
9
-
10
- attr_accessor :tmp, :r
11
-
12
- before(:each) do
13
- @tmp = "test-temp"
14
- Dir.mkdir(@tmp) unless Dir.exists?(@tmp)
15
- @r = Logirel::Initer.new(@tmp)
16
- end
17
-
18
- after(:each) do
19
- FileUtils.rm_rf(@tmp) if Dir.exists?(@tmp)
20
- end
21
-
22
- it "should be created" do
23
- @r.init_rakefile
24
- File.exists?(File.join(@tmp, 'Rakefile.rb')).should == true
25
- end
26
- end
@@ -1,16 +0,0 @@
1
- require 'construct'
2
-
3
- def with_sample_projects(&block)
4
- Construct::within_construct do |c|
5
- # given files
6
- c.directory('src/A')
7
- c.directory('src/B')
8
- c.directory('src/C')
9
- c.file('src/A/A.csproj') do |f|
10
- f.puts "cs proj file ... xml in here"
11
- end
12
-
13
- c.file('src/C/HelloWorld.vbproj')
14
- block.call(c)
15
- end
16
- end
File without changes