jimothy 1.0.009 → 1.0.011
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -41
- data/app/assets/config/jimothy_manifest.js +1 -0
- data/{lib/jimothy → app/assets}/images/andy-bernard.png +0 -0
- data/{lib/jimothy → app/assets}/images/angela-martin.png +0 -0
- data/{lib/jimothy → app/assets}/images/creed-bratton.png +0 -0
- data/{lib/jimothy → app/assets}/images/darryl-philbin.png +0 -0
- data/{lib/jimothy → app/assets}/images/dwight-schrute.png +0 -0
- data/{lib/jimothy → app/assets}/images/erin-hannon.png +0 -0
- data/{lib/jimothy → app/assets}/images/flonkerton.jpg +0 -0
- data/{lib/jimothy → app/assets}/images/jim-halpert.png +0 -0
- data/{lib/jimothy → app/assets}/images/kelly-kapoor.png +0 -0
- data/{lib/jimothy → app/assets}/images/kevin-malone.png +0 -0
- data/{lib/jimothy → app/assets}/images/meredith-palmer.png +0 -0
- data/app/assets/images/michael-scott.jpg +0 -0
- data/{lib/jimothy → app/assets}/images/michael-scott.png +0 -0
- data/{lib/jimothy → app/assets}/images/oscar-martinez.png +0 -0
- data/{lib/jimothy → app/assets}/images/pam-beesly.png +0 -0
- data/{lib/jimothy → app/assets}/images/phyllis-vance.png +0 -0
- data/{lib/jimothy → app/assets}/images/ryan-howard.png +0 -0
- data/{lib/jimothy → app/assets}/images/screenshot.jpg +0 -0
- data/{lib/jimothy → app/assets}/images/stanley-hudson.png +0 -0
- data/{lib/jimothy → app/assets}/images/toby-flenderson.png +0 -0
- data/lib/generators/jimothy/install_generator.rb +25 -5
- data/lib/jimothy/version.rb +1 -1
- data/lib/jimothy.rb +15 -24
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d08a408d886553058d5d17a5ff41751d55de648763df93b85f6f689e57632033
|
4
|
+
data.tar.gz: 12c1a834d3ea3b19f948cbcc523f62f47fe7791af681bce9e920cdc1ae279c8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74a299120ed1517dbd2c4c9518fdbef9a2e37c34579d4acbdb9444d8a787990a40f264d92377957fea34d50ec9ea7bc3e450f87d4ba40bd3c848e4309e5d8533
|
7
|
+
data.tar.gz: 2445363e3ca41e59ac68bd3a84d22c93a20d7638df8ebb3c6560474ad7ca1e4d30880c743326677da15bd98ef2c9cddde52bc3ddbec93dff96f9a666702fdcc6
|
data/README.md
CHANGED
@@ -1,50 +1,28 @@
|
|
1
1
|
# Jimothy
|
2
|
-
|
3
|
-
Gem available at https://rubygems.org/gems/jimothy
|
2
|
+
Short description and motivation.
|
4
3
|
|
5
|
-
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
## Why
|
12
|
-
|
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.
|
14
|
-
|
15
|
-
## Usage (Quick, Using Custom Generator)
|
16
|
-
- (If you don't have an app already) Run `rails new testapp`
|
17
|
-
- Do `cd testapp`
|
18
|
-
- Add `gem "jimothy"` to your `Gemfile`
|
19
|
-
- Run `bundle install`
|
20
|
-
- Run `rails g jimothy:install`
|
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.
|
22
|
-
- Run `rails server` and open `http://127.0.0.1:3000/users` - you should see the users from The Office.
|
23
|
-
|
24
|
-
![Jimothy screenshot](https://github.com/mark-mcdermott/jimothy/blob/main/lib/jimothy/images/screenshot.jpg)
|
25
|
-
|
26
|
-
## Usage (Slow, Doing Everything By Hand)
|
27
|
-
- (If you don't have an app already) Run `rails new testapp`
|
28
|
-
- Do `cd testapp`
|
29
|
-
- Add `gem "jimothy"` to your `Gemfile`
|
30
|
-
- Run `bundle install`
|
31
|
-
- You'll need a `User` model with `name`, `email` and `image` fields (all `string`s). Fastest way to do this is:
|
32
|
-
```
|
33
|
-
rails generate scaffold User name:string email:string image:string
|
34
|
-
rails db:migrate
|
10
|
+
```ruby
|
11
|
+
gem "jimothy"
|
35
12
|
```
|
36
|
-
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
37
17
|
```
|
38
|
-
|
39
|
-
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install jimothy
|
40
22
|
```
|
41
|
-
- Run `rails db:seed`
|
42
|
-
- In `app/views/users/_user.html.erb`, change `<%= user.image %>` to `<%= image_tag user.image %>`
|
43
|
-
- Run `rails server` and go to `http://127.0.0.1:3000/users` - you should see the users from The Office.
|
44
23
|
|
45
|
-
##
|
46
|
-
|
47
|
-
- Initial user data is in a json file in `lib/jimothy/the-office-characters.json`
|
48
|
-
- Inital user images are in `lib/jimothy/images`
|
49
|
-
- I believe images in Rails engines are supposed to be directly available from the gem for use in a Rail app's asset pipeline, but I could not get this working and couldn't find sufficient documentation for this. So I just copy the images from the gem to the rails app (to `app/assets/images`) in the `import_images` method, which is called by the `seed_users` method.
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
50
26
|
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,29 +5,49 @@ module Jimothy
|
|
5
5
|
module Generators
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
7
|
def install_jimothy
|
8
|
+
cyan = "\e[36m" # use cyan color for puts
|
8
9
|
# only run if User model doesn't exist yet
|
9
10
|
if !Dir[Rails.root + 'app/models/*.rb'].map { |path| path.split('/')[-1] }.include? 'user.rb'
|
11
|
+
puts "#{cyan}\n🦄 Scaffolding user model now."
|
10
12
|
# scaffold users
|
11
13
|
%x(rails g scaffold user name email image)
|
14
|
+
puts "🦄 User model/views scaffolding built."
|
12
15
|
%x(rails db:migrate)
|
16
|
+
puts "🦄 Database migrated."
|
13
17
|
|
14
18
|
# add image tag
|
15
19
|
gsub_file 'app/views/users/_user.html.erb',/<%= user.image %>/,'<%= image_tag user.image %>'
|
20
|
+
puts "#{cyan}🦄 _user view partial updated."
|
16
21
|
|
17
22
|
# empty seed file
|
18
|
-
|
23
|
+
if File.exists?('db/seeds.rb')
|
24
|
+
puts "🦄 Seed file exists - emptying the file now."
|
25
|
+
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/,''
|
26
|
+
else
|
27
|
+
puts "🦄 Seed file does not exist. Creating now."
|
28
|
+
File.open("db/seeds.rb") {|f| f.write(".") }
|
29
|
+
end
|
19
30
|
|
20
31
|
# add jimothy call
|
21
32
|
seeds_file = File.read('db/seeds.rb')
|
22
|
-
if seeds_file
|
23
|
-
|
33
|
+
if seeds_file.empty? # 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)
|
34
|
+
puts "#{cyan}🦄 Seed file is empty - adding Jimothy::seed_users call now."
|
35
|
+
File.write('db/seeds.rb', "require \"jimothy\"\nJimothy::seed_users", mode: 'a+')
|
36
|
+
else
|
37
|
+
puts "🤔 Seed file is not empty - skipping adding Jimothy::seed_users call."
|
24
38
|
end
|
25
39
|
|
26
|
-
#
|
40
|
+
# seed users
|
41
|
+
puts "🦄 Seeding users now."
|
27
42
|
%x(rails db:seed)
|
43
|
+
|
44
|
+
# add gem manifest to app manifest
|
45
|
+
puts "🦄 Adding jimothy gem manifest to app manifest now.\n"
|
46
|
+
File.write('app/assets/config/manifest.js', '//= link jimothy_manifest.js', mode: 'a+')
|
28
47
|
else
|
29
|
-
puts "Error: user model already exists. Skipping jimothy install."
|
48
|
+
puts "#{cyan}\n🤔 Error: user model already exists. Skipping jimothy install."
|
30
49
|
end
|
50
|
+
puts "\e[0m" # restore puts color to normal
|
31
51
|
end
|
32
52
|
end
|
33
53
|
end
|
data/lib/jimothy/version.rb
CHANGED
data/lib/jimothy.rb
CHANGED
@@ -8,37 +8,28 @@ GEM_IMAGE_PATH = "#{GEM_ROOT}/lib/jimothy/images/"
|
|
8
8
|
RAILS_IMAGE_PATH = "/app/assets/images/"
|
9
9
|
|
10
10
|
module Jimothy
|
11
|
-
|
12
|
-
class Railtie < Rails::Railtie
|
13
|
-
config.app_generators do |g|
|
14
|
-
g.templates.unshift File::expand_path('../../templates', __FILE__)
|
15
|
-
g.templates.unshift File::expand_path('../../templates/erb/scaffold/_user.html.erb.tt')
|
16
|
-
g.templates.unshift File::expand_path('../../templates/erb/scaffold/_user.html.erb')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
11
|
def self.get_users
|
21
12
|
users = JSON.parse(IO.read("#{JSON_PATH}"))['users']
|
22
13
|
end
|
23
14
|
|
24
15
|
def self.seed_users
|
25
|
-
create_users
|
26
|
-
import_images
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.create_users
|
30
16
|
get_users.each do |user|
|
31
17
|
User.create(name: user['firstname'] + " " + user['lastname'], email: user['email'], image: user['image'])
|
32
18
|
end
|
33
19
|
end
|
34
20
|
|
35
|
-
def self.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
21
|
+
# def self.seed_users
|
22
|
+
# create_users
|
23
|
+
# import_images
|
24
|
+
# end
|
25
|
+
|
26
|
+
# def self.import_images
|
27
|
+
# images = Dir["#{GEM_IMAGE_PATH}" + "*.png"] # TODO: there are jpgs in this folder for the readme, move them to a different folder
|
28
|
+
# images.each do |path|
|
29
|
+
# image = path.split('/')[-1]
|
30
|
+
# source = "#{GEM_IMAGE_PATH}" + image
|
31
|
+
# target = "#{Rails.root}#{RAILS_IMAGE_PATH}" + image
|
32
|
+
# FileUtils.cp(source, target)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.011
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark McDermott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,9 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 7.0.4.2
|
27
|
-
description:
|
28
|
-
app. Generate the names, emails and profile pictures of eighteen characters from
|
29
|
-
The Office.
|
27
|
+
description: Description of Jimothy.
|
30
28
|
email:
|
31
29
|
- mark@markmcdermott.io
|
32
30
|
executables: []
|
@@ -37,6 +35,26 @@ files:
|
|
37
35
|
- README.md
|
38
36
|
- Rakefile
|
39
37
|
- app/assets/config/jimothy_manifest.js
|
38
|
+
- app/assets/images/andy-bernard.png
|
39
|
+
- app/assets/images/angela-martin.png
|
40
|
+
- app/assets/images/creed-bratton.png
|
41
|
+
- app/assets/images/darryl-philbin.png
|
42
|
+
- app/assets/images/dwight-schrute.png
|
43
|
+
- app/assets/images/erin-hannon.png
|
44
|
+
- app/assets/images/flonkerton.jpg
|
45
|
+
- app/assets/images/jim-halpert.png
|
46
|
+
- app/assets/images/kelly-kapoor.png
|
47
|
+
- app/assets/images/kevin-malone.png
|
48
|
+
- app/assets/images/meredith-palmer.png
|
49
|
+
- app/assets/images/michael-scott.jpg
|
50
|
+
- app/assets/images/michael-scott.png
|
51
|
+
- app/assets/images/oscar-martinez.png
|
52
|
+
- app/assets/images/pam-beesly.png
|
53
|
+
- app/assets/images/phyllis-vance.png
|
54
|
+
- app/assets/images/ryan-howard.png
|
55
|
+
- app/assets/images/screenshot.jpg
|
56
|
+
- app/assets/images/stanley-hudson.png
|
57
|
+
- app/assets/images/toby-flenderson.png
|
40
58
|
- app/assets/stylesheets/jimothy/application.css
|
41
59
|
- app/controllers/jimothy/application_controller.rb
|
42
60
|
- app/helpers/jimothy/application_helper.rb
|
@@ -48,29 +66,10 @@ files:
|
|
48
66
|
- lib/generators/jimothy/install_generator.rb
|
49
67
|
- lib/jimothy.rb
|
50
68
|
- lib/jimothy/engine.rb
|
51
|
-
- lib/jimothy/images/andy-bernard.png
|
52
|
-
- lib/jimothy/images/angela-martin.png
|
53
|
-
- lib/jimothy/images/creed-bratton.png
|
54
|
-
- lib/jimothy/images/darryl-philbin.png
|
55
|
-
- lib/jimothy/images/dwight-schrute.png
|
56
|
-
- lib/jimothy/images/erin-hannon.png
|
57
|
-
- lib/jimothy/images/flonkerton.jpg
|
58
|
-
- lib/jimothy/images/jim-halpert.png
|
59
|
-
- lib/jimothy/images/kelly-kapoor.png
|
60
|
-
- lib/jimothy/images/kevin-malone.png
|
61
|
-
- lib/jimothy/images/meredith-palmer.png
|
62
|
-
- lib/jimothy/images/michael-scott.png
|
63
|
-
- lib/jimothy/images/oscar-martinez.png
|
64
|
-
- lib/jimothy/images/pam-beesly.png
|
65
|
-
- lib/jimothy/images/phyllis-vance.png
|
66
|
-
- lib/jimothy/images/ryan-howard.png
|
67
|
-
- lib/jimothy/images/screenshot.jpg
|
68
|
-
- lib/jimothy/images/stanley-hudson.png
|
69
|
-
- lib/jimothy/images/toby-flenderson.png
|
70
69
|
- lib/jimothy/the-office-characters.json
|
71
70
|
- lib/jimothy/version.rb
|
72
71
|
- lib/tasks/jimothy_tasks.rake
|
73
|
-
homepage: https://github.com/mark-mcdermott/jimothy
|
72
|
+
homepage: https://github.com/mark-mcdermott/jimothy
|
74
73
|
licenses:
|
75
74
|
- MIT
|
76
75
|
metadata: {}
|
@@ -92,5 +91,5 @@ requirements: []
|
|
92
91
|
rubygems_version: 3.3.7
|
93
92
|
signing_key:
|
94
93
|
specification_version: 4
|
95
|
-
summary:
|
94
|
+
summary: Summary of Jimothy.
|
96
95
|
test_files: []
|