opensource 0.6.2 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/History.md +6 -0
- data/LICENSE +1 -1
- data/README.md +11 -16
- data/bin/console +12 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +6 -0
- data/{bin → exe}/opensource +7 -7
- data/lib/open_source.rb +13 -7
- data/lib/open_source/license/generator.rb +31 -0
- data/lib/open_source/license/owner.rb +31 -0
- data/{templates → lib/open_source/license/templates}/apache2.erb +1 -1
- data/{templates → lib/open_source/license/templates}/bsd.erb +3 -3
- data/{templates → lib/open_source/license/templates}/gpl3.erb +2 -2
- data/{templates → lib/open_source/license/templates}/mit.erb +1 -1
- data/lib/open_source/utilities/logging.rb +25 -0
- data/lib/open_source/version.rb +1 -1
- data/opensource.gemspec +13 -12
- metadata +35 -14
- data/lib/open_source/license.rb +0 -29
- data/lib/open_source/owner.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a49b0a7a6f0eb57af9cd727066d3738d835cab24
|
4
|
+
data.tar.gz: 29e1676472604520274219feaa63127e2dc8e59f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea6012b2cad1a20d5d4fde86e064b05c95afeed0637f889f2cd8bd481a87e860c4b19ebffa928aaa41103cb0ef24e2fc005ba870d4660d66ca27cf1d0f5713bc
|
7
|
+
data.tar.gz: a42265fc6f2e913faf0828e5f4a366ffb56c2c18be61e79c6a71a2ef2908a66712573f299b797ab881b757e86990ab9744a540fd2e0332a102105c491c2a69b1
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/History.md
CHANGED
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
(The MIT License)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2016 Mohnish Thallavajhula <i@mohni.sh>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# OpenSource
|
2
|
-
|
2
|
+
[](https://travis-ci.org/mohnish/opensource)
|
3
3
|
[](https://codeclimate.com/github/mohnish/opensource)
|
4
4
|
|
5
|
-
Command line tool that lets you add an open source license to your project by running a simple command.
|
5
|
+
> Command line tool that lets you add an open source license to your project by running a simple command.
|
6
|
+
|
7
|
+
Supports **Ruby 1.9.3+**.
|
6
8
|
|
7
9
|
## Supported Licenses
|
8
10
|
|
@@ -13,27 +15,20 @@ Command line tool that lets you add an open source license to your project by ru
|
|
13
15
|
|
14
16
|
## Installation
|
15
17
|
|
16
|
-
|
18
|
+
Run:
|
17
19
|
|
18
|
-
```
|
19
|
-
gem
|
20
|
+
```bash
|
21
|
+
$ gem install opensource
|
20
22
|
```
|
21
23
|
|
22
|
-
And then execute:
|
23
|
-
|
24
|
-
$ bundle
|
25
|
-
|
26
|
-
Or install it yourself as:
|
27
|
-
|
28
|
-
$ gem install opensource
|
29
|
-
|
30
24
|
## Usage
|
31
|
-
|
25
|
+
|
26
|
+
```bash
|
32
27
|
Usage: opensource OPTIONS
|
33
28
|
|
34
29
|
Specific options:
|
35
30
|
-s, --setup Setup user credentials in ~/.osrc file
|
36
|
-
-l, --license LICENSE LICENSE can be apache2
|
31
|
+
-l, --license LICENSE LICENSE can be apache2, bsd, gpl3, mit
|
37
32
|
-a, --append README Append LICENSE content to README file
|
38
33
|
|
39
34
|
Common options:
|
@@ -45,7 +40,7 @@ Common options:
|
|
45
40
|
|
46
41
|
(The MIT License)
|
47
42
|
|
48
|
-
Copyright (c)
|
43
|
+
Copyright (c) 2016 Mohnish Thallavajhula <i@mohni.sh>
|
49
44
|
|
50
45
|
Permission is hereby granted, free of charge, to any person obtaining
|
51
46
|
a copy of this software and associated documentation files (the
|
data/bin/console
ADDED
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require "pathname"
|
10
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require "rubygems"
|
14
|
+
require "bundler/setup"
|
15
|
+
|
16
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require "pathname"
|
10
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require "rubygems"
|
14
|
+
require "bundler/setup"
|
15
|
+
|
16
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/setup
ADDED
data/{bin → exe}/opensource
RENAMED
@@ -12,11 +12,11 @@ option_parser = OptionParser.new do |opts|
|
|
12
12
|
opts.separator 'Specific options:'
|
13
13
|
|
14
14
|
opts.on('-s', '--setup', 'Setup user credentials in ~/.osrc file') do |s|
|
15
|
-
OpenSource.
|
15
|
+
OpenSource.setup_owner_credentials
|
16
16
|
exit
|
17
17
|
end
|
18
18
|
|
19
|
-
opts.on('-l', '--license LICENSE', OpenSource::
|
19
|
+
opts.on('-l', '--license LICENSE', OpenSource::SUPPORTED_LICENSES, "LICENSE can be #{OpenSource::SUPPORTED_LICENSES.join(', ')}") do |l|
|
20
20
|
options[:license] = l
|
21
21
|
end
|
22
22
|
|
@@ -28,12 +28,12 @@ option_parser = OptionParser.new do |opts|
|
|
28
28
|
opts.separator 'Common options:'
|
29
29
|
|
30
30
|
opts.on_tail('-v', '--version', 'Print the version') do
|
31
|
-
|
31
|
+
OpenSource.logger.info(OpenSource::VERSION)
|
32
32
|
exit
|
33
33
|
end
|
34
34
|
|
35
35
|
opts.on_tail('-h', '--help', 'Show this message') do
|
36
|
-
|
36
|
+
OpenSource.logger.info(opts)
|
37
37
|
exit
|
38
38
|
end
|
39
39
|
end
|
@@ -41,13 +41,13 @@ end
|
|
41
41
|
begin
|
42
42
|
option_parser.parse!
|
43
43
|
if options.empty?
|
44
|
-
|
44
|
+
OpenSource.logger.info(option_parser)
|
45
45
|
exit 0
|
46
46
|
end
|
47
47
|
|
48
|
-
OpenSource::License.new(options).
|
48
|
+
OpenSource::License::Generator.new(options).generate
|
49
49
|
rescue OpenSource::Error => e
|
50
50
|
# TODO: Make sure the above call raises only OpenSource::Error
|
51
|
-
|
51
|
+
OpenSource.logger.fatal("Error: #{e.message}")
|
52
52
|
exit 1
|
53
53
|
end
|
data/lib/open_source.rb
CHANGED
@@ -1,24 +1,30 @@
|
|
1
1
|
require 'open_source/version'
|
2
2
|
require 'open_source/error'
|
3
|
-
require 'open_source/
|
4
|
-
require 'open_source/license'
|
3
|
+
require 'open_source/utilities/logging'
|
4
|
+
require 'open_source/license/owner'
|
5
|
+
require 'open_source/license/generator'
|
5
6
|
|
6
7
|
module OpenSource
|
7
|
-
|
8
|
+
extend Utilities::Logging
|
9
|
+
|
10
|
+
SUPPORTED_LICENSES = Dir.entries(File.expand_path('../open_source/license/templates', __FILE__)).map do |filename|
|
8
11
|
File.basename(filename, '.erb') if !['.', '..'].include?(filename)
|
9
12
|
end.compact
|
10
13
|
|
14
|
+
CONFIG_PATH = File.expand_path('~/.osrc')
|
15
|
+
|
11
16
|
def self.request_owner_credentials
|
12
|
-
|
17
|
+
OpenSource.logger.info("Enter full name: ")
|
13
18
|
name = gets.chomp
|
14
|
-
|
19
|
+
OpenSource.logger.info("Enter email address: ")
|
15
20
|
email = gets.chomp
|
16
21
|
|
17
22
|
{ name: name, email: email }
|
18
23
|
end
|
19
24
|
|
20
|
-
def self.
|
25
|
+
def self.setup_owner_credentials
|
21
26
|
owner_credentials = request_owner_credentials
|
22
|
-
Owner.
|
27
|
+
owner = License::Owner.new
|
28
|
+
owner.credentials = owner_credentials
|
23
29
|
end
|
24
30
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module OpenSource
|
4
|
+
module License
|
5
|
+
class Generator
|
6
|
+
def initialize(options)
|
7
|
+
@options = options
|
8
|
+
@owner = Owner.new
|
9
|
+
@license = ERB.new(File.read("#{File.expand_path("../templates", __FILE__)}/#{@options[:license]}.erb"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate
|
13
|
+
create_license_file
|
14
|
+
append_to_file if @options[:append]
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def create_license_file
|
19
|
+
f = File.new("#{Dir.pwd}/LICENSE", 'w')
|
20
|
+
f.write(@license.result(binding))
|
21
|
+
f.close
|
22
|
+
end
|
23
|
+
|
24
|
+
def append_to_file
|
25
|
+
File.open(File.expand_path(@options[:append]), 'a') do |f|
|
26
|
+
f << "\n## License\n\n#{@license.result(binding)}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module OpenSource
|
4
|
+
module License
|
5
|
+
class Owner
|
6
|
+
def credentials=(credentials)
|
7
|
+
config_file = File.new(CONFIG_PATH, 'w')
|
8
|
+
file_contents = YAML.dump(credentials)
|
9
|
+
config_file.write(file_contents)
|
10
|
+
rescue StandardError => ex
|
11
|
+
OpenSource.logger.fatal("Unable to access #{CONFIG_PATH}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def credentials
|
15
|
+
@credentials ||= YAML.load_file(CONFIG_PATH)
|
16
|
+
end
|
17
|
+
|
18
|
+
def email
|
19
|
+
credentials[:email]
|
20
|
+
end
|
21
|
+
|
22
|
+
def markdown_supported_email
|
23
|
+
"<#{credentials[:email]}>"
|
24
|
+
end
|
25
|
+
|
26
|
+
def name
|
27
|
+
credentials[:name]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -187,7 +187,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
188
188
|
identification within third-party archives.
|
189
189
|
|
190
|
-
Copyright <%= Time.now.year %> <%= @
|
190
|
+
Copyright <%= Time.now.year %> <%= @owner.name %> <%= @owner.markdown_supported_email %>
|
191
191
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
193
193
|
you may not use this file except in compliance with the License.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) <%= Time.now.year %> <%= @
|
1
|
+
Copyright (c) <%= Time.now.year %> <%= @owner.name %> <%= @owner.markdown_supported_email %>
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without
|
@@ -8,14 +8,14 @@ modification, are permitted provided that the following conditions are met:
|
|
8
8
|
* Redistributions in binary form must reproduce the above copyright
|
9
9
|
notice, this list of conditions and the following disclaimer in the
|
10
10
|
documentation and/or other materials provided with the distribution.
|
11
|
-
* Neither the name of <%= @
|
11
|
+
* Neither the name of <%= @owner.name %> nor the
|
12
12
|
names of its contributors may be used to endorse or promote products
|
13
13
|
derived from this software without specific prior written permission.
|
14
14
|
|
15
15
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
16
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
17
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
-
DISCLAIMED. IN NO EVENT SHALL <%= @
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL <%= @owner.name.upcase %> BE LIABLE FOR ANY
|
19
19
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
20
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
21
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
|
|
632
632
|
the "copyright" line and a pointer to where the full notice is found.
|
633
633
|
|
634
634
|
<one line to give the program's name and a brief idea of what it does.>
|
635
|
-
Copyright (C) <%= Time.now.year %> <%= @
|
635
|
+
Copyright (C) <%= Time.now.year %> <%= @owner.name %> <%= @owner.markdown_supported_email %>
|
636
636
|
|
637
637
|
This program is free software: you can redistribute it and/or modify
|
638
638
|
it under the terms of the GNU General Public License as published by
|
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|
652
652
|
If the program does terminal interaction, make it output a short
|
653
653
|
notice like this when it starts in an interactive mode:
|
654
654
|
|
655
|
-
Copyright (C) <%= Time.now.year %> <%= @
|
655
|
+
Copyright (C) <%= Time.now.year %> <%= @owner.name %> <%= @owner.markdown_supported_email %>
|
656
656
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657
657
|
This is free software, and you are welcome to redistribute it
|
658
658
|
under certain conditions; type `show c' for details.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
(The MIT License)
|
2
2
|
|
3
|
-
Copyright (c) <%= Time.now.year %> <%= @
|
3
|
+
Copyright (c) <%= Time.now.year %> <%= @owner.name %> <%= @owner.markdown_supported_email %>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module OpenSource
|
4
|
+
module Utilities
|
5
|
+
module Logging
|
6
|
+
class Simple < Logger::Formatter
|
7
|
+
def call(severity, time, progname, msg)
|
8
|
+
"OpenSource: #{msg}\n"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def logger
|
13
|
+
@logger ||= initialize_logger
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def initialize_logger
|
18
|
+
logger = Logger.new(STDOUT)
|
19
|
+
logger.level = Logger::INFO
|
20
|
+
logger.formatter = Simple.new
|
21
|
+
logger
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/open_source/version.rb
CHANGED
data/opensource.gemspec
CHANGED
@@ -4,20 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'open_source/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'opensource'
|
8
8
|
spec.version = OpenSource::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary = %q{Command line tool that lets you add an open source license to your project by running a simple command}
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.license = "MIT"
|
9
|
+
spec.authors = ['Mohnish Thallavajhula']
|
10
|
+
spec.email = ['i@mohni.sh']
|
11
|
+
spec.summary = spec.description = %q{Command line tool that lets you add an open source license to your project by running a simple command}
|
12
|
+
spec.homepage = 'https://github.com/mohnish/opensource'
|
13
|
+
spec.license = 'MIT'
|
15
14
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = 'exe'
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opensource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohnish Thallavajhula
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.11'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
41
55
|
description: Command line tool that lets you add an open source license to your project
|
42
56
|
by running a simple command
|
43
57
|
email:
|
@@ -49,23 +63,30 @@ extra_rdoc_files: []
|
|
49
63
|
files:
|
50
64
|
- ".codeclimate.yml"
|
51
65
|
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
52
68
|
- Gemfile
|
53
69
|
- History.md
|
54
70
|
- LICENSE
|
55
71
|
- README.md
|
56
72
|
- Rakefile
|
57
|
-
- bin/
|
73
|
+
- bin/console
|
74
|
+
- bin/rake
|
75
|
+
- bin/rspec
|
76
|
+
- bin/setup
|
77
|
+
- exe/opensource
|
58
78
|
- lib/open_source.rb
|
59
79
|
- lib/open_source/error.rb
|
60
|
-
- lib/open_source/license.rb
|
61
|
-
- lib/open_source/owner.rb
|
80
|
+
- lib/open_source/license/generator.rb
|
81
|
+
- lib/open_source/license/owner.rb
|
82
|
+
- lib/open_source/license/templates/apache2.erb
|
83
|
+
- lib/open_source/license/templates/bsd.erb
|
84
|
+
- lib/open_source/license/templates/gpl3.erb
|
85
|
+
- lib/open_source/license/templates/mit.erb
|
86
|
+
- lib/open_source/utilities/logging.rb
|
62
87
|
- lib/open_source/version.rb
|
63
88
|
- opensource.gemspec
|
64
|
-
|
65
|
-
- templates/bsd.erb
|
66
|
-
- templates/gpl3.erb
|
67
|
-
- templates/mit.erb
|
68
|
-
homepage: https://github.com/mohnish/opensource.rb
|
89
|
+
homepage: https://github.com/mohnish/opensource
|
69
90
|
licenses:
|
70
91
|
- MIT
|
71
92
|
metadata: {}
|
@@ -85,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
106
|
version: '0'
|
86
107
|
requirements: []
|
87
108
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.5.1
|
89
110
|
signing_key:
|
90
111
|
specification_version: 4
|
91
112
|
summary: Command line tool that lets you add an open source license to your project
|
data/lib/open_source/license.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module OpenSource
|
4
|
-
class License
|
5
|
-
def initialize(options)
|
6
|
-
@options = options
|
7
|
-
@user = Owner.get_credentials
|
8
|
-
@license = ERB.new(File.read("#{File.expand_path("../../../templates", __FILE__)}/#{@options[:license]}.erb")).result(binding)
|
9
|
-
end
|
10
|
-
|
11
|
-
def process
|
12
|
-
generate
|
13
|
-
append if @options[:append]
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def generate
|
18
|
-
f = File.new("#{Dir.pwd}/LICENSE", "w")
|
19
|
-
f.write(@license)
|
20
|
-
f.close
|
21
|
-
end
|
22
|
-
|
23
|
-
def append
|
24
|
-
File.open(File.expand_path(@options[:append]), "a") do |f|
|
25
|
-
f << "\n## License\n\n#{@license}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/open_source/owner.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module OpenSource
|
2
|
-
module Owner
|
3
|
-
extend self
|
4
|
-
|
5
|
-
OSRC_PATH = File.expand_path("~/.osrc")
|
6
|
-
|
7
|
-
def set_credentials credentials
|
8
|
-
f = File.new(OSRC_PATH, "w")
|
9
|
-
f.write <<-CREDENTIALS.gsub /^\s+/, ""
|
10
|
-
name: #{credentials[:name]}
|
11
|
-
email: #{credentials[:email]}
|
12
|
-
escaped_email: <#{credentials[:email]}>
|
13
|
-
CREDENTIALS
|
14
|
-
f.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_credentials
|
18
|
-
credentials = {}
|
19
|
-
|
20
|
-
IO.foreach(OSRC_PATH) do |line|
|
21
|
-
current_line = line.strip
|
22
|
-
if !current_line.empty?
|
23
|
-
key, value = current_line.split(':')
|
24
|
-
credentials[key.strip.to_sym] = value.strip
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
credentials
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|