chris_lib 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2e4cc4937a74e64331de5b7eae42fde969af752
4
- data.tar.gz: c556265b8abf00727717506cc4588b05f0541813
3
+ metadata.gz: c0129b3936265ef5a35b448d35f66899fc9a8da7
4
+ data.tar.gz: f7ac18d82152598669f0bd7dc49659adc9fd0042
5
5
  SHA512:
6
- metadata.gz: 271b426509b3a6009868cf5515055cd0c24a862219723c16ed27b034102eda49949903592b99ad1ab3b8452eb7d22617c94e961b780189df1d84ab804696ea8f
7
- data.tar.gz: d2cd1d750488604c25e353b26f5462e83a3b5e9e735545f4523a56164a55fd0d7adbd49b7932852c4a6fb815888867aa91a5ba9a9b62479c60d46a916ed5b180
6
+ metadata.gz: c82f2367424ff15ba9159c11ba337d3c017d2e83f5f6295b3c01d2d67bf3c028c2c7fdc309b3249d87bd4efebb18035c47ef437d40e1ca1daa7aba8ebd75bddf
7
+ data.tar.gz: f0b09caa71a654f2c7403a8fc4661b0bb2df1f7bb0e5c7531d91e1c4741e3989b0a0342f58cfd467b07c15b88977878926f5772b43ace378aaaa52a708e00275
@@ -1,31 +1,42 @@
1
- Date.class_eval do
2
- def us_format
3
- "#{strftime('%B')} #{day.to_s}, #{year.to_s}"
4
- end
5
- def us_format_with_weekday
6
- "#{strftime('%A')}, #{strftime('%B')} #{day.to_s}, #{year.to_s}"
7
- end
8
- def charmians_format
9
- d=cardinalation(day)
10
- "#{strftime('%A')}, #{d} #{strftime('%B')}, #{year.to_s}"
11
- end
12
- def charmians_format_sup
13
- d=cardinalation(day,true)
14
- "#{strftime('%A')}, #{d} #{strftime('%B')}, #{year.to_s}"
15
- end
16
- def cardinalation(day,html_sup=false)
17
- s=case day
18
- when 1,21,31
19
- 'st'
20
- when 2,22
21
- 'nd'
22
- when 3,23
23
- 'rd'
24
- else
25
- 'th'
26
- end
27
- s="<sup>#{s}</sup>" if html_sup
28
- "#{day}#{s}"
1
+ module DateExt
2
+ # To format a date, use <tt>date.charmians_format</tt>
3
+ # on any Date object.
4
+ #
5
+ # class Date
6
+ # charmians_format
7
+ # end
8
+ #
9
+ # If using a DateTime object, need to convert to date i.e. <tt>datetime.to_date.charmians_format</tt>.
10
+ Date.class_eval do
11
+ def us_format
12
+ "#{strftime('%B')} #{day.to_s}, #{year.to_s}"
13
+ end
14
+ def us_format_with_weekday
15
+ "#{strftime('%A')}, #{strftime('%B')} #{day.to_s}, #{year.to_s}"
16
+ end
17
+ def charmians_format
18
+ d=cardinalation(day)
19
+ "#{strftime('%A')}, #{d} #{strftime('%B')}, #{year.to_s}"
20
+ end
21
+ def charmians_format_sup
22
+ d=cardinalation(day,true)
23
+ "#{strftime('%A')}, #{d} #{strftime('%B')}, #{year.to_s}"
24
+ end
25
+ private
26
+ def cardinalation(day,html_sup=false)
27
+ s=case day
28
+ when 1,21,31
29
+ 'st'
30
+ when 2,22
31
+ 'nd'
32
+ when 3,23
33
+ 'rd'
34
+ else
35
+ 'th'
36
+ end
37
+ s="<sup>#{s}</sup>" if html_sup
38
+ "#{day}#{s}"
39
+ end
29
40
  end
30
41
  end
31
42
 
