kebab_remote_api 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27202b7d0dc73cacd11aa45a00bddb5a6ea05d28
4
- data.tar.gz: 51a7d3515409dc30f5c14af4e2d16f088db6834b
3
+ metadata.gz: 1ec600e6c5d221f52cfb5af4504baf7fd7945bfc
4
+ data.tar.gz: ed7ed9773b78c7a1e5e5441dca3afbac85ea1a44
5
5
  SHA512:
6
- metadata.gz: f5f52e722492fda58e2a1482113c4ed84006426b74513a4ddc9e50b84c05e4de30503ddf60f1f23f70be7b556397d73296ebeb9417397310a4dd416bed7a1ef6
7
- data.tar.gz: d5b782cb5c2c32ecadcf961e90bf94c89af9915b7e04e815426f03ce781d5ed16523aac7d790cf776db2050690bf5c458b4d0073d7f250f63734a9eb4422b6a7
6
+ metadata.gz: e9f9838ae9c1de6350ae9d68f8d3b172d9f183ca73223777b1a1ba0a26b2614bacc85d919b0d24cc2b40e6dbd04ccde71aadc5956c3fd3162b4b58ab2e22cfbc
7
+ data.tar.gz: fac299c37753cba07c808cb64aca4f7b7499392f25071bb05479630c8d46443294ed52bbef9904b5666bd8440f74ff6f3cb1134dec92c597cf53fb0790f49b1e
@@ -1,5 +1,10 @@
1
1
 
2
2
  #### [Current]
