mmini 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 +7 -0
- data/bin/mmini +16 -0
- data/lib/lib_mmini.rb +54 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ae317f32925f7ec911e2252fd85ee5d37bd621253bcf52186b4c80c7ec8cb78b
|
4
|
+
data.tar.gz: e4d5cd87126b97b2cb3d552f49a4d565ecc1ff3669ba3e189b983c30339bd6fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6a4be0a9953e0bab3ccf45c08e9c3491ca92e0208448dd95d00858d83081dd0ee582b7ab90c33fc6375f9d61ba5d9eac042942a304d6557a674ec35a6be6e43
|
7
|
+
data.tar.gz: 6477f76774497d85ffe9c81755953e263fbf9406b30e68ba8d901e10edbcb75d7dad979e3d205f425995e2c03f00f2a9e15b7caadd26e2ab70f2a015af7ae061
|
data/bin/mmini
ADDED
data/lib/lib_mmini.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
require 'json'
|
5
|
+
require 'net/http'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module LibMmini
|
9
|
+
BACKEND_BASE = 'https://mmini.herokuapp.com'.freeze
|
10
|
+
BACKEND = URI.parse(BACKEND_BASE + '/minify')
|
11
|
+
HTTP = Net::HTTP.new(BACKEND.host, BACKEND.port = nil)
|
12
|
+
|
13
|
+
def valid_url?(string)
|
14
|
+
hits = string =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
|
15
|
+
!hits.nil? && hits.zero?
|
16
|
+
end
|
17
|
+
|
18
|
+
def post_url(url)
|
19
|
+
header = { 'Content-Type': 'application/json' }
|
20
|
+
body = {
|
21
|
+
url: url
|
22
|
+
}
|
23
|
+
|
24
|
+
req = Net::HTTP::Post.new(BACKEND.request_uri, header)
|
25
|
+
req.body = body.to_json
|
26
|
+
|
27
|
+
HTTP.request(req)
|
28
|
+
end
|
29
|
+
|
30
|
+
def run(argv, post_url_fn)
|
31
|
+
if argv.length != 1
|
32
|
+
puts 'Only single argument supported'
|
33
|
+
exit!
|
34
|
+
end
|
35
|
+
|
36
|
+
url = argv.first
|
37
|
+
|
38
|
+
unless valid_url?(url)
|
39
|
+
puts 'URL is invalid: ' + url
|
40
|
+
exit!
|
41
|
+
end
|
42
|
+
|
43
|
+
response = post_url_fn.call(url)
|
44
|
+
|
45
|
+
if response.code == '200'
|
46
|
+
id = response.body
|
47
|
+
success = true
|
48
|
+
[success, BACKEND_BASE.to_s + '/' + id]
|
49
|
+
else
|
50
|
+
success = false
|
51
|
+
[success, '']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mmini
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon Egersand
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables:
|
16
|
+
- mmini
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/mmini
|
21
|
+
- lib/lib_mmini.rb
|
22
|
+
homepage: https://github.com/simeg/minifier
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.0.0
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.0.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: CLI client for minifier server
|
45
|
+
test_files: []
|