jimothy 1.0.001 → 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 +11 -4
- data/lib/generators/jimothy/install_generator.rb +24 -15
- data/lib/jimothy/images/screenshot.jpg +0 -0
- data/lib/jimothy/version.rb +1 -1
- data/lib/jimothy.rb +1 -1
- metadata +2 -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
@@ -1,27 +1,34 @@
|
|
1
1
|
# Jimothy
|
2
|
-
Placeholder user data from The Office
|
2
|
+
Placeholder user data from The Office.
|
3
|
+
Gem available at https://rubygems.org/gems/jimothy
|
3
4
|
|
4
5
|
![The office characters](https://github.com/mark-mcdermott/jimothy/blob/main/lib/jimothy/images/flonkerton.jpg)
|
5
6
|
|
6
7
|
## What This Does
|
7
8
|
|
8
|
-
Quickly seed placeholder user data for your Rails toy app or prototype
|
9
|
+
Quickly seed placeholder user data for your Rails toy app or prototype app. Generate the names, emails and profile pictures of eighteen characters from The Office.
|
9
10
|
|
10
11
|
## Why
|
11
12
|
|
12
|
-
This is a (much) less robust version of something like Faker (https://github.com/faker-ruby/faker). But I built it to be more reliable than Faker, with more solid data. Faker is great for what it does, but if you generate users from TV data, sometimes users get weird names like "Skinny Pete", where "Pete" isn't really a last name and it can mess up your data. Yeah it's just placeholder data, but we want it to look right.
|
13
|
+
This is a (much) less robust version of something like Faker (https://github.com/faker-ruby/faker). But I built it to be more reliable than Faker, with more solid data. Faker is great for what it does, but if you generate users from TV data for example, sometimes users get weird names like "Skinny Pete", where "Pete" isn't really a last name and it can mess up your data. Yeah it's just placeholder data, but we want it to look right.
|
13
14
|
|
14
15
|
## Usage (Quick, Using Custom Generator)
|
16
|
+
- (If you don't have an app already) Run `rails new testapp`
|
17
|
+
- Do `cd testapp`
|
15
18
|
- Add `gem "jimothy"` to your `Gemfile`
|
16
19
|
- Run `bundle install`
|
17
20
|
- Run `rails g jimothy:install`
|
18
21
|
- This will scaffold user model/views, import images, seed users and add an image tag to the user view's `_user.html.erb` partial.
|
19
22
|
- Run `rails server` and open `http://127.0.0.1:3000/users` - you should see the users from The Office.
|
20
23
|
|
24
|
+
![Jimothy screenshot](https://github.com/mark-mcdermott/jimothy/blob/main/lib/jimothy/images/screenshot.jpg)
|
25
|
+
|
21
26
|
## Usage (Slow, Doing Everything By Hand)
|
27
|
+
- (If you don't have an app already) Run `rails new testapp`
|
28
|
+
- Do `cd testapp`
|
22
29
|
- Add `gem "jimothy"` to your `Gemfile`
|
23
30
|
- Run `bundle install`
|
24
|
-
- You'll need a `User` model with `name`, `email` and `image` fields (all `string`s. Fastest way to do this is:
|
31
|
+
- You'll need a `User` model with `name`, `email` and `image` fields (all `string`s). Fastest way to do this is:
|
25
32
|
```
|
26
33
|
rails generate scaffold User name:string email:string image:string
|
27
34
|
rails db:migrate
|
@@ -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
|
Binary file
|
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jimothy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.009
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark McDermott
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/jimothy/images/pam-beesly.png
|
65
65
|
- lib/jimothy/images/phyllis-vance.png
|
66
66
|
- lib/jimothy/images/ryan-howard.png
|
67
|
+
- lib/jimothy/images/screenshot.jpg
|
67
68
|
- lib/jimothy/images/stanley-hudson.png
|
68
69
|
- lib/jimothy/images/toby-flenderson.png
|
69
70
|
- lib/jimothy/the-office-characters.json
|