license_generator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/license_generator.rb'}"
9
+ puts "Loading license_generator gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,87 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.dirname(__FILE__) + '/spec_helper.rb'
3
+
4
+ describe "LicenseGenerator" do
5
+
6
+ before(:each) do
7
+ @generator = generator
8
+ end
9
+
10
+ it "should accept a --author option" do
11
+ generator(:author => "dummy").author.should == "dummy"
12
+ end
13
+
14
+ it "should accept a --license option" do
15
+ generator(:license => "gpl").license.should == :gpl
16
+ end
17
+
18
+ it "should accept a --years option" do
19
+ generator(:years => "2008,2009").years.should == [2008, 2009, 2010]
20
+ end
21
+
22
+ it "should include the current year in years" do
23
+ generator.years.should include(Time.now.year)
24
+ end
25
+
26
+ it "should have 'GNU General public' as named when :gpl is selected" do
27
+ @generator.license = :gpl
28
+ @generator.license_name.should == "GNU General public"
29
+ end
30
+
31
+ it "should have 'GNU Affero General public' as named when :agpl is selected" do
32
+ @generator.license = :agpl
33
+ @generator.license_name.should == "GNU Affero General public"
34
+ end
35
+
36
+ it "should display usage if author is blank" do
37
+ lambda {generator(:author => "")}.should raise_error(RubiGen::UsageError)
38
+ end
39
+
40
+ it "should display usage if license is blank" do
41
+ lambda {generator(:license => "")}.should raise_error(RubiGen::UsageError)
42
+ end
43
+
44
+ def exist
45
+ simple_matcher("exist") do |actual|
46
+ File.exist?(actual)
47
+ end
48
+ end
49
+
50
+ def have_text(text)
51
+ simple_matcher("have text") do |actual|
52
+ IO.read(actual).match(text)
53
+ end
54
+ end
55
+
56
+ describe "after creation" do
57
+
58
+ before(:each) do
59
+ generator.create
60
+ end
61
+
62
+ it "should generate a COPYING file" do
63
+ generated_file("COPYING").should exist
64
+ end
65
+
66
+ it "should generate a COPYING file" do
67
+ generated_file("COPYRIGHT").should exist
68
+ end
69
+
70
+ end
71
+
72
+ it "should create a COPYRIGHT file with includes 'Copyright ©'" do
73
+ generator.create
74
+ generated_file("COPYRIGHT").should have_text('Copyright ©')
75
+ end
76
+
77
+ it "should create a COPYRIGHT file with associates author to copyright" do
78
+ generator(:author => "Homer and Bart").create
79
+ generated_file("COPYRIGHT").should have_text(/Copyright ©.*Homer and Bart/)
80
+ end
81
+
82
+ it "should create a COPYRIGHT file with associates author to copyright" do
83
+ generator.tap { |g| g.years = [1,2,3] }.create
84
+ generated_file("COPYRIGHT").should have_text(/Copyright © 1, 2, 3/)
85
+ end
86
+
87
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ require 'generator_spec_helper'
10
+
11
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
12
+ require 'license_generator'
13
+
14
+ include RubiGen::GeneratorTestHelper
15
+
16
+ def with_default_options(options = {})
17
+ { :author => "John Doe", :license => "gpl" }.update(options)
18
+ end
19
+
20
+ def generator(options = {}, params = [])
21
+ build_generator :license, params, generator_sources, with_default_options(options)
22
+ end
23
+
24
+ class RubiGen::Base
25
+
26
+ # Replace run_generator
27
+ def create
28
+ silence_generator do
29
+ self.command(:create).invoke!
30
+ end
31
+ end
32
+
33
+ end
34
+
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_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
@@ -0,0 +1,29 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+ rescue LoadError
4
+ require 'test/unit'
5
+ end
6
+ require 'fileutils'
7
+
8
+ # Must set before requiring generator libs.
9
+ TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
10
+ PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
11
+ app_root = File.join(TMP_ROOT, PROJECT_NAME)
12
+ if defined?(APP_ROOT)
13
+ APP_ROOT.replace(app_root)
14
+ else
15
+ APP_ROOT = app_root
16
+ end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
22
+
23
+ begin
24
+ require 'rubigen'
25
+ rescue LoadError
26
+ require 'rubygems'
27
+ require 'rubigen'
28
+ end
29
+ require 'rubigen/helpers/generator_test_helper'
@@ -0,0 +1,45 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestLicenseGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ name = "myapp"
31
+ run_generator('license', [name], sources)
32
+ assert_directory_exists "some/directory"
33
+ assert_generated_file "some_file"
34
+ end
35
+
36
+ private
37
+ def sources
38
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
39
+ ]
40
+ end
41
+
42
+ def generator_path
43
+ "rubygems_generators"
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: license_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alban Peignier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-07 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubigen
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.5.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rubyforge
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.3
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: gemcutter
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hoe
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.5.0
54
+ version:
55
+ description: Choose the license and generate required documents
56
+ email:
57
+ - alban@tryphon.eu
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files:
63
+ - History.txt
64
+ - Manifest.txt
65
+ - rubygems_generators/license/templates/agpl.txt
66
+ - rubygems_generators/license/templates/gpl.txt
67
+ files:
68
+ - History.txt
69
+ - Manifest.txt
70
+ - README.rdoc
71
+ - Rakefile
72
+ - features/development.feature
73
+ - features/step_definitions/common_steps.rb
74
+ - features/support/common.rb
75
+ - features/support/env.rb
76
+ - features/support/matchers.rb
77
+ - lib/license_generator.rb
78
+ - license_generator.gemspec
79
+ - rubygems_generators/license/USAGE
80
+ - rubygems_generators/license/license_generator.rb
81
+ - rubygems_generators/license/templates/agpl.txt
82
+ - rubygems_generators/license/templates/copyright.erb
83
+ - rubygems_generators/license/templates/gpl.txt
84
+ - script/console
85
+ - script/destroy
86
+ - script/generate
87
+ - spec/license_generator_spec.rb
88
+ - spec/spec.opts
89
+ - spec/spec_helper.rb
90
+ - tasks/rspec.rake
91
+ - test/test_generator_helper.rb
92
+ - test/test_license_generator.rb
93
+ has_rdoc: true
94
+ homepage: http://projects.tryphon.eu/license_generator
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options:
99
+ - --main
100
+ - README.rdoc
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: "0"
108
+ version:
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ requirements: []
116
+
117
+ rubyforge_project: license_generator
118
+ rubygems_version: 1.3.5
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: Choose the license and generate required documents
122
+ test_files:
123
+ - test/test_license_generator.rb
124
+ - test/test_generator_helper.rb