jimothy 1.0.002 → 1.0.009
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/generators/jimothy/install_generator.rb +24 -15
- data/lib/jimothy/version.rb +1 -1
- data/lib/jimothy.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a70e66322520a834bb5c9aaf556786e3e66f4755a09366a0f632d4ee3d351d84
|
4
|
+
data.tar.gz: bbdb79e3e76580d55cc2e77babcd8d470f84a08d04d4c3ea78cd02b96b94ae52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89298bf266deb16420fb28cac27f11aebd0a3f9c88518d2de0c75fc19f35bb20e59c7335605511ffbb376d9a52d9bedf0ec096ea3062425fdeae385fea4e3893
|
7
|
+
data.tar.gz: 124537a7e4e05ca4bf7ba3e4b08aa2eed49fe0f6a391fa968b0d624f15acd27ccc262b794c68b3502b2a44c5872d169b23d3b145fa2bd2decf6906a51cf601ce
|
data/README.md
CHANGED
@@ -14,6 +14,7 @@ This is a (much) less robust version of something like Faker (https://github.com
|
|
14
14
|
|
15
15
|
## Usage (Quick, Using Custom Generator)
|
16
16
|
- (If you don't have an app already) Run `rails new testapp`
|
17
|
+
- Do `cd testapp`
|
17
18
|
- Add `gem "jimothy"` to your `Gemfile`
|
18
19
|
- Run `bundle install`
|
19
20
|
- Run `rails g jimothy:install`
|
@@ -24,6 +25,7 @@ This is a (much) less robust version of something like Faker (https://github.com
|
|
24
25
|
|
25
26
|
## Usage (Slow, Doing Everything By Hand)
|
26
27
|
- (If you don't have an app already) Run `rails new testapp`
|
28
|
+
- Do `cd testapp`
|
27
29
|
- Add `gem "jimothy"` to your `Gemfile`
|
28
30
|
- Run `bundle install`
|
29
31
|
- You'll need a `User` model with `name`, `email` and `image` fields (all `string`s). Fastest way to do this is:
|
@@ -4,21 +4,30 @@ require "rails/generators/rails/resource/resource_generator"
|
|
4
4
|
module Jimothy
|
5
5
|
module Generators
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
def install_jimothy
|
8
|
+
# only run if User model doesn't exist yet
|
9
|
+
if !Dir[Rails.root + 'app/models/*.rb'].map { |path| path.split('/')[-1] }.include? 'user.rb'
|
10
|
+
# scaffold users
|
11
|
+
%x(rails g scaffold user name email image)
|
12
|
+
%x(rails db:migrate)
|
13
|
+
|
14
|
+
# add image tag
|
15
|
+
gsub_file 'app/views/users/_user.html.erb',/<%= user.image %>/,'<%= image_tag user.image %>'
|
16
|
+
|
17
|
+
# empty seed file
|
18
|
+
gsub_file 'db/seeds.rb',/# This file should contain all the record creation needed to seed the database with its default values.\n# The data can then be loaded with the bin\/rails db:seed command \(or created alongside the database with db:setup\).\n#\n# Examples:\n#\n# movies = Movie.create\(\[\{ name: \"Star Wars\" \}, \{ name: \"Lord of the Rings\" \}\]\)\n# Character.create\(name: \"Luke\", movie: movies.first\)\n/,'.'
|
19
|
+
|
20
|
+
# add jimothy call
|
21
|
+
seeds_file = File.read('db/seeds.rb')
|
22
|
+
if seeds_file == '.' # only paste in this Jimothy::seed_users if the previous empty_seed_file was successful (ie, don't add it again if it's already there)
|
23
|
+
gsub_file 'db/seeds.rb',/./,"require \"jimothy\"\nJimothy::seed_users"
|
24
|
+
end
|
25
|
+
|
26
|
+
# seed_users
|
27
|
+
%x(rails db:seed)
|
28
|
+
else
|
29
|
+
puts "Error: user model already exists. Skipping jimothy install."
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
data/lib/jimothy/version.rb
CHANGED
data/lib/jimothy.rb
CHANGED
@@ -33,7 +33,7 @@ module Jimothy
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.import_images
|
36
|
-
images = Dir["#{GEM_IMAGE_PATH}" + "*.png"]
|
36
|
+
images = Dir["#{GEM_IMAGE_PATH}" + "*.png"] # TODO: there are jpgs in this folder for the readme, move them to a different folder
|
37
37
|
images.each do |path|
|
38
38
|
image = path.split('/')[-1]
|
39
39
|
source = "#{GEM_IMAGE_PATH}" + image
|