schema_to_scaffold 0.8.0 → 0.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2687f54c3d084dbb6678d431c66db92a31ba691c
4
- data.tar.gz: f731ebdb43c91ba5f8e98f0c3a26507aeaf8da61
2
+ SHA256:
3
+ metadata.gz: 229ebc7daea413c98b93c50601c9849af0e827f2fbb2d338b09872b54470a46d
4
+ data.tar.gz: 0c514edaa979279a1a2a8f764c198618c07040662f830c1c4fb133ec7b0ce23e
5
5
  SHA512:
6
- metadata.gz: 733cce3b7f62c783a43a095e1c339411416c0a3a81664d06d77120b1945d502960dc8213d3e6df61fa9670bba5c8d823ed9918e349fa6c48c50ef42125cff27c
7
- data.tar.gz: c16a1b76fc4841df4025e71ab8d781acb7c29687f1b59008c3113f1743cd55be9f02e4fa58ec24c55114c2e87b38b75c65efbf2b9a4ae2d67ef374c4c258f755
6
+ metadata.gz: faf0fa5ce0d3c2a3c773c2840bb5a8fac8507d722e3a1f681a65f71aaea31db204f7a22d95dc68bd9f99bc30ecc01f5ed392eb5df171ea96d897dd1f4867dd36
7
+ data.tar.gz: 2c85e8f978b9e831671a9ae1512a9c6103f3f9a12bd59e8d27e395dac5848766f38ab04229561e70910b00448e41cdf157f175fa750992e619d63f90ddd149d5
data/.gitignore CHANGED
@@ -18,4 +18,5 @@ tmp
18
18
  .project
19
19
  /schema.rb
20
20
  .idea
21
- spec/examples.txt
21
+ spec/examples.txt
22
+ .byebug_history
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.7.4
data/README.md CHANGED
@@ -7,7 +7,7 @@ This Gem generates Rails command strings based on a Rails database schema you al
7
7
  This Gem does not modify anything; it simply prints a string which you can then use to invoke the Rails generators, and optionally copies the string to your clipboard. Generated string commands available are:
8
8
  ```bash
9
9
  rails generate scaffold <model_name> <field[:type]>
10
- rails generate factory_girl:model <ModelName> <field[:type]>
10
+ rails generate factory_bot:model <ModelName> <field[:type]>
11
11
  ```
12
12
 
13
13
  Use your schema.rb file from `<rails_app>/db` or generated with `rake db:schema:dump`. You can optionally rename schema.rb to `schema_your_fav_name.rb` and it will still be found. Unique schema file names will prevent schema.rb from being overwritten if you use migrations and run `rake db:migrate`.
@@ -26,24 +26,28 @@ Assuming that you have rubygems-bundler installed, just type:
26
26
 
27
27
  ## Usage
28
28
 
29
+ ```bash
30
+ $ scaffold [options]
29
31
  ```
30
- Usage: scaffold [options]
32
+
31
33
  Generate a rails scaffold script for a given schema.rb
34
+ ```
32
35
  -h Displays help.
33
36
  -p <path> It specifies a path to a folder or to a file.
34
37
  -c Will copy the script to your clipboard. Requires xclip be installed on Linux.
35
- -f Generates a factory_girl:model rather than a full scaffold.
38
+ -f Generates a factory_bot:model rather than a full scaffold.
36
39
  -m Add migration (use if your schema comes from a different database)
37
-
40
+ ```
38
41
  Examples:
39
- scaffold
40
- scaffold -c -p ~/work/rails/my_app
41
- scaffold -c -p ~/work/rails/my_app/db/schema.rb
42
-
42
+ ```bash
43
+ $ scaffold
44
+ $ scaffold -c -p ~/work/rails/my_app
45
+ $ scaffold -c -p ~/work/rails/my_app/db/schema.rb
43
46
  ```
47
+
44
48
  ## Generators
45
49
 
