pyk 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,159 @@
1
+ module Pyk::Helpers
2
+
3
+ #--------------------------------------------------------------------------------------------------------------
4
+ # GENERIC
5
+ #--------------------------------------------------------------------------------------------------------------
6
+
7
+ def title(page_title)
8
+ content_for(:title) { page_title }
9
+ end
10
+
11
+ def dp(email, size=20)
12
+ Pyk::Gravatar.dp(email, size)
13
+ end
14
+
15
+ def icon_d
16
+ "<span class='glyphicon glyphicon-trash'></span>".html_safe
17
+ end
18
+
19
+ def r
20
+ "<i class='icon-repeat'></i>".html_safe
21
+ end
22
+
23
+ #--------------------------------------------------------------------------------------------------------------
24
+ # NUMBERS
25
+ #--------------------------------------------------------------------------------------------------------------
26
+
27
+ def two_decimal_points(ff)
28
+ sprintf("%0.02f", ff)
29
+ end
30
+
31
+ def remove_decimal(str)
32
+ str = str.to_s
33
+ if str.index(".").present?
34
+ str = str[0..(str.index(".") - 1)]
35
+ end
36
+ str
37
+ end
38
+
39
+ def n2h(d)
40
+ begin
41
+ return number_to_human(d, significant: false, precision: 1)
42
+ rescue
43
+ return d
44
+ end
45
+ end
46
+
47
+ def stock_market(d)
48
+ if d < 0
49
+ return "<span style='color: red;'><i class='icon-arrow-down'></i></span> #{d}%".html_safe
50
+ elsif d > 0
51
+ return "<span style='color: green;'><i class='icon-arrow-up'></i></span> #{d}%".html_safe
52
+ else
53
+ return d
54
+ end
55
+ end
56
+
57
+ def color_amount(d)
58
+ if d < 0
59
+ "<span class='red'>(#{number_to_currency(d, unit: '')})</span>".html_safe
60
+ else
61
+ number_to_currency(d, unit: '')
62
+ end
63
+ end
64
+
65
+ #--------------------------------------------------------------------------------------------------------------
66
+ # DATE
67
+ #--------------------------------------------------------------------------------------------------------------
68
+
69
+ def smart_date(i, mode="date")
70
+ if i.blank?
71
+ return ""
72
+ elsif (i.class.to_s == "Time" or i.class.to_s == "ActiveSupport::TimeWithZone") and mode == "time"
73
+ return i.year == Time.now.year ? i.strftime("%d-%b %H:%M") : i.strftime("%d-%b-%Y %H:%M")
74
+ else
75
+ return i.year == Time.now.year ? i.strftime("%d-%b") : i.strftime("%d-%b-%Y")
76
+ end
77
+ end
78
+
79
+ def smart_due_date(i)
80
+ if i == nil
81
+ return ""
82
+ elsif i.class.to_s == "Time" or i.class.to_s == "ActiveSupport::TimeWithZone"
83
+ i = i.to_date
84
+ end
85
+ if Date.today == i
86
+ return "<span style=\"background-color:#F7FAB9;padding:0px 2px 0px 2px;\">Today</span>"
87
+ elsif i - Date.today == 1
88
+ return "<span style=\"background-color:#F7FAB9;padding:0px 2px 0px 2px;\">Tomorrow</span>"
89
+ elsif Date.today - i > 0.9
90
+ return "<span style=\"background-color:#FFC7C7;padding:0px 2px 0px 2px;\">" + smart_date(i) + "</span>"
91
+ elsif Date.today - i < 1
92
+ return "<span style=\"background-color:#D2FFCC;padding:0px 2px 0px 2px;\">" + smart_date(i) + "</span>"
93
+ end
94
+ return smart_date(i, "date")
95
+ end
96
+
97
+ #--------------------------------------------------------------------------------------------------------------
98
+ # ADDRESS
99
+ #--------------------------------------------------------------------------------------------------------------
100
+
101
+ def location_summary(u)
102
+ return Pyk::Address.to_s(u)
103
+ end
104
+
105
+ def location_summary_short(u)
106
+ return Pyk::Address.gist(u)
107
+ end
108
+
109
+ def location_map(u)
110
+ return Pyk::Address.map(u, 300, 95)
111
+ end
112
+
113
+ #--------------------------------------------------------------------------------------------------------------
114
+ # DEVISE
115
+ #--------------------------------------------------------------------------------------------------------------
116
+
117
+ def resource_name
118
+ :user
119
+ end
120
+
121
+ def resource
122
+ @resource ||= User.new
123
+ end
124
+
125
+ def devise_mapping
126
+ @devise_mapping ||= Devise.mappings[:user]
127
+ end
128
+
129
+ #DEVISE end
130
+
131
+ def devise_error_messages!
132
+ flash_alerts = []
133
+ error_key = 'errors.messages.not_saved'
134
+
135
+ if !flash.empty?
136
+ flash_alerts.push(flash[:error]) if flash[:error]
137
+ flash_alerts.push(flash[:alert]) if flash[:alert]
138
+ flash_alerts.push(flash[:notice]) if flash[:notice]
139
+ error_key = 'devise.failure.invalid'
140
+ end
141
+
142
+ return "" if resource.errors.empty? && flash_alerts.empty?
143
+ errors = resource.errors.empty? ? flash_alerts : resource.errors.full_messages
144
+
145
+ messages = errors.map { |msg| content_tag(:li, msg) }.join
146
+ sentence = I18n.t(error_key, :count => errors.count,
147
+ :resource => resource.class.model_name.human.downcase)
148
+
149
+ html = <<-HTML
150
+ <div id="error_explanation">
151
+ <h2>#{sentence}</h2>
152
+ <ul>#{messages}</ul>
153
+ </div>
154
+ HTML
155
+
156
+ html.html_safe
157
+ end
158
+
159
+ end
@@ -26,16 +26,43 @@ class Pyk::Highcharts
26
26
  end
