garfield 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 772cd4ed0c705a8cd33d25a84d676d5508d55b54
4
+ data.tar.gz: c3a4a55b1612d3d0f2a7ff3a75ab06c993f3155a
5
+ SHA512:
6
+ metadata.gz: dc50c6208f7838c3ff2b598ad9c371af1a90bd37c72337dde11ff2ba3695bceb2b464279f21de7bc9066d44f1cbb7ea27aefb8cbc2b43d94ab231f6655860197
7
+ data.tar.gz: c6f2531f4c57eccf2e35689472e6c79fe3e7d2a842f31f44bca840ff7b16eeb952799edaabbb7b9245941381c9d08232cf77537af7e33ec4ad5fd2b312143d7b
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in garfield.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dave Bush
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Garfield
2
+
3
+ Inspects Ruby environment to generate Guardfile based on installed testrunner.
4
+
5
+ Also works for Python! Currently supports Django, Pytest and Unittest.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'garfield'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install garfield
22
+
23
+ ## Usage
24
+
25
+ garfield generate && guard
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/disavowd/garfield.
30
+
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
35
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "garfield"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'garfield'
4
+
5
+ Garfield::GuardfileGenerator.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'garfield/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "garfield"
8
+ spec.version = Garfield::VERSION
9
+ spec.authors = ["Dave Bush"]
10
+ spec.email = ["github@david-bush.co.uk"]
11
+
12
+ spec.summary = %q{Garfield generates inspects your environment and generates a basic Guardfile.}
13
+ spec.description = %q{Garfield generates a Guardfile based on your dependencies. Also works for Python projects!}
14
+ spec.homepage = "https://github.com/disavowd/garfield"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "bin"
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_dependency('thor')
34
+ end
@@ -0,0 +1,56 @@
1
+ require 'find'
2
+ require 'rubygems'
3
+ require "garfield/version"
4
+ require 'garfield/cli'
5
+
6
+ module Garfield
7
+ def self.get_file_count(extension)
8
+ files = []
9
+ Find.find('.') do |path|
10
+ files << path if path =~ /.*\.#{extension}$/
11
+ end
12
+ return files.length
13
+ end
14
+ def self.get_test_string(extension)
15
+ return extension == 'rb' ? get_ruby_test_string : get_python_test_string
16
+ end
17
+ def self.get_ruby_test_string
18
+ case
19
+ when defined? 'minitest'
20
+ return 'ruby test/*.rb'
21
+ when defined? 'rspec'
22
+ return 'rspec spec'
23
+ when defined? 'rails'
24
+ return 'bundle exec rspec spec'
25
+ else
26
+ installed_gems = Gem::Specification.sort_by{
27
+ |gem| [gem.name.downcase] }.group_by{ |gem| gem.name }
28
+ raise "Couldn't find test runner in #{installed_gems.keys}"
29
+ end
30
+ end
31
+ def self.get_python_test_string
32
+ requirements = 'requirements.txt'
33
+ if File.file?(requirements)
34
+ dependencies = File.read(requirements).downcase.split(/\n+/)
35
+ case
36
+ when dependencies.index {|s| s.include?('django')}
37
+ return 'python manage.py test'
38
+ when dependencies.index {|s| s.include?('pytest')}
39
+ return 'py.test --color=yes -s test'
40
+ else
41
+ return 'python setup.py test'
42
+ end
43
+ end
44
+ return 'python setup.py test'
45
+ end
46
+ def self.write_guardfile(extension, test_string)
47
+ content = %{
48
+ guard :shell do
49
+ watch /.*.#{extension}/ do
50
+ `#{test_string}`
51
+ end
52
+ end
53
+ }
54
+ File.write('Guardfile', content)
55
+ end
56
+ end
@@ -0,0 +1,14 @@
1
+ require 'thor'
2
+
3
+ module Garfield
4
+ class GuardfileGenerator < Thor
5
+ desc 'generate', 'Generates Guardfile'
6
+ def generate()
7
+ extension = Garfield.get_file_count('rb') < Garfield.get_file_count('py') ? 'py' : 'rb'
8
+ puts "Writing Guardfile to monitor #{extension} files..."
9
+ test_string = Garfield.get_test_string(extension)
10
+ Garfield.write_guardfile(extension, test_string)
11
+ puts 'Complete!'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Garfield
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: garfield
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dave Bush
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
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'
69
+ description: Garfield generates a Guardfile based on your dependencies. Also works
70
+ for Python projects!
71
+ email:
72
+ - github@david-bush.co.uk
73
+ executables:
74
+ - console
75
+ - garfield
76
+ - setup
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - ".gitignore"
81
+ - ".rspec"
82
+ - ".travis.yml"
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - bin/garfield
89
+ - bin/setup
90
+ - garfield.gemspec
91
+ - lib/garfield.rb
92
+ - lib/garfield/cli.rb
93
+ - lib/garfield/version.rb
94
+ homepage: https://github.com/disavowd/garfield
95
+ licenses:
96
+ - MIT
97
+ metadata:
98
+ allowed_push_host: https://rubygems.org
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.6
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Garfield generates inspects your environment and generates a basic Guardfile.
119
+ test_files: []