46
- Since this gem assists you in invoking Rails generators for your scaffolding, make sure you've configured your generators with your preferred settings before you start. There's a good [Rails Guide](http://guides.rubyonrails.org/generators.html) and you can invoke `rails g scaffold -h` to see options.
50
+ Since this gem assists you in invoking Rails generators for your scaffolding, make sure you've configured your generators with your preferred settings before you start. There's a good [Rails Guide](http://guides.rubyonrails.org/generators.html) and you can invoke `$ rails g scaffold -h` to see options.
47
51
 
48
52
  Generator options are configured in `config/application.rb`. Here is an example setting:
49
53
 
@@ -56,15 +60,15 @@ module YourApplication
56
60
  g.helper false # Don't create view helpers
57
61
  g.test_framework :rspec, :view_specs => false
58
62
  g.integration_tool :rspec
59
- g.fixture_replacement :factory_girl # Choose between fixtures and factories
60
- g.factory_girl dir: 'spec/factories'
63
+ g.fixture_replacement :factory_bot # Choose between fixtures and factories
64
+ g.factory_bot dir: 'spec/factories'
61
65
  g.javascript_engine :js # Disable coffeescript
62
66
  g.scaffold_controller "responders_controller" # from responders gem
63
67
  end
64
68
  end
65
69
  end
66
70
  ```
67
- If you configure factory_girl as your fixture_replacement here, there is no need to invoke factory_girl separately with the `scaffold -f` command.
71
+ If you configure factory_bot as your fixture_replacement here, there is no need to invoke factory_bot separately with the `scaffold -f` command.
68
72
 
69
73
  ## Migrations
70
74
 
@@ -72,7 +76,7 @@ Schema to Scaffold is set up by default to support creating scaffolds for your e
72
76
 
73
77
  ## To install xclip on Linux
74
78
 
75
- sudo apt-get install xclip
79
+ `apt-get install xclip`
76
80
 
77
81
  ## Contributing
78
82
 
@@ -83,10 +87,10 @@ Schema to Scaffold is set up by default to support creating scaffolds for your e
83
87
  3. Commit your changes (`git commit -am "Added great stuff"`)
84
88
  4. Push to the branch (`git push origin my_schema_to_scaffold`)
85
89
  5. Open a [Pull Request][1]
86
- 6. That's all!!
90
+ 6. That's all!!
87
91
 
88
92
  [1]: http://github.com/frenesim/schema_to_scaffold/pulls
89
93
 
90
94
  ## Collaborate
91
95
 
92
- If you want to collaborate, please send me an email, or just create an issue or pull request.
96
+ If you want to collaborate, please send me an email, or just create an issue or pull request.
@@ -24,6 +24,8 @@ module SchemaToScaffold
24
24
  rescue
25
25
  puts "\nUnable to open file '#{path}'"
26
26
  exit 1
27
+ rescue Interrupt => e
28
+ exit 1
27
29
  end
28
30
 
29
31
  ## Generate scripts from schema
@@ -47,10 +49,12 @@ module SchemaToScaffold
47
49
  rescue
48
50
  puts "Not a valid input. #{TABLE_OPTIONS}"
49
51
  exit 1
52
+ rescue Interrupt => e
53
+ exit 1
50
54
  end
51
55
 
52
56
  script = []
53
- target = opts[:factory_girl] ? "factory_girl:model" : "scaffold"
57
+ target = opts[:factory_bot] ? "factory_bot:model" : "scaffold"
54
58
  migration_flag = opts[:migration] ? true : false
55
59
 
56
60
  tables.each do |table_id|
@@ -76,7 +80,7 @@ module SchemaToScaffold
76
80
 
77
81
  args = {
78
82
  clipboard: argv.delete('-c'), # check for clipboard flag
79
- factory_girl: argv.delete('-f'), # factory_girl instead of scaffold
83
+ factory_bot: argv.delete('-f'), # factory_bot instead of scaffold
80
84
  migration: argv.delete('-m'), # generate migrations
81
85
  help: argv.delete('-h'), # check for help flag
82
86
  path: path # get path to file(s)
@@ -85,7 +89,7 @@ module SchemaToScaffold
85
89
  if argv.empty?
86
90
  args
87
91
  else
88
- puts "\n------\nWrong set of arguments.\n------\n"
92
+ puts "\n------\nWrong set of arguments.\n------\n"
89
93
  puts Help.message
90
94
  exit
91
95
  end
@@ -8,7 +8,7 @@ Generate a rails scaffold script for a given schema.rb
8
8
  -h Displays help.
9
9
  -p <path> It specifies a path to a folder or to a file.
10
10
  -c Will copy the script to your clipboard. Requires xclip be installed on Linux.
11
- -f Generates a factory_girl:model rather than a full scaffold.
11
+ -f Generates a factory_bot:model rather than a full scaffold.
12
12
  -m Add migration (use if your schema comes from a different database)
13
13
 
14
14
  END_OF_HELP
@@ -23,7 +23,11 @@ module SchemaToScaffold
23
23
 
24
24
  begin
25
25
  print "\nSelect a path to the target schema: "
26
- end while search_paths_list[(id = STDIN.gets.to_i)].nil?
26
+ while search_paths_list[(id = STDIN.gets.to_i)].nil?; end
27
+ rescue Interrupt => e
28
+ exit 1
29
+ end
30
+
27
31
 
28
32
  search_paths_list[id]
29
33
  end
@@ -28,7 +28,7 @@ module SchemaToScaffold
28
28
  case id
29
29
  when Symbol then table(id.to_s)
30
30
  when String then tables[table_names.index(id)]
31
- when Fixnum then tables[id]
31
+ when Integer then tables[id]
32
32
  else nil
33
33
  end
34
34
  end
@@ -1,6 +1,6 @@
1
1
  module SchemaToScaffold
2
2
  MAJOR = 0
3
3
  MINOR = 8
4
- REVISION = 0
4
+ REVISION = 2
5
5
  VERSION = [MAJOR, MINOR, REVISION].join('.')
6
6
  end
@@ -20,8 +20,8 @@ EOD
20
20
  gem.licenses = ['MIT']
21
21
  gem.required_ruby_version = '>= 1.9.3'
22
22
 
23
- gem.add_runtime_dependency('activesupport', '>= 3.2.1')
24
- gem.add_development_dependency('pry', '~> 0.10', '>= 0.10.0')
25
- gem.add_development_dependency('rspec')
26
- gem.add_development_dependency('simplecov')
23
+ gem.add_runtime_dependency('activesupport', '~> 7')
24
+ gem.add_development_dependency('byebug', '~> 11')
25
+ gem.add_development_dependency('rspec', '~> 3')
26
+ gem.add_development_dependency('simplecov', '~> 0.21')
27
27
  end
data/spec/cli_spec.rb CHANGED
@@ -92,23 +92,23 @@ module SchemaToScaffold
92
92
 
93
93
  context "handles arguments" do
94
94
  it "help argument" do
95
- expect(CLI.parse_arguments(["-h"])).to eq({clipboard: nil, factory_girl: nil, migration: nil, help: "-h", path: nil})
95
+ expect(CLI.parse_arguments(["-h"])).to eq({clipboard: nil, factory_bot: nil, migration: nil, help: "-h", path: nil})
96
96
  end
97
97
 
98
98
  it "path argument" do
99
- expect(CLI.parse_arguments(["-p", "/some/path"])).to eq({clipboard: nil, factory_girl: nil, migration: nil, help: nil, path: "/some/path"})
99
+ expect(CLI.parse_arguments(["-p", "/some/path"])).to eq({clipboard: nil, factory_bot: nil, migration: nil, help: nil, path: "/some/path"})
100
100
  end
101
101
 
102
102
  it "clipboard argument" do
103
- expect(CLI.parse_arguments(["-c"])).to eq({clipboard: "-c", factory_girl: nil, migration: nil, help: nil, path: nil})
103
+ expect(CLI.parse_arguments(["-c"])).to eq({clipboard: "-c", factory_bot: nil, migration: nil, help: nil, path: nil})
104
104
  end
105
105
 
106
106
  it "factory girl argument" do
107
- expect(CLI.parse_arguments(["-f"])).to eq({clipboard: nil, factory_girl: "-f", migration: nil, help: nil, path: nil})
107
+ expect(CLI.parse_arguments(["-f"])).to eq({clipboard: nil, factory_bot: "-f", migration: nil, help: nil, path: nil})
108
108
  end
109
109
 
110
110
  it "migration argument" do
111
- expect(CLI.parse_arguments(["-m"])).to eq({clipboard: nil, factory_girl: nil, migration: "-m", help: nil, path: nil})
111
+ expect(CLI.parse_arguments(["-m"])).to eq({clipboard: nil, factory_bot: nil, migration: "-m", help: nil, path: nil})
112
112
  end
113
113
  end
114
114
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,7 @@ require "simplecov"
10
10
  SimpleCov.start 'test_frameworks'
11
11
 
12
12
  require "schema_to_scaffold"
13
+ require "byebug"
13
14
 
14
15
  # Given that it is always loaded, you are encouraged to keep this file as
15
16
  # light-weight as possible. Requiring heavyweight dependencies from this file
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_to_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Soares
@@ -9,70 +9,64 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-27 00:00:00.000000000 Z
12
+ date: 2022-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 3.2.1
20
+ version: '7'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 3.2.1
27
+ version: '7'
28
28
  - !ruby/object:Gem::Dependency
29
- name: pry
29
+ name: byebug
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.10'
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: 0.10.0
34
+ version: '11'
38
35
  type: :development
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
38
  requirements:
42
39
  - - "~>"
43
40
  - !ruby/object:Gem::Version
44
- version: '0.10'
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.10.0
41
+ version: '11'
48
42
  - !ruby/object:Gem::Dependency
49
43
  name: rspec
50
44
  requirement: !ruby/object:Gem::Requirement
51
45
  requirements:
52
- - - ">="
46
+ - - "~>"
53
47
  - !ruby/object:Gem::Version
54
- version: '0'
48
+ version: '3'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
52
  requirements:
59
- - - ">="
53
+ - - "~>"
60
54
  - !ruby/object:Gem::Version
61
- version: '0'
55
+ version: '3'
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: simplecov
64
58
  requirement: !ruby/object:Gem::Requirement
65
59
  requirements:
66
- - - ">="
60
+ - - "~>"
67
61
  - !ruby/object:Gem::Version
68
- version: '0'
62
+ version: '0.21'
69
63
  type: :development
70
64
  prerelease: false
71
65
  version_requirements: !ruby/object:Gem::Requirement
72
66
  requirements:
73
- - - ">="
67
+ - - "~>"
74
68
  - !ruby/object:Gem::Version
75
- version: '0'
69
+ version: '0.21'
76
70
  description: " Command line app which parses a schema.rb file obtained from your
77
71
  rails repo or by running rake:schema:dump\n"
78
72
  email:
@@ -112,6 +106,7 @@ files:
112
106
  - spec/schema_to_scaffold_spec.rb
113
107
  - spec/spec_helper.rb
114
108
  - spec/support/empty_schema.rb
109
+ - spec/support/no_schema/.keep
115
110
  - spec/support/schema.rb
116
111
  - spec/support/table.rb
117
112
  - spec/table_spec.rb
@@ -134,8 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
129
  - !ruby/object:Gem::Version
135
130
  version: '0'
136
131
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.5.1
132
+ rubygems_version: 3.1.6
139
133
  signing_key:
140
134
  specification_version: 4
141
135
  summary: Generate rails scaffold script from a schema.rb file.