effective_developer 0.0.5 → 0.0.6

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: 37009e501c345970f6f61ba7da9de4434ed0aa80
4
- data.tar.gz: 16d0fdc7164a019cd888b0777d25a9888e5d0b34
3
+ metadata.gz: 321b83d7d7cf7a803e2516db52bb1610b32dd8a0
4
+ data.tar.gz: 9f64632100cb5199d5b76bb4a6a57f8764ce64a3
5
5
  SHA512:
6
- metadata.gz: 6d5d37ee66983776213ddc80550ef3090274e955c28a3ed75b77237f4d7b90e90368b12b86f602edad51925236dcb9873662a6f5e2f6a75c213c0f187397c75b
7
- data.tar.gz: 6a72d5938336c130800ef95dcb140c40dcf64d38ae0dab52197ba2e57ff1bd8ebd618328ef80be505d4926e28aa0f5f47a080f49ce5e0cd067e48d92c73c9f6c
6
+ metadata.gz: 1d8b4e802b1e9b8c8bbc7bc78dc9aa12cf8518a9d1a35a859a86289a1417852c1f14f95cec6ce609a57b544e2838b34e2b31f4c3329052ac396aa642903bb3a3
7
+ data.tar.gz: 7e7d7fba5828905f6b0663817424ba74a3532e857f84b8752e11cd37c1fb96bd62e5d0d218ab63bccbd883fde23dfbbba8995107b1f38206ecde74be2c9670c0
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Effective Developer
2
2
 
3
- This is a small gem with some developer quality of life scripts.
3
+ This gem contains some developer quality of life scripts and rails helpers.
4
4
 
5
5
  ## Getting Started
6
6
 
7
- Add to your Gemfile:
7
+ To use the included rails helpers and rake tasks in your current rails project, add to the Gemfile:
8
8
 
9
9
  ```ruby
10
10
  group :development
@@ -18,12 +18,20 @@ Run the bundle command to install it:
18
18
  bundle install
19
19
  ```
20
20
 
21
- To use with any gem, add the following folder to your `PATH` (edit your ~/.bashrc or ~/.profile):
21
+ To use the included command line scripts in any directory, clone this repo:
22
+
23
+ ```console
24
+ git clone git@github.com:code-and-effect/effective_developer.git
25
+ ```
26
+
27
+ and add the following to your `PATH` (edit your ~/.bashrc or ~/.profile):
22
28
 
23
29
  ```console
24
30
  export PATH="$PATH:$HOME/effective_developer/bin"
25
31
  ```
26
32
 
33
+ # Shell scripts
34
+
27
35
  ## gem_release
28
36
 
29
37
  A command line shell script that quickly bumps the version of any ruby gem.
@@ -60,6 +68,55 @@ A command line script that calls [BFG Repo-Cleaner](https://rtyley.github.io/bfg
60
68
  > bfg --delete-files id_rsa.pub
61
69
  ```
62
70
 
71
+ # Rake scripts
72
+
73
+ ## Reset Pk Sequence
74
+
75
+ If you ever run into the error `duplicate key violates unique constraint (id) error`, run this script:
76
+
77
+ ```ruby
78
+ rake reset_pk_sequence
79
+ ```
80
+
81
+ This makes sure that the autoincremented (postgresql) Pk sequence matches the correct `id` value.
82
+
83
+ ## pg:pull
84
+
85
+ Creates a new backup on heroku, downloads that backup to latest.dump, and then calls pg:load
86
+
87
+ ```ruby
88
+ rake pg:pull
89
+ rake pg:pull[staging]
90
+ ```
91
+
92
+ ## pg:load
93
+
94
+ Drops and re-creates the local database then initializes database with the contents of latest.dump
95
+
96
+ ```ruby
97
+ rake pg:load
98
+ rake pg:load[something.dump]
99
+ ```
100
+
101
+ ## pg:save
102
+
103
+ Saves the development database to a postgresql .dump file (latest.dump by default)
104
+
105
+ ```ruby
106
+ rake pg:save
107
+ rake pg:save[something.dump]
108
+ ```
109
+
110
+ ## pg:clone
111
+
112
+ Clones the production (--remote heroku by default) database to staging (--remote staging by default)
113
+
114
+ ```ruby
115
+ rake pg:clone
116
+ rake pg:clone[origin,staging]
117
+ ```
118
+
119
+ # Rails Helpers
63
120
 
64
121
  ## CSV Importer
65
122
 
@@ -127,9 +127,21 @@ module Effective
127
127
  "\e[#{code}m#{text}\e[0m"
128
128
  end
129
129
 
130
- def parse_datetime(col, value)
130
+ def parse_first_name(column, value = nil)
131
+ value ||= col(column)
132
+ value.to_s.split(' ')[0]
133
+ end
134
+
135
+ def parse_last_name(column, value = nil)
136
+ value ||= col(column)
137
+ value.to_s.split(' ')[1..-1].try(:join, ' ')
138
+ end
139
+
140
+ def parse_datetime(column, value = nil)
141
+ value ||= col(column)
142
+
131
143
  begin
132
- Time.zone.parse(value)
144
+ Time.zone.parse(value.to_s)
133
145
  rescue => e
134
146
  error("Unable to Time.zone.parse('#{value}'). Override parse_datetime() to parse your own time, something like:\n#{' ' * 6}def parse_datetime(col, value)\n#{' ' * 8}Time.strptime(value, '%m/%d/%Y %H:%M:%S').in_time_zone\n#{' ' * 6}end")
135
147
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
@@ -21,6 +21,8 @@ namespace :import do
21
21
  desc "Import #{importer} from #{csv_file}"
22
22
 
23
23
  task importer => :environment do
24
+ require "#{Rails.application.root}/#{file}"
25
+
24
26
  klass = "CsvImporters::#{importer.classify.pluralize}Importer".safe_constantize
25
27
  raise "unable to constantize CsvImporters::#{importer.classify.pluralize}Importer for #{file}" unless klass
26
28
 
@@ -29,7 +29,7 @@ namespace :pg do
29
29
  # Drops and re-creates the local database then initializes database with latest.dump
30
30
  #
31
31
  # bundle exec rake pg:load => Will replace the current database with latest.dump
32
- # bundle exec rake pg:load[something.dump] => Will replace the current database with latest.dump
32
+ # bundle exec rake pg:load[something.dump] => Will replace the current database with something.dump
33
33
  desc 'Loads a postgresql .dump file into the development database (latest.dump by default)'
34
34
  task :load, [:file_name] => :environment do |t, args|
35
35
  args.with_defaults(:file_name => 'latest.dump')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_developer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails