sign 0.1.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5eb22ecc6ce95485daef7ca63612f5f1cbe59d9b
4
- data.tar.gz: 5115c457f8a0010eddd86685f06e94e43a009d2f
3
+ metadata.gz: 6c1bff5b097d5ae5b177e79f40e00ec1fa6cd42a
4
+ data.tar.gz: 7339e34897141d28bda6ec9e31eee1911d1766cf
5
5
  SHA512:
6
- metadata.gz: '093582cfa72d300fe3fceab2950c14e6d73168d5dc7a5dd90ce8d6f30529c47801ee88e1c637a699403a8b863e115ea766a40d2c797de3471dbd3377308546a3'
7
- data.tar.gz: 3f82bd1878955aa6a8ecfcd14bba359749825f87db90c35612726060215f2341c628cb12f0ec4233dc648122eb363b8af35a77f2323dbbafde96d944f582c9c8
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
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
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
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
+ - 2.2.8
5
+ - 2.3.5
4
6
  - 2.4.2
5
- before_install: gem install bundler -v 1.15.4
7
+ before_install: gem install bundler
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
- ## [0.2.0] - 2017-10-26
19
+
20
+ ## [0.6.0] - 2017-11-02
9
21
  ### Added
10
- - Command prompt using `gem`.
11
- - Display help information using `-h` or `--help` flag.
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
@@ -1,6 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in sign.gemspec
6
3
  gemspec
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
  [![Gem Version](https://badge.fury.io/rb/sign.svg)](https://badge.fury.io/rb/sign)
7
- [![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)
4
+ [![Travis CI](https://img.shields.io/travis/evanscloud/sign.svg)](https://travis-ci.org/evanscloud/sign)
8
5
  [![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg)](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: search for one, copy it, create a text file, and then paste it in (let's not forget changing the year and name too). This process takes about 1-2 mins Well no more! Signer generates a license for you in less than 10 seconds. No need for an internet connection either!
9
+ When you need a license for your project, you have to:
13
10
 
14
- ## Installation
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
- <!-- --- taken from readme doc automated--- -->
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
- bundle exec rake install
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 `--help` to see the entire list). The format is `sign [options] <license name>`.
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 display the license:
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
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/sign"
4
+
5
+ Sign::Runner.new.start
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Sign
2
- VERSION = "0.1.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/sign.rb CHANGED
@@ -1,9 +1,4 @@
1
- require "sign/version"
2
-
3
- module Sign
4
- class Greeting
5
- def self.greet
6
- puts "Hello, world"
7
- end
8
- end
9
- end
1
+ require_relative "sign/version"
2
+ require_relative "sign/runner"
3
+ require_relative "sign/fetcher"
4
+ require_relative "sign/generator"