opensource 0.3.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4e83d8af3f0788afa7ebb82bd65a997fd5b71ff
4
+ data.tar.gz: 2dd6bdd76f1b6d3937b7694901832ba8501f4ae0
5
+ SHA512:
6
+ metadata.gz: c64ffb2dae7ed3a4eff3d27247378c1e63b43d857503e3b4b2faa4ac0a312468eeb045e97727616552a5a52cf3e188a8c6d190ed610f0b6c8932449fa0840fc1
7
+ data.tar.gz: a005bce24ca23a02217da0e509d1db485f68a16c5efb88045f5ca2fa88ea1f54c931a077315b04555ae9c028eb416ffd22f0a6d335ca646c888a7cb56b5359ac
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in opensource.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014 Mohnish Thallavajhula <i@mohni.sh>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ ## Opensource.rb
2
+
3
+ Add an Opensource License to your project
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'opensource'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install opensource
20
+
21
+ ## Usage
22
+ ```
23
+ opensource OPTIONS
24
+
25
+ Specific options:
26
+ -l, --license LICENSE LICENSE can be mit
27
+ -a, --append README Append LICENSE content to README file
28
+
29
+ Common options:
30
+ -v, --version Print the version
31
+ -h, --help Show this message
32
+ ```
33
+
34
+ ## License
35
+
36
+ (The MIT License)
37
+
38
+ Copyright (c) 2014 Mohnish Thallavajhula <i@mohni.sh>
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining
41
+ a copy of this software and associated documentation files (the
42
+ 'Software'), to deal in the Software without restriction, including
43
+ without limitation the rights to use, copy, modify, merge, publish,
44
+ distribute, sublicense, and/or sell copies of the Software, and to
45
+ permit persons to whom the Software is furnished to do so, subject to
46
+ the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be
49
+ included in all copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
52
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
54
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
55
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
56
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
57
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/opensource ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../lib/opensource'
5
+
6
+ options = {}
7
+
8
+ LICENSES = Dir.new('./templates').map do |filename|
9
+ File.basename(filename, '.erb') if !['.', '..'].include?(filename)
10
+ end.compact
11
+
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} OPTIONS"
14
+ opts.separator ''
15
+ opts.separator 'Specific options:'
16
+
17
+ opts.on('-l', '--license LICENSE', LICENSES, "LICENSE can be #{LICENSES.join('|')}") do |l|
18
+ options[:license] = l
19
+ end
20
+
21
+ opts.on('-a', '--append README', 'Append LICENSE content to README file') do |a|
22
+ options[:append] = a
23
+ end
24
+
25
+ opts.separator ''
26
+ opts.separator 'Common options:'
27
+
28
+ opts.on_tail('-v', '--version', 'Print the version') do
29
+ puts Opensource::VERSION
30
+ exit
31
+ end
32
+
33
+ opts.on_tail('-h', '--help', 'Show this message') do
34
+ puts opts
35
+ exit
36
+ end
37
+ end.parse!
38
+
39
+ begin
40
+ Opensource::License.new(options).process
41
+ rescue Opensource::Error => e
42
+ # TODO: Make sure the above call raises only Opensource::Error
43
+ puts "Error: #{e.message}"
44
+ exit 1
45
+ end
data/lib/opensource.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative 'opensource/version'
2
+ require_relative 'opensource/error'
3
+ require_relative 'opensource/owner'
4
+ require_relative 'opensource/license'
5
+
6
+ module Opensource
7
+
8
+ end
@@ -0,0 +1,7 @@
1
+ module Opensource
2
+ module Error
3
+ def self.exception(*args)
4
+ RuntimeError.new(*args).extend(self)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ require 'erb'
2
+
3
+ module Opensource
4
+ class License
5
+ def initialize(options)
6
+ @options = options
7
+ @user = Owner.get_credentials
8
+ @user['escaped_email'] = "<#{@user['email']}>"
9
+ @license = ERB.new(File.read(File.expand_path("./templates/#{@options[:license]}.erb"))).result(binding)
10
+ end
11
+
12
+ def process
13
+ generate
14
+ append if @options[:append]
15
+ end
16
+
17
+ private
18
+ def generate
19
+ f = File.new("#{Dir.pwd}/LICENSE", "w")
20
+ f.write(@license)
21
+ f.close
22
+ end
23
+
24
+ def append
25
+ File.open(File.expand_path(@options[:append]), "a") do |f|
26
+ f << "\n## License\n\n#{@license}"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ module Opensource
2
+ module Owner
3
+ extend self
4
+
5
+ def set_credentials
6
+ puts "Enter full name: "
7
+ name = gets.chomp
8
+ puts "Enter email address: "
9
+ email = gets.chomp
10
+
11
+ f = File.new(File.expand_path("~/.osrc"), "w")
12
+ f.write <<-CREDENTIALS
13
+ name: #{name}
14
+ email: #{email}
15
+ CREDENTIALS
16
+ f.close
17
+ end
18
+
19
+ def get_credentials
20
+ user = {}
21
+
22
+ IO.foreach(File.expand_path("~/.osrc")) do |line|
23
+ current_line = line.strip
24
+ if !current_line.empty?
25
+ key, value = current_line.split(':')
26
+ user[key.strip] = value.strip
27
+ end
28
+ end
29
+
30
+ user
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Opensource
2
+ VERSION = '0.3.0'
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'opensource/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "opensource"
8
+ spec.version = Opensource::VERSION
9
+ spec.authors = ["Mohnish Thallavajhula"]
10
+ spec.email = ["i@mohni.sh"]
11
+ spec.summary = %q{Add a license to your opensource project}
12
+ spec.description = %q{Add a license to your opensource project by running a simple command}
13
+ spec.homepage = "http://mohni.sh/opensource"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
data/templates/mit.erb ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) <%= Time.now.year %> <%= @user['name'] %> <%= @user['escaped_email'] %>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opensource
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Mohnish Thallavajhula
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Add a license to your opensource project by running a simple command
42
+ email:
43
+ - i@mohni.sh
44
+ executables:
45
+ - opensource
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - bin/opensource
56
+ - lib/opensource.rb
57
+ - lib/opensource/error.rb
58
+ - lib/opensource/license.rb
59
+ - lib/opensource/owner.rb
60
+ - lib/opensource/version.rb
61
+ - opensource.gemspec
62
+ - templates/mit.erb
63
+ homepage: http://mohni.sh/opensource
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Add a license to your opensource project
87
+ test_files: []