@@ -0,0 +1,53 @@
1
+ module ShellMethods
2
+ def time_hash
3
+ time=Time.now
4
+ time.day.to_s + time.month.to_s + time.year.to_s + '-' + time.hour.to_s + time.min.to_s
5
+ end
6
+ def same_db_version(remote: nil)
7
+ destination=(remote.nil? ? nil : "--remote #{remote}")
8
+ lv=`rake db:version`;lr=$?.success?
9
+ puts "Local version: ",lv
10
+ hv=`heroku run rake db:version #{destination}`;hr=$?.success?
11
+ puts hv
12
+ key='version: '
13
+ nl=lv.index(key)+9
14
+ l_version=lv.slice(nl..-1)
15
+ nh=hv.index(key)+9
16
+ h_version=hv.slice(nh..-1)
17
+ l_version==h_version
18
+ end
19
+ def check_git_clean
20
+ puts "Checking git status"
21
+ gs=`git status`; lr=$?.success?
22
+ if gs['working directory clean'].nil?
23
+ puts "Exiting, you need to commit files"
24
+ exit 1
25
+ end
26
+ end
27
+ def check_chris_lib_status
28
+ gs=`cd ../chris_lib;git status`; lr=$?.success?
29
+ puts "Checking chris_lib_status"
30
+ if gs['working directory clean'].nil? || gs['up-to-date'].nil?
31
+ puts "Exiting, chris_lib is not up to date with master."
32
+ exit 3
33
+ end
34
+ system('cd $OLDPWD')
35
+ end
36
+ def migrate_if_necessary(remote: nil,migrate: nil)
37
+ if migrate == '--no_migrate'
38
+ puts "No migration will be performed due to --no_migrate option"
39
+ else
40
+ destination=(remote.nil? ? nil : "--remote #{remote}")
41
+ puts "Checking local and remote databases have same version and migrates if necessary"
42
+ if same_db_version(remote: remote)
43
+ puts "No migration necessary"
44
+ else
45
+ puts "Warning, different db versions"
46
+ puts "Press m<cr> to migrate or q<cr> to exit"
47
+ ans=$stdin.gets()
48
+ exit 2 if ans[0]!='m'
49
+ system("heroku run rake db:migrate #{destination}")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,4 +1,10 @@
1
1
  module TestAccess
2
+ # A rspec macro to test access security for controllers, call <tt>it_should_route_to(path,actions)</tt>
3
+ # where path is a string of the form <tt>url_path</tt> and actions is a hash of symbols
4
+ # that represent actions to be protected.
5
+ # An example call is <tt>it_should_route_to('login_path',:edit,:update)</tt>. The call is
6
+ # made in a describe or context block with a preceding <tt>require TestAccess</tt>.
7
+ #
2
8
  module ExampleMethods
3
9
  end
4
10
  module ExampleGroupMethods
@@ -1,3 +1,3 @@
1
1
  module ChrisLib
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/chris_lib.rb CHANGED
@@ -2,5 +2,6 @@ require "chris_lib/version"
2
2
  require "chris_lib/date_ext"
3
3
  require "chris_lib/test_access"
4
4
  require "chris_lib/chris_math"
5
+ require "chris_lib/shell_methods"
5
6
  module ChrisLib
6
7
  end
metadata CHANGED
@@ -1,51 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chris_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-12 00:00:00.000000000 Z
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 4.1.5
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 4.1.5
27
- - !ruby/object:Gem::Dependency
28
- name: sqlite3
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec-rails
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
46
18
  - !ruby/object:Gem::Version
47
19
  version: '0'
48
- type: :development
20
+ type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
@@ -53,7 +25,7 @@ dependencies:
53
25
  - !ruby/object:Gem::Version
54
26
  version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
- name: pry
28
+ name: sqlite3
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -67,7 +39,7 @@ dependencies:
67
39
  - !ruby/object:Gem::Version
68
40
  version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
- name: pry-rails
42
+ name: rspec-rails
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - ">="
@@ -92,6 +64,7 @@ files:
92
64
  - lib/chris_lib.rb
93
65
  - lib/chris_lib/chris_math.rb
94
66
  - lib/chris_lib/date_ext.rb
67
+ - lib/chris_lib/shell_methods.rb
95
68
  - lib/chris_lib/test_access.rb
96
69
  - lib/chris_lib/version.rb
97
70
  - lib/tasks/chris_lib_tasks.rake