header-inserter 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,127 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+ require File.dirname(__FILE__) + '/../lib/header-inserter/project_file'
3
+ require 'ftools'
4
+ require 'fileutils'
5
+
6
+ describe Project do
7
+
8
+ before(:all) do
9
+ @project_path = "/tmp/project#{@rand}"
10
+ File.makedirs "#{@project_path}/src/my/project/logic"
11
+ File.makedirs "#{@project_path}/test/my/project/logic"
12
+ File.makedirs "#{@project_path}/bin/my/project/logic"
13
+ create_file "#{@project_path}/src/my/project/Main.java", "package my.project; class Main {}"
14
+ create_file "#{@project_path}/src/my/project/logic/Logic.java", "package my.project.logic; class Logic {}"
15
+ create_file "#{@project_path}/test/my/project/logic/LogicTest.java", "package my.project.logic; class LogicTest {}"
16
+ create_file "#{@project_path}/bin/my/project/logic/Logic.class", (1..500).to_a.map{|x| rand(256)}.pack("c*")
17
+ create_file "#{@project_path}/Util.java", "class Util {}"
18
+ create_file "#{@project_path}/../Useless.java", "package invalid; class Useless {}"
19
+
20
+ File.makedirs "#{@project_path}/src/my/project/.svn/text-base/"
21
+ create_file "#{@project_path}/src/my/project/.svn/text-base/ShouldEndWith.java.svn-base", "package my.project; class ShouldEndWith {}"
22
+ end
23
+
24
+ def create_file path, content
25
+ file = File.new path, "w"
26
+ file.puts content
27
+ file.close
28
+ end
29
+
30
+ def to_project_file project, array
31
+ array.map { |file| ProjectFile.new project, file }
32
+ end
33
+
34
+ it "should be created with a relative path" do
35
+ relative_path = "a/path"
36
+ project = Project.new relative_path
37
+ project.path.should == File.expand_path(relative_path)
38
+ end
39
+
40
+ it "should be created with an absolute path" do
41
+ absolute_path = "/an/absolute/path"
42
+ project = Project.new absolute_path
43
+ project.path.should == absolute_path
44
+ end
45
+
46
+ it "should be created with an absolute path with separator" do
47
+ absolute_path = "/an/absolute/path"
48
+ project = Project.new(absolute_path+File::SEPARATOR)
49
+ project.path.should == absolute_path
50
+ end
51
+
52
+ it "should list nothing if there are no files of that type" do
53
+ project = Project.new @project_path
54
+ project.list(:rb).should == []
55
+ end
56
+
57
+ it "should list nothing if there are no files matching the pattern" do
58
+ project = Project.new @project_path
59
+ project.list(/Holy Example Batman/).should == []
60
+ end
61
+
62
+ it "should list nothing on a non-existing project" do
63
+ project = Project.new(@project_path + "/" + rand(100000).to_s)
64
+ project.list(:rb).should == []
65
+ end
66
+
67
+ it "should list all files from an extension on aproject with many" do
68
+ project = Project.new @project_path
69
+
70
+ expected = to_project_file project, ["src/my/project/Main.java", "src/my/project/logic/Logic.java", "test/my/project/logic/LogicTest.java", "Util.java"]
71
+ project.list(:java).sort.should == expected.sort
72
+ end
73
+
74
+ it "should list a single file with an extension on a project" do
75
+ project = Project.new @project_path
76
+ expected = to_project_file project, ["bin/my/project/logic/Logic.class"]
77
+ project.list(:class).sort.should == expected.sort
78
+ end
79
+
80
+ it "should list files matching a pattern a project with many" do
81
+ project = Project.new @project_path
82
+ expected = to_project_file project, ["src/my/project/Main.java", "src/my/project/logic/Logic.java"]
83
+ project.list(/src\/.*.java$/).sort.should == expected.sort
84
+ end
85
+
86
+ it "should list a single file matching a pattern a project" do
87
+ project = Project.new @project_path
88
+ expected = to_project_file project, ["Util.java"]
89
+ project.list(/^((?!\/).)*\..*/).sort.should == expected.sort
90
+ end
91
+
92
+ it "should compare based on path" do
93
+ project = Project.new @project_path
94
+ other_project = Project.new "/an/absolute/path"
95
+ equal_project = Project.new @project_path
96
+
97
+ (project<=>project).should == 0
98
+ (project<=>other_project).should == 1
99
+ (other_project<=>project).should == -1
100
+ (project<=>equal_project).should == 0
101
+ end
102
+
103
+ it "should return files with a SvnVersionControl if they are under svn version control" do
104
+ project = Project.new @project_path
105
+ File.makedirs "#{@project_path}/src/my/project/.svn"
106
+ File.makedirs "#{@project_path}/src/my/project/logic/.svn"
107
+ File.makedirs "#{@project_path}/test/my/project/logic/.svn"
108
+ create_file "#{@project_path}/src/my/project/.svn/entries", "1\n\ndir\n1\nhttp://svn.archimedes.org.br/public/header-inserter/example/src/my/project\nhttp://svn.archimedes.org.br/public/\n\n\n\n2009-03-25T10:45:36.384923Z\n1\nhugo\n\n\nsvn:special svn:externals svn:needs-lock\n\n\n\n\n\n\n\n\na03a93f-28bc-2938-fbd2-ba29480238aa\n\L\nMain.java\nfile\n1\n\n\n\n2009-03-25T10:45:37.000000Z\ndf2e89885a41b572e159e8e454613b74\n2009-03-25T10:45:37.000000Z\n1\nhugo354\L"
109
+ create_file "#{@project_path}/src/my/project/logic/.svn/entries", "1\n\ndir\n1\nhttp://svn.archimedes.org.br/public/header-inserter/example/src/my/project/logic\nhttp://svn.archimedes.org.br/public/\n\n\n\n2009-03-25T10:45:36.384923Z\n1\nhugo\n\n\nsvn:special svn:externals svn:needs-lock\n\n\n\n\n\n\n\n\na03a93f-28bc-2938-fbd2-ba29480238aa\n\L\nLogic.java\nfile\n1\n\n\n\n2009-03-25T10:45:37.000000Z\ndf2e89885a41b572e159e8e454613b74\n2009-03-25T10:45:37.000000Z\n1\nhugo354\L"
110
+ create_file "#{@project_path}/test/my/project/logic/.svn/entries", "1\n\ndir\n1\nhttp://svn.archimedes.org.br/public/header-inserter/example/test/my/project/logic\nhttp://svn.archimedes.org.br/public/\n\n\n\n2009-03-25T10:45:36.384923Z\n1\nhugo\n\n\nsvn:special svn:externals svn:needs-lock\n\n\n\n\n\n\n\n\na03a93f-28bc-2938-fbd2-ba29480238aa\n\L\nLogicTest.java\nfile\n1\n\n\n\n2009-03-25T10:45:37.000000Z\ndf2e89885a41b572e159e8e454613b74\n2009-03-25T10:45:37.000000Z\n1\nhugo354\L"
111
+
112
+ project.list(:java).sort.each do |file|
113
+ if file.path == "Util.java"
114
+ file.version_control.should be_kind_of(NilVersionControl)
115
+ else
116
+ vc = file.version_control
117
+ vc.should be_kind_of(SvnVersionControl)
118
+ vc.path.should == "http://svn.archimedes.org.br/public/header-inserter/example/"
119
+ end
120
+ end
121
+ end
122
+
123
+ after(:all) do
124
+ File.delete "#{@project_path}/../Useless.java"
125
+ FileUtils.rm_rf @project_path
126
+ end
127
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'header-inserter'
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../lib/header-inserter/svn_version_control'
2
+ require File.dirname(__FILE__) + '/../lib/header-inserter/modification'
3
+ require 'date'
4
+
5
+ describe SvnVersionControl do
6
+ before(:all) do
7
+ server_path = "http://svn.archimedes.org.br/public/mainarchimedes/rcparchimedes/"
8
+ @svn = SvnVersionControl.new server_path
9
+ end
10
+
11
+ it "should be created with a server address" do
12
+ @svn.path.should == "http://svn.archimedes.org.br/public/mainarchimedes/rcparchimedes/"
13
+ end
14
+
15
+ it "should retrieve log from the server according to the specified file" do
16
+ log="""------------------------------------------------------------------------
17
+ r1451 | hugo.corbucci | 2009-03-17 17:21:03 -0300 (Ter, 17 Mar 2009) | 2 lines
18
+
19
+ Adding the projects for erase and tests for it. I forgot it before.
20
+ Hugo
21
+ ------------------------------------------------------------------------
22
+ r1436 | hugo.corbucci | 2009-03-11 11:17:12 -0300 (Qua, 11 Mar 2009) | 2 lines
23
+
24
+ Updating the configs and adding a project set to help people configure Archimedes to develop.
25
+ Hugo (thanks to Mariana for finding this feature and telling me)
26
+ ------------------------------------------------------------------------
27
+ """
28
+ @svn.retrieve_log("br.org.archimedes.config/trunk/ArchimedesProjectsSet.psf").should == log
29
+ end
30
+
31
+ it "should retrieve history from the server according to the specified file sorted" do
32
+ date_log1 = DateTime.civil(2009, 03, 11, 11, 17, 12, -1/8)
33
+ date_log2 = DateTime.civil(2009, 03, 17, 17, 21, 03, -1/8)
34
+ first_mod = Modification.new 1436, "hugo.corbucci", date_log1, "Adding the projects for erase and tests for it. I forgot it before.\nHugo"
35
+ second_mod = Modification.new 1451, "hugo.corbucci", date_log2, "Updating the configs and adding a project set to help people configure Archimedes to develop.\nHugo (thanks to Mariana for finding this feature and telling me)"
36
+ @svn.history("br.org.archimedes.config/trunk/ArchimedesProjectsSet.psf").should == [first_mod, second_mod]
37
+ end
38
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: header-inserter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - FIXME full name
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-25 00:00:00 -03:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: newgem
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.3.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ version:
35
+ description: This project was created to help me insert the EPLv1.0 license into all Archimedes source code files. It should recover data from the subversion repository if needed and generated a header with the license, the years in which the copyright apply and the list of contributors for each file.
36
+ email:
37
+ - FIXME email
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - PostInstall.txt
46
+ - README.rdoc
47
+ files:
48
+ - History.txt
49
+ - Manifest.txt
50
+ - PostInstall.txt
51
+ - README.rdoc
52
+ - Rakefile.rb
53
+ - features/get_subversion_modifications.feature
54
+ - features/retrieve_files_for_project.feature
55
+ - features/step_definitions/common_steps.rb
56
+ - features/step_definitions/get_subversion_modifications_steps.rb
57
+ - features/step_definitions/retrieve_files_for_project_steps.rb
58
+ - features/support/env.rb
59
+ - lib/header-inserter.rb
60
+ - lib/header-inserter/modification.rb
61
+ - lib/header-inserter/nil_version_control.rb
62
+ - lib/header-inserter/project.rb
63
+ - lib/header-inserter/project_file.rb
64
+ - lib/header-inserter/svn_version_control.rb
65
+ - spec/modification_spec.rb
66
+ - spec/nil_version_control_spec.rb
67
+ - spec/project-file_spec.rb
68
+ - spec/project_spec.rb
69
+ - spec/spec.opts
70
+ - spec/spec_helper.rb
71
+ - spec/svn_version_control_spec.rb
72
+ - tasks/rspec.rake
73
+ has_rdoc: true
74
+ homepage: https://github.com/night/header-inserter/tree
75
+ post_install_message: PostInstall.txt
76
+ rdoc_options:
77
+ - --main
78
+ - README.rdoc
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ version:
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ version:
93
+ requirements: []
94
+
95
+ rubyforge_project: header-inserter
96
+ rubygems_version: 1.3.1
97
+ signing_key:
98
+ specification_version: 2
99
+ summary: This project was created to help me insert the EPLv1.0 license into all Archimedes source code files
100
+ test_files: []
101
+