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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 255502c8c568226ce82080916eae0bdb0fb3073fb7372a5f036a34616608c473
4
- data.tar.gz: 73529e4e80f39edb1e56ded50686d4e6cd1d73b3f90fafe01aca155b19159f09
3
+ metadata.gz: a70e66322520a834bb5c9aaf556786e3e66f4755a09366a0f632d4ee3d351d84
4
+ data.tar.gz: bbdb79e3e76580d55cc2e77babcd8d470f84a08d04d4c3ea78cd02b96b94ae52
5
5
  SHA512:
6
- metadata.gz: 0ad498d87ab805b1a66398df1390983da77558a0339ea0753ed731601051dfd2c5459f2b3faa095987dca41e509af8b2e17225d7a9140345c5afd2aeb62a66ab
7
- data.tar.gz: d9c4a066276e6ac01016030e4612645540a3583fe77500c698200e5150dca47d581237ffd7fe102986bc4da42d02583275d5b29332950ac046370a83d2a1d04b
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 scaffold_users
8
- %x(rails g scaffold user name email image)
9
- %x(rails db:migrate)
10
- end
11
- def add_image_tag
12
- gsub_file 'app/views/users/_user.html.erb',/<%= user.image %>/,'<%= image_tag user.image %>'
13
- end
14
- def empty_seed_file
15
- 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/,'.'
16
- end
17
- def add_jimothy_call
18
- gsub_file 'db/seeds.rb',/./,"require \"jimothy\"\nJimothy::seed_users"
19
- end
20
- def seed_users
21
- %x(rails db:seed)
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
@@ -1,3 +1,3 @@
1
1
  module Jimothy
2
- VERSION = "1.0.002"
2
+ VERSION = "1.0.009"
3
3
  end
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.002
4
+ version: 1.0.009
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark McDermott