license_page_extract 0.0.1

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
+ SHA256:
3
+ metadata.gz: 0a1514107be853cbbff31a73c9c49bb95366a6865ee93aeb7ca103a4e1e022eb
4
+ data.tar.gz: c585d8abe9c354432fcfa7ec5f72a34bfd520616d7af7c538ac4f0647181676e
5
+ SHA512:
6
+ metadata.gz: dd77a2908b5567b4a8a851051665a9c17ffc53a8041c9a5cfbc08a1bb7334b86a04fe8bdd2685d5a0dd61c368aa1835e309a66879bb7aa5eaa8d8993719a7715
7
+ data.tar.gz: 6f605374a6354255e77d64e51ee3bcab9b31700dd863fc5d1a426d1d461d9c85f45f9ff0b4eb4a9d20df8586068d28687200e62003802c3b1c949d587fc9f550
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/CHANGELOG ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in license_page_extract.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # LicensePageExtract
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/license_page_extract`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'license_page_extract'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install license_page_extract
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/license_page_extract.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "license_page_extract"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module LicensePageExtract
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,31 @@
1
+ require "license_page_extract/version"
2
+ require 'net/http'
3
+
4
+ module LicensePageExtract
5
+ class LicensePageExtract
6
+
7
+ URI_OPEN_SOURCE_ORG = "https://opensource.org/licenses/"
8
+ URI_CHOOSE_LICENSE_RAW = 'https://raw.githubusercontent.com/github/choosealicense.com/gh-pages/_licenses/'
9
+
10
+ def self.getLicenseText(metadata = true, uri = "")
11
+ if uri.include? URI_OPEN_SOURCE_ORG
12
+ licensefile = uri.split('/')[-1].downcase + ".txt"
13
+ uri = URI("#{URI_CHOOSE_LICENSE_RAW}#{licensefile}")
14
+ license = Net::HTTP.get(uri)
15
+ if !to_boolean(metadata)
16
+ license = license.gsub(/---.*---/m,'')
17
+ end
18
+ puts license
19
+ end
20
+ end
21
+
22
+ def self.to_boolean(string)
23
+ case string
24
+ when /^(true|t|yes|y|1)$/i then true
25
+ when /^(false|f|no|n|0)$/i then false
26
+ else raise "Cannot convert to boolean: #{string}"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "license_page_extract/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = %q{license_page_extract}
8
+ spec.version = "0.0.1"
9
+ spec.authors = ["Josef Andersson"]
10
+ spec.email = ["josef.andersson@gmail.com"]
11
+ spec.licenses = ['MIT']
12
+
13
+ spec.summary = %q{A simple gem that extracts the license from a known license page}
14
+ spec.description = %q{Som License pages like OSI or Choose A License are missing an API to get only the license, without the text. This library will make an url request to a supported license page only return the license, without the HTML etc.}
15
+ spec.homepage = "https://gitlab.com/hanklank/license-page-extract"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://gitlab.com/hanklank/license-page-extract"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 2.0"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: license_page_extract
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josef Andersson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-04 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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: Som License pages like OSI or Choose A License are missing an API to
42
+ get only the license, without the text. This library will make an url request to
43
+ a supported license page only return the license, without the HTML etc.
44
+ email:
45
+ - josef.andersson@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - CHANGELOG
53
+ - Gemfile
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/license_page_extract.rb
59
+ - lib/license_page_extract/version.rb
60
+ - license_page_extract.gemspec
61
+ homepage: https://gitlab.com/hanklank/license-page-extract
62
+ licenses:
63
+ - MIT
64
+ metadata:
65
+ homepage_uri: https://gitlab.com/hanklank/license-page-extract
66
+ source_code_uri: https://gitlab.com/hanklank/license-page-extract
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.7.6.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: A simple gem that extracts the license from a known license page
87
+ test_files: []