sign 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -0
- data/lib/sign/fetcher.rb +12 -23
- data/lib/sign/runner.rb +19 -6
- data/lib/sign/version.rb +1 -1
- data/sign.gemspec +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fd6f7cc94ac5dc8bfd4aa196f2262cdddd8c962b7927dbcef9cc46186091fe82
|
4
|
+
data.tar.gz: edfa62d2cfd14c08c623e6ba30b21fe1c4a3925d722206348c5861bcd765f207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e615613d00475dcce1cc9ae56a8a402e409542027f7a3621434b4afba07c652ff622187707a9505c2c673ec6453f79ad05d58e5efcbb6149c4cb6891f6c66dc
|
7
|
+
data.tar.gz: 637b2c18e0f698ff03f0f4c1863ece06dcc19ad5f93a6251a4cfe1fca6dcc5de46331d23ad9d562334b1b61424f854886bcb30728f7641813d01a56014ce1bbf
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ 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.3] - 2017-11-11
|
8
|
+
### Changed
|
9
|
+
- Fix issue where `Sign` wasn't able to locate license templates.
|
10
|
+
- Update specs.
|
11
|
+
|
12
|
+
|
7
13
|
## [1.0.2] - 2017-11-03
|
8
14
|
### Changed
|
9
15
|
- Sign will check if a license file exists before creating/overwriting.
|
data/lib/sign/fetcher.rb
CHANGED
@@ -1,34 +1,23 @@
|
|
1
1
|
module Sign
|
2
2
|
class Fetcher
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
|
4
|
+
def self.get_list(list)
|
5
|
+
Dir["#{$LOAD_PATH[2]}/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 unless list.has_key?(name)
|
10
|
+
end
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
@@list.each do |name, info|
|
17
|
-
puts format % [name, info]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_license(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
|
14
|
+
def get_license(license)
|
15
|
+
file_name = "#{license}.txt"
|
16
|
+
File.open("#{license_path}/#{file_name}")
|
28
17
|
end
|
29
18
|
|
30
19
|
def license_path
|
31
|
-
File.expand_path("
|
20
|
+
File.expand_path("#{$LOAD_PATH[2]}/licenses", __dir__)
|
32
21
|
end
|
33
22
|
end
|
34
23
|
end
|
data/lib/sign/runner.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
module Sign
|
2
2
|
class Runner
|
3
3
|
def start
|
4
|
+
list = {}
|
5
|
+
|
4
6
|
argv = ARGV.clone
|
5
7
|
argv << "--help" if argv.empty?
|
8
|
+
|
9
|
+
Sign::Fetcher.get_list(list)
|
6
10
|
|
7
11
|
case argv[0]
|
8
12
|
when "--help", "-h"
|
@@ -10,9 +14,9 @@ module Sign
|
|
10
14
|
when "--version", "-v"
|
11
15
|
show_version
|
12
16
|
when "--list", "-l"
|
13
|
-
show_list
|
17
|
+
show_list(list)
|
14
18
|
else
|
15
|
-
create_license(argv) unless license_exist?
|
19
|
+
create_license(argv, list) unless license_exist?
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
@@ -32,11 +36,15 @@ module Sign
|
|
32
36
|
puts ""
|
33
37
|
end
|
34
38
|
|
35
|
-
def show_list
|
39
|
+
def show_list(list)
|
40
|
+
format = "%-16s %10s"
|
41
|
+
|
36
42
|
puts ""
|
37
43
|
puts "List of available licenses:"
|
38
44
|
puts ""
|
39
|
-
|
45
|
+
list.each do |name, info|
|
46
|
+
puts format % [name, info]
|
47
|
+
end
|
40
48
|
puts ""
|
41
49
|
end
|
42
50
|
|
@@ -68,8 +76,13 @@ module Sign
|
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|
71
|
-
def create_license(argv)
|
72
|
-
|
79
|
+
def create_license(argv, list)
|
80
|
+
if list.has_key?(argv[0].downcase)
|
81
|
+
license = Sign::Fetcher.new.get_license(argv[0])
|
82
|
+
else
|
83
|
+
raise ArgumentError, "#{argv[0]} is not available."
|
84
|
+
end
|
85
|
+
|
73
86
|
name = !!argv[1] ? parse_argument(argv[1]) : nil
|
74
87
|
year = !!argv[2] ? parse_argument(argv[2]) : nil
|
75
88
|
|
data/lib/sign/version.rb
CHANGED
data/sign.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
vendor = File.expand_path("../vendor", __FILE__)
|
5
|
+
$LOAD_PATH.unshift(vendor) unless $LOAD_PATH.include?(vendor)
|
4
6
|
require "sign/version"
|
5
7
|
|
6
8
|
Gem::Specification.new do |spec|
|
@@ -26,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
26
28
|
end
|
27
29
|
spec.bindir = "bin"
|
28
30
|
spec.executables = spec.files.grep(%r{^bin/sign}) { |f| File.basename(f) }
|
29
|
-
spec.require_paths = ["lib"]
|
31
|
+
spec.require_paths = ["lib", "vendor"]
|
30
32
|
spec.required_ruby_version = '>= 2.2.8'
|
31
33
|
|
32
34
|
spec.add_development_dependency "bundler", "~> 1.15"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sign
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Ng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,6 +114,7 @@ post_install_message:
|
|
114
114
|
rdoc_options: []
|
115
115
|
require_paths:
|
116
116
|
- lib
|
117
|
+
- vendor
|
117
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
119
|
requirements:
|
119
120
|
- - ">="
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.7.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Generate a license for your project right from your command-line.
|