lgm 0.0.7 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8db6a41190826509f61907621b214a437092ff7e
4
- data.tar.gz: e5f0ac6fc71d734ca743a95687fb775a332ab241
3
+ metadata.gz: 71fd71b6ec54a4033374cdbbee1d16e8802abcfa
4
+ data.tar.gz: 7f7429d9591ecfb695777d61b1635788d3d4df2e
5
5
  SHA512:
6
- metadata.gz: ca1d2a80f934d6b3f30219e015cbf3d03076162302e71203fe0be4bbde2c4888b44b8692af3303e30fe2a20ed71f0eccc4e9daad61f723a5fe0bf201772ced34
7
- data.tar.gz: 39e14ed2ebc09a20064a09970e1795f62f1784a6fdab1303d0eb51e19ddeefe83421fed30f65efea043229ce9894f0f752f9abdd5556a4326dc39ed32c4b913d
6
+ metadata.gz: d48c2db945fc5010dff99bddae7d2cd0bf1b9533a1376e65abb177d3f81f9cc5e1e563556158118f6f7a3e54cedd55f154146ebeb7c64ef3081901526105629b
7
+ data.tar.gz: f582373a833a73af885d1a1d0422834b78a9b32b71e23b3c3e9d2a2ebe4e5f5511af1c06eb954b4bbdd0a4a1c74ea390f1f76dfaf65e033bc2c4370411c817c2
data/bin/lgm CHANGED
@@ -1,5 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require_relative '../server/constants'
4
+ require 'fileutils'
5
+ FileUtils.mkdir_p LGM_DIR
6
+
7
+ Thread.new do
8
+ `redis-server --unixsocket #{LGM_DIR}/redis.sock --port 0 --dir #{LGM_DIR} --appendonly yes`
9
+ end
10
+ at_exit { R.shutdown }
11
+
12
+
3
13
  require 'puma'
4
14
  require_relative '../server/app'
5
15
 
data/server/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'hobby'
4
4
  gem 'hobby-json'
5
+ gem 'redis'
data/server/Gemfile.lock CHANGED
@@ -6,6 +6,7 @@ GEM
6
6
  hobby-json (0.0.4)
7
7
  rack
8
8
  rack (2.0.3)
9
+ redis (4.0.1)
9
10
 
10
11
  PLATFORMS
11
12
  ruby
@@ -13,6 +14,7 @@ PLATFORMS
13
14
  DEPENDENCIES
14
15
  hobby
15
16
  hobby-json
17
+ redis
16
18
 
17
19
  BUNDLED WITH
18
20
  1.16.1
data/server/app.rb CHANGED
@@ -2,7 +2,7 @@ require 'hobby'
2
2
  require 'hobby/json'
3
3
 
4
4
  require_relative 'link'
5
- LINKS = [Link.new('/main.js'), Link.new('/another.html')]
5
+ require_relative 'links'
6
6
 
7
7
  class API
8
8
  include Hobby
@@ -15,13 +15,17 @@ class API
15
15
  post '/links' do
16
16
  link = Link.new json['link']
17
17
 
18
- if link.valid?
19
- LINKS << link
18
+ if link.valid? && ( not LINKS.include? link )
19
+ LINKS.add link
20
20
  link
21
21
  else
22
22
  response.status = 422
23
23
  end
24
24
  end
25
+
26
+ get '/links/amount' do
27
+ LINKS.amount
28
+ end
25
29
  end
26
30
 
27
31
  class App
@@ -0,0 +1 @@
1
+ LGM_DIR = "#{ENV['HOME']}/.lgm"
data/server/link.rb CHANGED
@@ -11,4 +11,8 @@ class Link
11
11
  def to_json _state = nil # JSON::Ext::Generator::State
12
12
  @string.to_json
13
13
  end
14
+
15
+ def to_s
16
+ @string
17
+ end
14
18
  end
data/server/links.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'redis'
2
+ require_relative 'constants'
3
+ R = Redis.new path: "#{LGM_DIR}/redis.sock"
4
+
5
+ module LINKS
6
+ extend self
7
+
8
+ def add link
9
+ R.lpush 'links_list', link
10
+ R.sadd 'links_set', link
11
+ end
12
+
13
+ def to_json
14
+ to_a.to_json
15
+ end
16
+
17
+ def to_a
18
+ R.lrange 'links_list', 0, -1
19
+ end
20
+
21
+ def include? link
22
+ R.sismember 'links_set', link
23
+ end
24
+
25
+ def amount
26
+ R.scard 'links_set'
27
+ end
28
+ end
@@ -1 +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>
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?edd53b2871bc06b206bd"></script></body>
data/static/dist/main.js CHANGED
@@ -702,7 +702,8 @@ module.exports = {
702
702
  data: function() {
703
703
  return {
704
704
  link: "",
705
- links: []
705
+ links: [],
706
+ total_amount_of_links: 0
706
707
  };
707
708
  },
708
709
  methods: {
@@ -713,14 +714,21 @@ module.exports = {
713
714
  }));
714
715
  if (response.status === 200) {
715
716
  this.links.unshift(response.data);
717
+ this.get_total_amount_of_links();
716
718
  return this.link = "";
717
719
  } else {
718
720
  return console.log(`Invalid link: ${this.link}`);
719
721
  }
722
+ },
723
+ get_total_amount_of_links: async function() {
724
+ var response;
725
+ response = (await axios.get('/api/links/amount'));
726
+ return this.total_amount_of_links = response.data;
720
727
  }
721
728
  },
722
729
  created: async function() {
723
730
  var response;
731
+ this.get_total_amount_of_links();
724
732
  response = (await axios.get('/api/links'));
725
733
  return this.links = response.data;
726
734
  }
@@ -10892,7 +10900,9 @@ var render = function() {
10892
10900
  }
10893
10901
  }),
10894
10902
  _c("p", [
10895
- _vm._v("Total amount of links: " + _vm._s(_vm.links.length) + ".")
10903
+ _vm._v(
10904
+ "Total amount of links: " + _vm._s(_vm.total_amount_of_links) + "."
10905
+ )
10896
10906
  ]),
10897
10907
  _c(
10898
10908
  "ol",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lgm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernow
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: puma
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +64,9 @@ files:
50
64
  - server/Gemfile.lock
51
65
  - server/app.rb
52
66
  - server/config.ru
67
+ - server/constants.rb
53
68
  - server/link.rb
69
+ - server/links.rb
54
70
  - static/dist/index.html
55
71
  - static/dist/main.js
56
72
  homepage: