cuttings 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +48 -10
- data/lib/cuttings.rb +2 -0
- data/lib/cuttings/railtie.rb +11 -0
- data/lib/cuttings/version.rb +1 -1
- data/lib/generators/cuttings/cuttings_generator.rb +21 -0
- data/lib/generators/cuttings/install/install_generator.rb +24 -0
- data/lib/generators/cuttings/templates/cuttings.rake +7 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9867e735e11f82a4e79dbfb8d2d809d43ecee9f
|
4
|
+
data.tar.gz: 2914a5a0cbb9da373fba49d58c7b55e261065085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f010cc3512589b10722c0a084fae99e288f0404d904e7e29bab0385bc3bc8deb62833928f8a2ebc1013176c72c56b113af699fd4dfa43a4479fbc3cf43d83329
|
7
|
+
data.tar.gz: e319680b8d7f0743e1eff0bfaab831aad03a2b4b431a0b4d4ab6ead9ee4f59f80c9bd4818b17e49c4e059e8048d97b5b0b39690c368f26bb1771487e2bf1ee8d
|
data/README.md
CHANGED
@@ -13,22 +13,60 @@ Add to your Gemfile and `bundle install` :
|
|
13
13
|
gem 'cuttings'
|
14
14
|
```
|
15
15
|
|
16
|
+
Then create the directory structure with the install generator :
|
17
|
+
|
18
|
+
```bash
|
19
|
+
rails generate cuttings:install
|
20
|
+
```
|
21
|
+
|
16
22
|
## Usage
|
17
23
|
|
18
|
-
|
24
|
+
Your can use **Cuttings** in your `db/seeds.rb` file, or inside `rake` tasks,
|
25
|
+
depending on which method you prefer.
|
26
|
+
|
27
|
+
If you choose the `db/seeds.rb` file way, just use the API as explained in the
|
28
|
+
**DSL** section.
|
29
|
+
|
30
|
+
If you choose the `rake` task way, a generator is provided to help you organize
|
31
|
+
your seed tasks.
|
32
|
+
|
33
|
+
### Using the `cuttings` generator :
|
34
|
+
|
35
|
+
But a generator is provided to help you create separated seed data accessible
|
36
|
+
with `rake` tasks.
|
37
|
+
|
38
|
+
```bash
|
39
|
+
rails generate cuttings users
|
40
|
+
```
|
41
|
+
|
42
|
+
Which will generate the following file in `lib/seeds/tasks/users.rake`
|
19
43
|
|
20
44
|
```ruby
|
21
|
-
|
45
|
+
namespace :seed do
|
46
|
+
task users: :environment do
|
47
|
+
Cuttings.plant do
|
48
|
+
# Add your seeding code here
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
```
|
22
53
|
|
23
|
-
|
24
|
-
truncate %w(Visit)
|
54
|
+
### Example usage
|
25
55
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
56
|
+
```ruby
|
57
|
+
namespace :seed do
|
58
|
+
task users: :environment do
|
59
|
+
Cuttings.plant do
|
60
|
+
truncate %w(Visit)
|
61
|
+
|
62
|
+
seed 'User' do
|
63
|
+
create(
|
64
|
+
name: 'Jean Jean',
|
65
|
+
email: 'jean@jean.com',
|
66
|
+
avatar: attachment('user.png')
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
32
70
|
end
|
33
71
|
end
|
34
72
|
```
|
data/lib/cuttings.rb
CHANGED
data/lib/cuttings/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class CuttingsGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc 'Cuttings install generator'
|
7
|
+
|
8
|
+
def welcome
|
9
|
+
say 'Creating new cuttings ...'
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_folders
|
13
|
+
template 'cuttings.rake', "lib/seeds/tasks/#{ name }.rake"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def base_dir
|
19
|
+
@base_dir ||= Rails.root.join('lib', 'seeds')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Cuttings
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Cuttings install generator'
|
8
|
+
|
9
|
+
def welcome
|
10
|
+
say 'Installing cuttings ...'
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_folders
|
14
|
+
FileUtils.mkdir_p(base_dir.join('attachments'))
|
15
|
+
FileUtils.mkdir_p(base_dir.join('tasks'))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def base_dir
|
21
|
+
@base_dir ||= Rails.root.join('lib', 'seeds')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuttings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentin Ballestrino
|
@@ -51,7 +51,11 @@ files:
|
|
51
51
|
- lib/cuttings.rb
|
52
52
|
- lib/cuttings/cutting.rb
|
53
53
|
- lib/cuttings/greenhouse.rb
|
54
|
+
- lib/cuttings/railtie.rb
|
54
55
|
- lib/cuttings/version.rb
|
56
|
+
- lib/generators/cuttings/cuttings_generator.rb
|
57
|
+
- lib/generators/cuttings/install/install_generator.rb
|
58
|
+
- lib/generators/cuttings/templates/cuttings.rake
|
55
59
|
- lib/tasks/cuttings_tasks.rake
|
56
60
|
homepage: http://github.com/glyph-fr/cuttings
|
57
61
|
licenses:
|