27
27
 
28
28
  # Pyk::Highcharts.column(data, categories, render_to_name, background_color)
29
- def self.column(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false)
29
+ def self.column(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil, stacking="normal")
30
30
  LazyHighCharts::HighChart.new('column') do |f|
31
- f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"column"} )
31
+ f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"column", height: height} )
32
32
  data.each do |d|
33
- f.series(:name=>d[0],:data=> d[1], borderWidth: 0)
33
+ f.series(:name=>d[0],:data=> d[1], borderWidth: 0, color: d[2])
34
34
  end
35
35
  f.xAxis({categories: categories, gridLineWidth: 0, :labels=>{:align => 'center'}, type: :string})
36
36
  f.yAxis({gridLineWidth: 0, title: nil, :min => 0})
37
37
  f.title({ :text=> nil})
38
- f.plot_options({:column=>{:stacking=>"normal", dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}})
38
+ f.plot_options({:column=>{:stacking=>stacking, dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}})
39
+ end
40
+ end
41
+
42
+ # Pyk::Highcharts.column
43
+ def self.area(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil, stacking="normal")
44
+ LazyHighCharts::HighChart.new('area') do |f|
45
+ f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"area", height: height} )
46
+ data.each do |d|
47
+ f.series(:name=>d[0],:data=> d[1], borderWidth: 0, color: d[2])
48
+ end
49
+ f.xAxis({categories: categories, tickmarkPlacement: 'on', title: { enabled: false }, :labels=>{:align => 'center'}, type: :string})
50
+ f.yAxis({gridLineWidth: 0, title: nil, :min => 0})
51
+ f.title({ :text=> nil})
52
+ f.plot_options({:area=>{:stacking=>stacking, lineColor: '#666666', lineWidth: 1, dataLabels: {enabled: data_labels}, showInLegend: show_in_legend}})
53
+ end
54
+ end
55
+
56
+ def self.line(data, categories, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil)
57
+ LazyHighCharts::HighChart.new('graph') do |f|
58
+ f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"line", height: height} )
59
+ data.each do |d|
60
+ f.series(:name=>d[0],:data=> d[1], color: d[2])
61
+ end
62
+ f.xAxis({categories: categories, title: { enabled: false }, :labels=>{:align => 'center'}, type: :string})
63
+ f.yAxis({title: nil, plotLines: [{value: 0, width: 1, color: '#F7F7F7'}]})
64
+ f.title({ :text=> nil})
65
+ f.legend({ :enabled=> show_in_legend})
39
66
  end
40
67
  end
41
68
 
@@ -80,9 +107,9 @@ class Pyk::Highcharts
80
107
  end
81
108
 
82
109
  # Pyk::Highcharts.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color)
83
- def self.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color, show_in_legend=false, data_labels=false)
110
+ def self.stacked_bar_with_pie(data, categories, pie_data, render_to_name, background_color, show_in_legend=false, data_labels=false, height=nil)
84
111
  LazyHighCharts::HighChart.new('column') do |f|
85
- f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"column"} )
112
+ f.chart({ backgroundColor: background_color, renderTo: render_to_name, :defaultSeriesType=>"column", height: height} )
86
113
  if pie_data.first.present?
87
114
  pie_data.each do |pie|
88
115
  f.series(:type=> 'pie',:name=> nil, :data=> [{:name=> pie[0], :y=> pie[1], :color=> pie[2]}], :center=> [pie[3], 5], :size=> 20, :showInLegend=> false, enableMouseTracking: false)
data/lib/pyk/user.rb CHANGED
@@ -2,7 +2,7 @@ class Pyk::User
2
2
 
3
3
  #Pyk::User.is_admin?(current_user.email)
4
4
  def self.is_admin?(email)
5
- (email == "rp@pykih.com" or email == "gs@pykih.com") ? true : false
5
+ (email == "rp@pykih.com") ? true : false
6
6
  end