3
+ * [deaa841](../../commit/deaa841) - __(Ahmet Sezgin Duran)__ Reduce complexity of server info init method
4
+ * [569cccd](../../commit/569cccd) - __(Ahmet Sezgin Duran)__ Fix tab-spaces
5
+
6
+ #### 1.0.0
7
+ * [b7935db](../../commit/b7935db) - __(Ahmet Sezgin Duran)__ [#8](../../issues/8) Get ready for gem publish
3
8
  * [18facb0](../../commit/18facb0) - __(Ahmet Sezgin Duran)__ Clean up application controller
4
9
  * [8316731](../../commit/8316731) - __(Ahmet Sezgin Duran)__ Remove unnecessary gems
5
10
  * [4d7db82](../../commit/4d7db82) - __(Ahmet Sezgin Duran)__ Fix CybeleInstallation tutorial
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kebab_remote_api (0.2.1)
4
+ kebab_remote_api (1.0.0)
5
5
  enumerize (~> 0.7.0)
6
- pg (~> 0.16.0)
7
6
  rails (~> 4.0.0)
8
- vmstat (~> 2.0.0)
7
+ vmstat (~> 2.1.0)
9
8
 
10
9
  GEM
11
10
  remote: https://rubygems.org/
@@ -45,10 +44,9 @@ GEM
45
44
  mail (2.5.4)
46
45
  mime-types (~> 1.16)
47
46
  treetop (~> 1.4.8)
48
- mime-types (1.25)
47
+ mime-types (1.25.1)
49
48
  minitest (4.7.5)
50
49
  multi_json (1.8.2)
51
- pg (0.16.0)
52
50
  polyglot (0.3.3)
53
51
  rack (1.5.2)
54
52
  rack-test (0.6.2)
@@ -67,7 +65,7 @@ GEM
67
65
  rake (>= 0.8.7)
68
66
  thor (>= 0.18.1, < 2.0)
69
67
  rake (10.1.0)
70
- sprockets (2.10.0)
68
+ sprockets (2.10.1)
71
69
  hike (~> 1.2)
72
70
  multi_json (~> 1.0)
73
71
  rack (~> 1.0)
@@ -85,7 +83,7 @@ GEM
85
83
  polyglot
86
84
  polyglot (>= 0.3.1)
87
85
  tzinfo (0.3.38)
88
- vmstat (2.0.0)
86
+ vmstat (2.1.0)
89
87
 
90
88
  PLATFORMS
91
89
  ruby
@@ -1,8 +1,8 @@
1
1
  module KebabRemoteApi
2
- class Api::V1::ServerInfoController < KebabRemoteApi::ApplicationController
3
- def get_server_info
4
- @info = ServerInfo.new
5
- render status: 200, json: @info.as_json
6
- end
7
- end
2
+ class Api::V1::ServerInfoController < KebabRemoteApi::ApplicationController
3
+ def get_server_info
4
+ @info = ServerInfo.new
5
+ render status: 200, json: @info.as_json
6
+ end
7
+ end
8
8
  end
@@ -1,52 +1,52 @@
1
1
  module KebabRemoteApi
2
2
 
3
- class Api::V1::SessionsController < KebabRemoteApi::ApplicationController
4
- skip_before_filter :verify_authenticity_token, :authenticate_request, :restrict_access
5
- respond_to :json
6
-
7
- def create
8
- email = params[:email]
9
- password = params[:password]
10
-
11
- # Checking whether format is json or not
12
- if request.format != :json
13
- render status: 406, json: { message: I18n.t('kebab_remote_api.not_json') }
14
- return
15
- end
16
-
17
- # Checking for empty email or password
18
- if email.nil? or password.nil?
19
- render status: 400, json: { message: I18n.t('kebab_remote_api.empty_input') }
20
- return
21
- end
22
-
23
- @admin = Admin.where(email: email.downcase).first
24
-
25
- # Checking whether user exists
26
- if @admin.nil?
27
- render status: 401, json: { message: I18n.t('kebab_remote_api.invalid_field') }
28
- return
29
- end
30
-
31
- @admin.ensure_authentication_token!
32
-
33
- # Finally, checking for password
34
- unless @admin.valid_password?(password)
35
- render status: 401, json: { message: I18n.t('kebab_remote_api.invalid_field') }
36
- else
37
- render status: 200, json: @admin.as_json.merge(success: true)
38
- end
39
- end
40
-
41
- def destroy
42
- @admin = Admin.find_by_authentication_token(params[:id])
43
-
44
- if @admin.nil?
45
- render status: 404, json: { message: I18n.t('kebab_remote_api.invalid_token') }
46
- else
47
- @admin.reset_authentication_token!
48
- render status: 200, json: { token: params[:id] }
49
- end
50
- end
51
- end
3
+ class Api::V1::SessionsController < KebabRemoteApi::ApplicationController
4
+ skip_before_filter :verify_authenticity_token, :authenticate_request, :restrict_access
5
+ respond_to :json
6
+
7
+ def create
8
+ email = params[:email]
9
+ password = params[:password]
10
+
11
+ # Checking whether format is json or not
12
+ if request.format != :json
13
+ render status: 406, json: { message: I18n.t('kebab_remote_api.not_json') }
14
+ return
15
+ end
16
+
17
+ # Checking for empty email or password
18
+ if email.nil? or password.nil?
19
+ render status: 400, json: { message: I18n.t('kebab_remote_api.empty_input') }
20
+ return
21
+ end
22
+
23
+ @admin = Admin.where(email: email.downcase).first
24
+
25
+ # Checking whether user exists
26
+ if @admin.nil?
27
+ render status: 401, json: { message: I18n.t('kebab_remote_api.invalid_field') }
28
+ return
29
+ end
30
+
31
+ @admin.ensure_authentication_token!
32
+
33
+ # Finally, checking for password
34
+ unless @admin.valid_password?(password)
35
+ render status: 401, json: { message: I18n.t('kebab_remote_api.invalid_field') }
36
+ else
37
+ render status: 200, json: @admin.as_json.merge(success: true)
38
+ end
39
+ end
40
+
41
+ def destroy
42
+ @admin = Admin.find_by_authentication_token(params[:id])
43
+
44
+ if @admin.nil?
45
+ render status: 404, json: { message: I18n.t('kebab_remote_api.invalid_token') }
46
+ else
47
+ @admin.reset_authentication_token!
48
+ render status: 200, json: { token: params[:id] }
49
+ end
50
+ end
51
+ end
52
52
  end
@@ -1,14 +1,14 @@
1
1
  module KebabRemoteApi
2
- class Api::V1::UsersController < KebabRemoteApi::ApplicationController
3
- respond_to :json
2
+ class Api::V1::UsersController < KebabRemoteApi::ApplicationController
3
+ respond_to :json
4
4
 
5
- def index
6
- render status: 200, json: {
7
- 'active_user' => User.with_block_status(:active).count,
8
- 'total_user' => User.all.count,
9
- 'total_user_by_role' => User.role.values.map { |role| { "role_name" => role.to_s,
5
+ def index
6
+ render status: 200, json: {
7
+ 'active_user' => User.with_block_status(:active).count,
8
+ 'total_user' => User.all.count,
9
+ 'total_user_by_role' => User.role.values.map { |role| { "role_name" => role.to_s,
10
10
  "count" => User.with_role(role).count } }
11
- }.to_json
12
- end
13
- end
11
+ }.to_json
12
+ end
13
+ end
14
14
  end
@@ -1,22 +1,22 @@
1
1
  module KebabRemoteApi
2
- class ApplicationController < ActionController::Base
3
- before_filter :authenticate_request, :restrict_access
2
+ class ApplicationController < ActionController::Base
3
+ before_filter :authenticate_request, :restrict_access
4
4
 
5
- respond_to :json
5
+ respond_to :json
6
6
 
7
- # Prevent CSRF attacks by raising an exception.
8
- # For APIs, you may want to use :null_session instead.
9
- protect_from_forgery with: :exception
7
+ # Prevent CSRF attacks by raising an exception.
8
+ # For APIs, you may want to use :null_session instead.
9
+ protect_from_forgery with: :exception
10
10
 
11
- protected
12
- def authenticate_request
13
- admin = Admin.find_by_authentication_token(params[:secret_token])
14
- head :unauthorized unless admin
15
- end
11
+ protected
12
+ def authenticate_request
13
+ admin = Admin.find_by_authentication_token(params[:secret_token])
14
+ head :unauthorized unless admin
15
+ end
16
16
 
17
- def restrict_access
18
- api_key = ApiKey.first
19
- head :unauthorized unless api_key
20
- end
21
- end
17
+ def restrict_access
18
+ api_key = ApiKey.first
19
+ head :unauthorized unless api_key
20
+ end
21
+ end
22
22
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency "rails", "~> 4.0.0"
23
23
  s.add_dependency 'enumerize', '~> 0.7.0'
24
- s.add_dependency 'vmstat', '~> 2.0.0'
24
+ s.add_dependency 'vmstat', '~> 2.1.0'
25
25
 
26
26
  s.add_development_dependency "sqlite3"
27
27
  end
@@ -2,10 +2,10 @@ class Admin < ActiveRecord::Base
2
2
  # Include default devise modules. Others available are:
3
3
  # :token_authenticatable, :confirmable,
4
4
  # :lockable, :timeoutable and :omniauthable
5
- devise :database_authenticatable,
5
+ devise :database_authenticatable,
6
6
  :recoverable, :rememberable, :trackable, :validatable,
7
7
  :token_authenticatable
8
-
8
+
9
9
  def as_json
10
10
  { id: id,
11
11
  auth_token: authentication_token,
@@ -6,7 +6,6 @@ class ServerInfo < ActiveRecord::Base
6
6
 
7
7
  def init
8
8
  mem = Vmstat.memory
9
- total_mem = mem.active_bytes + mem.inactive_bytes + mem.free_bytes + mem.wired_bytes
10
9
  # Getting disk info for main partition is, temprorarily, for only
11
10
  # UN*X-like systems, such as GNU/Linux, BSD, Mac OS X etc.
12
11
  # Windows implementation will be added in future
@@ -14,8 +13,8 @@ class ServerInfo < ActiveRecord::Base
14
13
  # CPU load data => Float typed
15
14
  self.cpu_load = Vmstat.load_average.five_minutes
16
15
  # All size data => Megabytes (MB)
17
- self.mem_total = (mem.active_bytes + mem.inactive_bytes + mem.free_bytes + mem.wired_bytes) / 1024**2
18
- self.mem_used = self.mem_total - (mem.free_bytes / 1024**2)
16
+ self.mem_total = mem.total_bytes / 1024**2
17
+ self.mem_used = (mem.total_bytes - mem.free_bytes) / 1024**2
19
18
  self.disk_total = disk.total_bytes / 1024**2
20
19
  self.disk_used = (disk.total_bytes - disk.free_bytes) / 1024**2
21
20
  # Uptime data => Minutes
@@ -1,3 +1,3 @@
1
1
  module KebabRemoteApi
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kebab_remote_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lab2023
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2013-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: 2.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
54
+ version: 2.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement