model_2_factory-rails 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: ebd03d0d28a35452fa8de28d87de55aa5a9dae04
4
- data.tar.gz: 9ce509a5bf89eb8656651a0e4760d20364aadf6f
3
+ metadata.gz: f5f43b66427d2e6c0eb883bdbd2b578f74811b77
4
+ data.tar.gz: 580c64ce7b0aba84d06cc6bd54ccce9e2464bd99
5
5
  SHA512:
6
- metadata.gz: e07d1334ab86f31e9504185d6f181f2cb100fefddb9e952a36a6d025881a4c8f2795e87b2a7282c9ef18646f3ea7b599109b0217865a765fe4ec43af96d73c75
7
- data.tar.gz: 7eebc953508f588ef582c29877a596ade0389ac86e41d0ca27ac9d6ab704854e4ce8af8646705312de8fea38018d890cdae1b14cf275b588686db0ecdc15bd0b
6
+ metadata.gz: f7d5447354b2760ad0340ceeb751392b11c86d5f8ae6bde6270512dbffa2bf90cb480df3d9594895ce3458e0c2f0729b8bd6177f3ca114948472e3efd977c3cf
7
+ data.tar.gz: 5d76f230c083773898e4703995f20fa41830773f1833a53c747c47bd7818cdd3f685f8990c22a5e8faf9b078d7c480a59db3bb92d16be05975bf598e089e2b68
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .idea/
data/.rubocop.yml CHANGED
@@ -3,6 +3,7 @@ AllCops:
3
3
  - 'bin/**/*'
4
4
  - 'spec/**/*'
5
5
  - 'vendor/**/*'
6
+ - 'model_2_factory-rails.gemspec'
6
7
 
7
8
  Metrics/LineLength:
8
9
  Max: 120
@@ -27,3 +28,6 @@ Style/NumericLiterals:
27
28
 
28
29
  Style/Next:
29
30
  Enabled: false