7
7
 
8
8
  end
metadata CHANGED
@@ -1,114 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pyk
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 9
9
- version: 0.0.9
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Pykih Software LLP
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2013-07-28 00:00:00 +05:30
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-07-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: nestful
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 0
30
- - 3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
31
19
  version: 1.0.3
32
20
  type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: nokogiri
36
21
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 5
44
- - 3
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
45
33
  version: 1.5.3
46
34
  type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: carmen
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- - 2
58
- - 13
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: carmen
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
59
47
  version: 0.2.13
60
48
  type: :development
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: roo
64
49
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 1
71
- - 10
72
- - 1
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.13
55
+ - !ruby/object:Gem::Dependency
56
+ name: roo
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
73
61
  version: 1.10.1
74
62
  type: :development
75
- version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: lazy_high_charts
78
63
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 1
85
- - 4
86
- - 3
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.10.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: lazy_high_charts
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
87
75
  version: 1.4.3
88
76
  type: :development
89
- version_requirements: *id005
90
- - !ruby/object:Gem::Dependency
91
- name: railties
92
77
  prerelease: false
93
- requirement: &id006 !ruby/object:Gem::Requirement
94
- requirements:
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.4.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: railties
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
95
87
  - - ~>
96
- - !ruby/object:Gem::Version
97
- segments:
98
- - 3
99
- - 1
100
- version: "3.1"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.1'
101
90
  type: :development
102
- version_requirements: *id006
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '3.1'
103
97
  description: Standard library of commonly reused functions across all Pykih Projects.
104
98
  email: rp@pykih.com
105
99
  executables: []
106
-
107
100
  extensions: []
108
-
109
101
  extra_rdoc_files: []
110
-
111
- files:
102
+ files:
112
103
  - app/assets/images/asc.gif
113
104
  - app/assets/images/desc.gif
114
105
  - app/assets/images/id_card-shadow.png
@@ -123,10 +114,13 @@ files:
123
114
  - app/assets/images/sprites/file-icons-16-px.png
124
115
  - app/assets/images/sprites/signup.png
125
116
  - app/assets/images/sprites/so.png
126
- - app/assets/stylesheets/pyk/bootstrap.css.scss
127
- - app/assets/stylesheets/pyk/global.css.scss
117
+ - app/assets/javascripts/pyk.js
118
+ - app/assets/javascripts/vendor/bootstrap.min.js
119
+ - app/assets/javascripts/vendor/jquery.sparkline.min.js
120
+ - app/assets/javascripts/vendor/pyk_master.js
121
+ - app/assets/stylesheets/pyk/bootstrap.min.css
128
122
  - app/assets/stylesheets/pyk/helpers.css.scss
129
- - app/assets/stylesheets/pyk/navbar.css.scss
123
+ - app/assets/stylesheets/pyk/pyk_master.css
130
124
  - app/assets/stylesheets/pyk/sprites.css.scss
131
125
  - app/assets/stylesheets/pyk/user_card.css.scss
132
126
  - app/assets/stylesheets/pyk.css.scss
@@ -136,51 +130,34 @@ files:
136
130
  - lib/pyk/date.rb
137
131
  - lib/pyk/date_time.rb
138
132
  - lib/pyk/dj.rb
139
- - lib/pyk/float.rb
140
133
  - lib/pyk/gravatar.rb
141
- - lib/pyk/number.rb
142
134
  - lib/pyk/regex.rb
143
135
  - lib/pyk/spreadsheet.rb
144
- - lib/pyk/string.rb
145
136
  - lib/pyk/url.rb
146
137
  - lib/pyk/user.rb
147
- - lib/pyk/address_helpers.rb
148
- - lib/pyk/app_helpers.rb
149
- - lib/pyk/date_helpers.rb
150
- - lib/pyk/devise_helpers.rb
151
- - lib/pyk/number_helpers.rb
138
+ - lib/pyk/helpers.rb
152
139
  - lib/pyk/highcharts.rb
153
- has_rdoc: true
154
140
  homepage: https://github.com/pykih/pyk
155
141
  licenses: []
156
-
142
+ metadata: {}
157
143
  post_install_message:
158
144
  rdoc_options: []
159
-
160
- require_paths:
145
+ require_paths:
161
146
  - lib
162
- required_ruby_version: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- segments:
167
- - 0
168
- version: "0"
169
- required_rubygems_version: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- segments:
174
- - 1
175
- - 3
176
- - 6
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
177
156
  version: 1.3.6
178
157
  requirements: []
179
-
180
158
  rubyforge_project:
181
- rubygems_version: 1.3.6
159
+ rubygems_version: 2.0.6
182
160
  signing_key:
183
- specification_version: 3
161
+ specification_version: 4
184
162
  summary: Standard library of commonly reused functions across all Pykih Projects.
185
163
  test_files: []
186
-