dashing_api 0.0.1 → 0.0.2

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.
data/README.md CHANGED
@@ -106,3 +106,7 @@ curl -i -H 'Accept: application/json' -X PUT -d '{"auth_token": "$DASHING_AUTH_T
106
106
  3. Commit your changes (`git commit -am 'Add some feature'`)
107
107
  4. Push to the branch (`git push origin my-new-feature`)
108
108
  5. Create new Pull Request
109
+
110
+ ## License
111
+
112
+ [MIT License](https://github.com/Financial-Times/dashing_api/blob/master/LICENSE.txt)
@@ -50,7 +50,7 @@ get '/dashboards/' do
50
50
  dashArray = dashboard.split("/")
51
51
  dashboard = dashArray[dashArray.length-1]
52
52
  if dashboard.include? ".erb"
53
- dashboards.push dashboard
53
+ dashboards.push dashboard.chomp(".erb")
54
54
  end
55
55
  end
56
56
 
@@ -77,8 +77,12 @@ put '/dashboards/' do
77
77
 
78
78
  if functions.checkAuthToken(body, settings.auth_token)
79
79
  if functions.dashboardExists(from, settings.root)
80
- File.rename(settings.root+'/dashboards/'+from+'.erb', settings.root+'/dashboards/'+to+'.erb')
81
- { :message => 'Dashboard Renamed from ' + from +' to ' + to }.to_json
80
+ if from != settings.default_dashboard
81
+ File.rename(settings.root+'/dashboards/'+from+'.erb', settings.root+'/dashboards/'+to+'.erb')
82
+ { :message => 'Dashboard Renamed from ' + from +' to ' + to }.to_json
83
+ else
84
+ { :message => 'Cannot rename the default dashboard ' + from }.to_json
85
+ end
82
86
  else
83
87
  @message = "Dashboard " + from + " does not exist"
84
88
  404
@@ -96,17 +100,17 @@ delete '/dashboards/:dashboard' do
96
100
  dashboard = params[:dashboard]
97
101
 
98
102
  if functions.checkAuthToken(body, settings.auth_token)
99
- if dashboard != settings.default_dashboard
100
- if functions.dashboardExists(dashboard, settings.root)
103
+ if functions.dashboardExists(dashboard, settings.root)
104
+ if dashboard != settings.default_dashboard
101
105
  File.delete(settings.root+'/dashboards/'+dashboard+'.erb')
102
106
  { :dashboard => dashboard, :message => 'Dashboard ' +dashboard+ ' deleted' }.to_json
103
107
  status 202
104
108
  else
105
- @message = "Dashboard " + dashboard + " does not exist"
109
+ @message = "Cannot delete the default dashboard"
106
110
  404
107
111
  end
108
112
  else
109
- @message = "Cannot delete the default dashboard"
113
+ @message = "Dashboard " + dashboard + " does not exist"
110
114
  403
111
115
  end
112
116
  else
@@ -1,3 +1,3 @@
1
1
  module DashingApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashing_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-11 00:00:00.000000000 Z
12
+ date: 2016-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ping