rails_cleaner 0.0.6

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a71329ca109dfa84d9f3f9381cd4b3549df4fc0
4
+ data.tar.gz: a377f5a3bf12ec67bd0433eda4b1ce026303a5de
5
+ SHA512:
6
+ metadata.gz: 20efec27f303fd4ef1cce91b18ac96edc04259c50723e555ffde4dd6461a7dc07a4da293d4e5db83193dcbd8aabb36a3956ef5d2fcc06bd87778b5ee331f1053
7
+ data.tar.gz: 07130a74f91af4c839c3ca2cdedf6ef7294a7494cbfae634abe25e9feb3a55aedfcc0b3c52ecd8574d2e04b97f4d11331c97b59727e0e29bf0212037c8fab298
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ rails_cleaner-*.gem
11
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.2
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ruby '2.3.0'
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem 'byebug'
9
+ gem 'rspec'
10
+ gem 'rake'
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Michael Harrison
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.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # RailsCleaner
2
+
3
+ [![Stories in Ready](https://badge.waffle.io/harrim91/rails_cleaner.svg?label=ready&title=Ready)](http://waffle.io/harrim91/rails_cleaner)
4
+ [![Gem Version](https://badge.fury.io/rb/rails_cleaner.svg)](https://badge.fury.io/rb/rails_cleaner)
5
+
6
+
7
+ Tracks and deletes any unused auto-generated scss and coffeescript files from your rails project.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'rails_cleaner'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install rails_cleaner
24
+
25
+ ## Usage
26
+
27
+ In your command line:
28
+
29
+ `rails_cleaner_init` creates a `.rails_cleaner` directory in your working directory, containing a `tracked_fies.txt` file.
30
+ `rails_cleaner_track` adds all `.scss` and `.coffee` files in the `app/assets` directory to `tracked_files.txt`
31
+ `rails_cleaner_sort` creates `files_to_delete.txt` in `.rails_cleaner`. This contains all files from `tracked_files.txt` where the created time and last modified times are the same.
32
+ `rails_cleaner_delete` deletes all files listed in `files_to_delete.txt`
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ 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).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/harrim91/rails_cleaner.
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
48
+
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rails_cleaner"
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
data/bin/setup ADDED
@@ -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,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rails_cleaner'
4
+
5
+ rails_cleaner = RailsCleaner.new
6
+
7
+ rails_cleaner.set_files_to_delete RailsCleaner::TO_DELETE_LIST
8
+
9
+ if rails_cleaner.files_to_delete.empty?
10
+ puts 'No files to delete'
11
+ exit
12
+ end
13
+
14
+ puts 'Please select y/n to delete each file'
15
+
16
+ rails_cleaner.files_to_delete.each do |file|
17
+ puts file.colorize :red
18
+ input = gets.chomp
19
+ if input.downcase == 'y'
20
+ File.delete file
21
+ end
22
+ end
23
+
24
+ rails_cleaner.remove_to_delete_list
25
+ rails_cleaner.clear_tracked_files_list
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rails_cleaner'
4
+
5
+ rails_cleaner = RailsCleaner.new
6
+
7
+ rails_cleaner.create_rc_directory
8
+ rails_cleaner.create_rc_file RailsCleaner::TRACKED_FILES_LIST
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rails_cleaner'
4
+
5
+ rails_cleaner = RailsCleaner.new
6
+
7
+ rails_cleaner.set_files_to_delete RailsCleaner::TRACKED_FILES_LIST
8
+ rails_cleaner.write_data_to_file rails_cleaner.files_to_delete, RailsCleaner::TO_DELETE_LIST
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rails_cleaner'
4
+
5
+ rails_cleaner = RailsCleaner.new
6
+
7
+ rails_cleaner.set_tracked_files
8
+ rails_cleaner.write_data_to_file rails_cleaner.tracked_files, RailsCleaner::TRACKED_FILES_LIST
@@ -0,0 +1,56 @@
1
+ require 'rails_cleaner/version'
2
+ require 'colorize'
3
+
4
+ class RailsCleaner
5
+
6
+ DIRECTORY_PATH = '.rails_cleaner/'
7
+ TRACKED_FILES_LIST = 'tracked_files.txt'
8
+ TO_DELETE_LIST = 'files_to_delete.txt'
9
+ ASSETS_PATH = 'app/assets'
10
+
11
+ attr_reader :tracked_files, :files_to_delete
12
+
13
+ def create_rc_directory
14
+ Dir.mkdir DIRECTORY_PATH unless File.exist? DIRECTORY_PATH
15
+ end
16
+
17
+ def create_rc_file filename
18
+ File.open DIRECTORY_PATH + filename, 'w'
19
+ end
20
+
21
+ def set_tracked_files
22
+ @tracked_files = Dir.glob("#{ASSETS_PATH}/**/*").select do |file|
23
+ file.match(/.(scss|coffee)$/)
24
+ end
25
+ end
26
+
27
+ def set_files_to_delete file_path
28
+ @files_to_delete = []
29
+ File.open DIRECTORY_PATH + file_path, 'r' do |file|
30
+ file.each_line do |line|
31
+ @files_to_delete << line.strip if File.ctime(line.strip)==File.birthtime(line.strip)
32
+ end
33
+ end
34
+ end
35
+
36
+ def write_data_to_file data, file
37
+ File.open DIRECTORY_PATH + file, 'w' do |f|
38
+ data.each do |d|
39
+ f.write "#{d}\n"
40
+ end
41
+ end
42
+ end
43
+
44
+ def remove_to_delete_list
45
+ File.delete DIRECTORY_PATH + TO_DELETE_LIST if File.exist? DIRECTORY_PATH + TO_DELETE_LIST
46
+ end
47
+
48
+ def clear_tracked_files_list
49
+ if File.exist? DIRECTORY_PATH + TRACKED_FILES_LIST
50
+ File.open DIRECTORY_PATH + TRACKED_FILES_LIST, 'w' do |file|
51
+ file.truncate 0
52
+ end
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,3 @@
1
+ class RailsCleaner
2
+ VERSION = "0.0.6"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_cleaner/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_cleaner"
8
+ spec.version = RailsCleaner::VERSION
9
+ spec.authors = ["Michael Harrison", "Joseph Chin", "Elia Bardashevich", "Jack Hardy"]
10
+ spec.email = ["harrim91@hotmail.co.uk"]
11
+
12
+ spec.summary = %q{Cleans up unused auto-generated rails templates}
13
+ spec.description = %q{Cleans up unused auto-generated files in the app/assets directory of rails projects}
14
+ spec.homepage = "https://github.com/harrim91/rails_cleaner"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = ["rails_cleaner_init","rails_cleaner_track","rails_cleaner_sort","rails_cleaner_delete"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_runtime_dependency "colorize"
26
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_cleaner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Michael Harrison
8
+ - Joseph Chin
9
+ - Elia Bardashevich
10
+ - Jack Hardy
11
+ autorequire:
12
+ bindir: exe
13
+ cert_chain: []
14
+ date: 2016-06-10 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.12'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.12'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '10.0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '10.0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '3.0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: colorize
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ description: Cleans up unused auto-generated files in the app/assets directory of
73
+ rails projects
74
+ email:
75
+ - harrim91@hotmail.co.uk
76
+ executables:
77
+ - rails_cleaner_init
78
+ - rails_cleaner_track
79
+ - rails_cleaner_sort
80
+ - rails_cleaner_delete
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - ".gitignore"
85
+ - ".rspec"
86
+ - ".travis.yml"
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/console
92
+ - bin/setup
93
+ - exe/rails_cleaner_delete
94
+ - exe/rails_cleaner_init
95
+ - exe/rails_cleaner_sort
96
+ - exe/rails_cleaner_track
97
+ - lib/rails_cleaner.rb
98
+ - lib/rails_cleaner/version.rb
99
+ - rails_cleaner.gemspec
100
+ homepage: https://github.com/harrim91/rails_cleaner
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.5.1
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Cleans up unused auto-generated rails templates
124
+ test_files: []