31
+
32
+ Style/FileName:
33
+ Enabled: false
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1 @@
1
+ * **Tanvir Hasan** - check for factory_girl_rails dependency - [tanvir002700](https://github.com/tanvir002700)
data/README.md CHANGED
@@ -1,41 +1,68 @@
1
1
  # model_2_factory-rails
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/model_2_factory-rails.svg)](https://badge.fury.io/rb/model_2_factory-rails)
3
+ [![Gem Version](https://badge.fury.io/rb/model_2_factory-rails.svg)](https://rubygems.org/gems/model_2_factory-rails)
4
+ [![Downloads](https://img.shields.io/gem/dt/model_2_factory-rails.svg)](https://rubygems.org/gems/model_2_factory-rails)
4
5
  [![Build Status](https://travis-ci.org/eendroroy/model_2_factory-rails.svg?branch=master)](https://travis-ci.org/eendroroy/model_2_factory-rails)
5
6
  [![Code Climate](https://codeclimate.com/github/eendroroy/model_2_factory-rails/badges/gpa.svg)](https://codeclimate.com/github/eendroroy/model_2_factory-rails)
7
+ [![Contributors](https://img.shields.io/github/contributors/eendroroy/model_2_factory-rails.svg)](CONTRIBUTORS.md)
6
8
 
7
- ## Installation
9
+
10
+ Factory model class generator for rails model class.
11
+
12
+ ## Description
13
+
14
+ Generate factory model class from rails active record class for rails-rspec test code.
15
+
16
+ ### Prerequisites
17
+
18
+ Require following gem to be included in your gem file:
19
+
20
+ - factory_girl-rails
21
+ ```
22
+ factory_girl-rails
23
+ ```
24
+
25
+ ### Installing
8
26
 
9
27
  Add this line to your application's Gemfile:
10
28
 
11
- ```ruby
12
- gem 'model_2_factory-rails'
13
29
  ```
30
+ gem 'model_2_factory-rails'
14
31
 
32
+ ```
15
33
  And then execute:
16
34
 
17
- $ bundle
35
+ ```
36
+ $ bundle
18
37
 
19
- Or install it yourself as:
38
+ ```
39
+ Or install it globally in your system:
20
40
 
21
- $ gem install model_2_factory-rails
41
+ ```
42
+ $ gem install model_2_factory-rails
43
+
44
+ ```
22
45
 
23
46
  ## Usage
24
47
 
25
- $ bundle exec factory_gen ModelName
48
+ To generate factory class for your existing model class
26
49
 
27
- ## Development
50
+ ```
51
+ $ bundle exec factory_gen your_model_name
52
+ ```
28
53
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+ ## Contributing
30
55
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+ Bug reports and pull requests are welcome on GitHub at [model_2_factory-rails repository](https://github.com/eendroroy/model_2_factory-rails).
57
+ This project is intended to be a safe, welcoming space for collaboration,
58
+ and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
59
 
33
- ## Contributing
60
+ ## Authors
34
61
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/eendroroy/model_2_factory-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
62
+ * **Indrajit Roy** - *Initial work* - [eendroroy](https://github.com/eendroroy)
36
63
 
64
+ See also the list of [contributors](CONTRIBUTORS.md) who participated in this project.
37
65
 
38
66
  ## License
39
67
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
68
+ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
data/exe/factory_gen CHANGED
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require './config/environment.rb'
3
+ if File.exist? File.join(Dir.pwd, 'bin', 'rails')
4
+ require './config/environment.rb'
5
+ require 'model_2_factory-rails'
4
6
 
5
- require 'active_support'
6
- require 'model_2_factory-rails'
7
-
8
- Model2Factory.invoke
7
+ Model2Factory.invoke
8
+ else
9
+ puts "\n'#{`pwd`.strip}' is not a rails application root.\n\n"
10
+ end
@@ -0,0 +1,5 @@
1
+ module Model2Factory
2
+ module Constants
3
+ FACTORY_GIRL_RAILS_MISSING = 'Project does not use dependency factory_girl_rails.'.freeze
4
+ end
5
+ end
@@ -13,6 +13,7 @@ module Model2Factory
13
13
  }.freeze
14
14
 
15
15
  def self.invoke
16
+ warnings_for_dependencies
16
17
  create_factory(ARGV[0].to_s)
17
18
  end
18
19
 
@@ -29,12 +30,17 @@ module Model2Factory
29
30
  exit(1)
30
31
  end
31
32
 
32
- def self.write_to_file(name, lines)
33
- factory = File.open(
33
+ def self.create_factory_file(name)
34
+ File.open(
34
35
  "#{factory_dir}/#{name.underscore.pluralize}_#{factory_suffix}.rb",
35
36
  File::RDWR | File::CREAT | File::TRUNC,
36
37
  0o644
37
38
  )
39
+ end
40
+
41
+ def self.write_to_file(name, lines)
42
+ create_factory_dir(factory_dir)
43
+ factory = create_factory_file(name)
38
44
  factory.write "FactoryGirl.define do\n factory :#{name.underscore} do\n"
39
45
  lines.each do |line|
40
46
  factory.write line
@@ -72,11 +78,21 @@ module Model2Factory
72
78
  end
73
79
  end
74
80
 
81
+ def self.create_factory_dir(dirname)
82
+ FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
83
+ end
84
+
85
+ def self.warnings_for_dependencies
86
+ puts Constants::FACTORY_GIRL_RAILS_MISSING.red unless Gem.loaded_specs.key? 'factory_girl_rails'
87
+ end
88
+
75
89
  class << self
90
+ private :create_factory_dir
76
91
  private :create_factory
77
92
  private :write_to_file
78
93
  private :warn_not_found
79
94
  private :factory_dir
80
95
  private :factory_suffix
96
+ private :warnings_for_dependencies
81
97
  end
82
98
  end
@@ -1,3 +1,3 @@
1
1
  module Model2Factory
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -1,2 +1,3 @@
1
+ require 'model_2_factory/constants'
1
2
  require 'model_2_factory/model_2_factory'
2
3
  require 'model_2_factory/version'
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency :actionpack, version_string
33
33
  spec.add_runtime_dependency :railties, version_string
34
34
 
35
+ spec.add_dependency 'colorize'
36
+
35
37
  spec.add_development_dependency 'bundler', '~> 1.13'
36
38
  spec.add_development_dependency 'rake', '~> 10.0'
37
39
  spec.add_development_dependency 'rspec', '~> 3.0'
data/sideci.yml ADDED
@@ -0,0 +1,5 @@
1
+ linter:
2
+ rubocop:
3
+ options:
4
+ config: './.rubocop.yml'
5
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_2_factory-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - indrajit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-24 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -121,6 +135,7 @@ files:
121
135
  - ".rubocop.yml"
122
136
  - ".travis.yml"
123
137
  - CODE_OF_CONDUCT.md
138
+ - CONTRIBUTORS.md
124
139
  - Gemfile
125
140
  - LICENSE
126
141
  - README.md
@@ -129,9 +144,11 @@ files:
129
144
  - bin/setup
130
145
  - exe/factory_gen
131
146
  - lib/model_2_factory-rails.rb
147
+ - lib/model_2_factory/constants.rb
132
148
  - lib/model_2_factory/model_2_factory.rb
133
149
  - lib/model_2_factory/version.rb
134
150
  - model_2_factory-rails.gemspec
151
+ - sideci.yml
135
152
  homepage: https://github.com/eendroroy/model_2_factory-rails
136
153
  licenses:
137
154
  - MIT