sign 0.1.0 → 0.6.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 +5 -3
- data/.travis.yml +3 -1
- data/CHANGELOG.md +34 -3
- data/Gemfile +0 -3
- data/README.md +18 -23
- data/bin/sign +5 -0
- data/lib/sign/fetcher.rb +34 -0
- data/lib/sign/generator.rb +61 -0
- data/lib/sign/runner.rb +59 -0
- data/lib/sign/version.rb +1 -1
- data/lib/sign.rb +4 -9
- data/vendor/licenses/agpl-3.0.txt +661 -0
- data/vendor/licenses/apache-2.0.txt +201 -0
- data/vendor/licenses/bsd-2.txt +25 -0
- data/vendor/licenses/bsd-3.txt +29 -0
- data/vendor/licenses/gpl-2.0.txt +339 -0
- data/vendor/licenses/gpl-3.0.txt +674 -0
- data/vendor/licenses/mit.txt +21 -0
- data/vendor/licenses/unlicense.txt +24 -0
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c1bff5b097d5ae5b177e79f40e00ec1fa6cd42a
|
4
|
+
data.tar.gz: 7339e34897141d28bda6ec9e31eee1911d1766cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331a0a5f1cd6872a5940d0a31a2fe5066e28891e4081754a562db855d86f4fab36224545d4390081351320306ac56b02c0673aa42c959e7c01b39b938ae2145f
|
7
|
+
data.tar.gz: b3f7504cfa5d16ffda2562a6171fc36b6caa6e4125d971a59fe93ee4ee28f893aeabb7b0926c5d3859350cbe6a06f8d811a596aaacc5fb342f40b3d4271951a9
|
data/.gitignore
CHANGED
@@ -42,11 +42,13 @@ build-iPhoneSimulator/
|
|
42
42
|
|
43
43
|
# for a library or gem, you might want to ignore these files since the code is
|
44
44
|
# intended to run in multiple environments; otherwise, check them in:
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
Gemfile.lock
|
46
|
+
.ruby-version
|
47
|
+
.ruby-gemset
|
48
|
+
.rspec_status
|
48
49
|
|
49
50
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
51
|
.rvmrc
|
51
52
|
|
52
53
|
notes.md
|
54
|
+
.DS_STORE
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,13 +4,44 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.0.1] - 2017-11-02
|
8
|
+
### Added
|
9
|
+
- More licenses.
|
10
|
+
### Changed
|
11
|
+
- Sign will check if a license file exists before creating/overwriting.
|
12
|
+
- Alias for options and flags.
|
13
|
+
- Overall refactor of code to improve code readability.
|
14
|
+
|
15
|
+
## [1.0.0] - 2017-11-02
|
16
|
+
### Changed
|
17
|
+
- Update README.
|
7
18
|
|
8
|
-
|
19
|
+
|
20
|
+
## [0.6.0] - 2017-11-02
|
9
21
|
### Added
|
10
|
-
-
|
11
|
-
|
22
|
+
- Licenses assemble! Look at the entire list with `sign --list`.
|
23
|
+
|
24
|
+
|
25
|
+
## [0.5.0] - 2017-11-01
|
26
|
+
### Added
|
27
|
+
- Runner is able to fetch and generate a license.
|
28
|
+
- Runner saves generated licenses into current project directory.
|
29
|
+
- Option to display version number.
|
30
|
+
- Tests for `Sign::Fetcher`.
|
31
|
+
- Tests for `Sign::Generator`.
|
32
|
+
### Changed
|
33
|
+
- Add tests for `Sign::Runner#create_license`.
|
34
|
+
|
35
|
+
|
36
|
+
## [0.2.0] - 2017-10-28
|
37
|
+
### Added
|
38
|
+
- Cli prompt in `runner.rb`.
|
39
|
+
- Return help information using `--help`.
|
40
|
+
- Tests for cli initialization and help information.
|
41
|
+
- Create `TestHelper` module to capture stdout and stderr.
|
12
42
|
### Changed
|
13
43
|
- Rename project `lc -> sign`.
|
14
44
|
|
45
|
+
|
15
46
|
## [0.1.0] - 2017-10-25
|
16
47
|
- Create initial project structure.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
# Sign
|
2
2
|
|
3
|
-
Generate a license for your project in a matter of seconds.
|
4
|
-
|
5
|
-
|
6
3
|
[](https://badge.fury.io/rb/sign)
|
7
|
-
[](https://travis-ci.org/evanscloud/sign)
|
8
5
|
[](https://opensource.org/licenses/MIT)
|
9
6
|
|
10
7
|
**tl;dr**: Generate a license for your project in less than 10 seconds.
|
11
8
|
|
12
|
-
When you need a license for your project, you have to:
|
9
|
+
When you need a license for your project, you have to:
|
13
10
|
|
14
|
-
|
11
|
+
1. Search for one on the web.
|
12
|
+
2. Copy it.
|
13
|
+
3. Create a text file.
|
14
|
+
4. Paste into text file.
|
15
|
+
5. Ugh (don't forget to change name and year if it's not filled in).
|
15
16
|
|
16
|
-
|
17
|
+
This process can take about 1-2 minutes, precious time that you can be using for more important things. Well no more! Sign creates a license in your current project directory for you in less than 10 seconds. No need for an internet connection either!
|
18
|
+
|
19
|
+
## Installation
|
17
20
|
|
18
21
|
Add this line to your application's Gemfile:
|
19
22
|
|
@@ -21,31 +24,19 @@ Add this line to your application's Gemfile:
|
|
21
24
|
gem 'sign'
|
22
25
|
```
|
23
26
|
|
24
|
-
And then execute:
|
25
|
-
|
26
|
-
$ bundle
|
27
|
-
|
28
|
-
Or install it yourself as:
|
29
|
-
|
30
|
-
$ gem install sign
|
31
|
-
|
32
|
-
<!-- --- -->
|
27
|
+
And then execute `bundle`. Or install using the command-line with:
|
33
28
|
|
34
29
|
```
|
35
|
-
|
36
|
-
```
|
37
|
-
|
38
|
-
```
|
39
|
-
gem install
|
30
|
+
$ gem install sign
|
40
31
|
```
|
41
32
|
|
42
33
|
## Usage
|
43
34
|
|
44
|
-
There are a wide range of licenses available (enter `--
|
35
|
+
There are a wide range of licenses available (enter `--list` to see the entire list). The format is `sign <license name>`.
|
45
36
|
|
46
37
|
### Examples
|
47
38
|
|
48
|
-
To
|
39
|
+
To create an MIT license:
|
49
40
|
|
50
41
|
```
|
51
42
|
```
|
@@ -57,6 +48,10 @@ To create a file and save a license in it:
|
|
57
48
|
|
58
49
|
To
|
59
50
|
|
51
|
+
## Updates
|
52
|
+
|
53
|
+
Check [CHANGELOG](https://github.com/evanscloud/sign/blob/master/CHANGELOG.md) for all updates.
|
54
|
+
|
60
55
|
## Development
|
61
56
|
|
62
57
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bin/sign
ADDED
data/lib/sign/fetcher.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Sign
|
2
|
+
class Fetcher
|
3
|
+
@@list = {}
|
4
|
+
|
5
|
+
Dir["vendor/licenses/*.txt"].select do |file|
|
6
|
+
if File.file?(file)
|
7
|
+
name = File.basename(file, ".txt")
|
8
|
+
info = File.open(file){ |file| file.readline }.downcase.strip.gsub(/[^-a-z0-9\s]/, "")
|
9
|
+
@@list[name] = info
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.get_list
|
14
|
+
format = "%-16s %10s"
|
15
|
+
|
16
|
+
@@list.each do |name, info|
|
17
|
+
puts format % [name, info]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(license)
|
22
|
+
if @@list.has_key?(license.downcase)
|
23
|
+
file_name = "#{license}.txt"
|
24
|
+
File.open("#{license_path}/#{file_name}")
|
25
|
+
else
|
26
|
+
raise ArgumentError, "#{license} is not available."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def license_path
|
31
|
+
File.expand_path("../../vendor/licenses", __dir__)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "Date"
|
2
|
+
|
3
|
+
module Sign
|
4
|
+
class Generator
|
5
|
+
def make(license, name, year)
|
6
|
+
raise ArgumentError, "#{license} is not available." unless File.readable?(license)
|
7
|
+
|
8
|
+
license_template = File.read(license)
|
9
|
+
name = get_name if name.nil?
|
10
|
+
year = get_year if year.nil?
|
11
|
+
|
12
|
+
if placeholders_exist?(license_template)
|
13
|
+
modified_license = license_template.gsub("[AUTHOR]", name)
|
14
|
+
modified_license = modified_license.gsub("[YEAR]", year)
|
15
|
+
end
|
16
|
+
|
17
|
+
create_new_file(modified_license)
|
18
|
+
end
|
19
|
+
|
20
|
+
def placeholders_exist?(license_template)
|
21
|
+
placeholders = ["[YEAR]", "[AUTHOR]"]
|
22
|
+
|
23
|
+
placeholders.any? { |placeholder| license_template.include?(placeholder) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_new_file(modified_license)
|
27
|
+
new_file = File.new("LICENSE", "w")
|
28
|
+
new_file.puts(modified_license)
|
29
|
+
new_file.close
|
30
|
+
puts "License created \033[91m<3\033[0m"
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_name
|
34
|
+
if gitconfig_exist?
|
35
|
+
find_name
|
36
|
+
else
|
37
|
+
return ""
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_name
|
42
|
+
File.foreach("#{gitconfig_path}/.gitconfig").detect do |line|
|
43
|
+
if line.match("\tname")
|
44
|
+
return line.scan(/= (.*)/).last[0]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_year
|
50
|
+
return Date.today.year.to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
def gitconfig_exist?
|
54
|
+
File.exist?("#{gitconfig_path}/.gitconfig")
|
55
|
+
end
|
56
|
+
|
57
|
+
def gitconfig_path
|
58
|
+
File.expand_path("~/", __dir__)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/sign/runner.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Sign
|
2
|
+
class Runner
|
3
|
+
def start
|
4
|
+
argv = ARGV.clone
|
5
|
+
argv << "--help" if argv.empty?
|
6
|
+
|
7
|
+
case argv[0]
|
8
|
+
when "--help"
|
9
|
+
display_help
|
10
|
+
when "--version"
|
11
|
+
display_version
|
12
|
+
when "--list"
|
13
|
+
display_list
|
14
|
+
else
|
15
|
+
create_license(argv)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def display_help
|
20
|
+
puts ""
|
21
|
+
puts " Generate a license for your project in a matter of seconds."
|
22
|
+
puts ""
|
23
|
+
puts " Usage:"
|
24
|
+
puts ""
|
25
|
+
puts " sign [option] <license>"
|
26
|
+
puts ""
|
27
|
+
puts " Options:"
|
28
|
+
puts ""
|
29
|
+
puts " --version display version number"
|
30
|
+
puts " --help display help information"
|
31
|
+
puts " --list display list of licenses"
|
32
|
+
puts ""
|
33
|
+
end
|
34
|
+
|
35
|
+
def display_list
|
36
|
+
puts ""
|
37
|
+
puts "List of available licenses:"
|
38
|
+
puts ""
|
39
|
+
Sign::Fetcher.get_list
|
40
|
+
puts ""
|
41
|
+
end
|
42
|
+
|
43
|
+
def display_version
|
44
|
+
puts "Sign v#{Sign::VERSION}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_license(argv)
|
48
|
+
license = Sign::Fetcher.new.get(argv[0])
|
49
|
+
name = !!argv[1] ? parse_argument(argv[1]) : nil
|
50
|
+
year = !!argv[2] ? parse_argument(argv[2]) : nil
|
51
|
+
|
52
|
+
Sign::Generator.new.make(license, name, year)
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_argument(arg)
|
56
|
+
arg.scan(/=(.*)/).last[0]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/sign/version.rb
CHANGED
data/lib/sign.rb
CHANGED