lgm 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
+ SHA1:
3
+ metadata.gz: f4bfb2208678b420a8e0aca9e926eeb843636d5a
4
+ data.tar.gz: 263966e8af9be3359b361730fe305d6e0edcb560
5
+ SHA512:
6
+ metadata.gz: ea7b1c30c18b60f18c758421b4fdae6ff95c77724353a72840b8855977878392100c1c1f2f375d14722e0ebc05f9e7afff126f8ec1cc1dce1c1da527ae09090c
7
+ data.tar.gz: 5db652eaac2ed220389bac38c1d0889c0dfafcadff3ad56b6ee0e7866850047f707a31dca44f36447af3b3e61fc6f71d841db1c1d03eef7e9798674c34e44d9c
data/bin/lgm ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'puma'
4
+ require_relative '../api/app'
5
+
6
+ server = Puma::Server.new App.new
7
+ server.add_tcp_listener '127.0.0.1:8000'
8
+ server.run
9
+ sleep
data/server/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'hobby'
4
+ gem 'hobby-json'
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ hobby (0.1.1)
5
+ rack
6
+ hobby-json (0.0.4)
7
+ rack
8
+ rack (2.0.3)
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ hobby
15
+ hobby-json
16
+
17
+ BUNDLED WITH
18
+ 1.16.1
data/server/app.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'hobby'
2
+ require 'hobby/json'
3
+
4
+ require_relative 'link'
5
+ LINKS = [Link.new('/main.js'), Link.new('/another.html')]
6
+
7
+ class API
8
+ include Hobby
9
+ include JSON
10
+
11
+ get '/links' do
12
+ LINKS
13
+ end
14
+
15
+ post '/links' do
16
+ link = Link.new json['link']
17
+
18
+ if link.valid?
19
+ LINKS << link
20
+ link
21
+ else
22
+ response.status = 422
23
+ end
24
+ end
25
+ end
26
+
27
+ class App
28
+ include Hobby
29
+
30
+ def initialize path
31
+ @path = path
32
+ end
33
+
34
+ map '/api', API.new
35
+
36
+ get do
37
+ IO.read "#{@path}/index.html"
38
+ end
39
+
40
+ get '/:name.:ext' do
41
+ IO.read "#{@path}/#{my[:name]}.#{my[:ext]}"
42
+ end
43
+ end
data/server/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require_relative './app'
2
+
3
+ run App.new '../static/dist'
data/server/link.rb ADDED
@@ -0,0 +1,14 @@
1
+ class Link
2
+ def initialize string
3
+ @string = string
4
+ end
5
+
6
+ def valid?
7
+ ['http://', 'https://'].any? { |prefix| @string.start_with? prefix } &&
8
+ @string.include?(?.)
9
+ end
10
+
11
+ def to_json _state = nil # JSON::Ext::Generator::State
12
+ @string.to_json
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ <!DOCTYPE html><head><title>CRM | Lead Gathering Machine</title><meta charset="utf-8"></head><body><div id="main"></div><script type="text/javascript" src="main.js?cb363ee1309d44ca25a9"></script></body>