smock 0.1.7 → 0.1.8
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.
- data/Gemfile.lock +1 -1
- data/bin/smock +5 -0
- data/lib/smock.rb +27 -0
- data/lib/smock/engine.rb +5 -0
- data/lib/smock/generator.rb +82 -0
- data/lib/tasks/install.rake +18 -0
- metadata +10 -4
data/Gemfile.lock
CHANGED
data/bin/smock
ADDED
data/lib/smock.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
3
|
+
|
4
|
+
require "smock/generator"
|
5
|
+
|
6
|
+
unless defined?(Sass)
|
7
|
+
require 'sass'
|
8
|
+
end
|
9
|
+
|
10
|
+
module Smock
|
11
|
+
if defined?(Rails) && defined?(Rails::Engine)
|
12
|
+
class Engine < ::Rails::Engine
|
13
|
+
require 'smock/engine'
|
14
|
+
end
|
15
|
+
|
16
|
+
module Rails
|
17
|
+
class Railtie < ::Rails::Railtie
|
18
|
+
rake_tasks do
|
19
|
+
load "tasks/install.rake"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
smock_path = File.expand_path("../../app/assets/stylesheets", __FILE__)
|
25
|
+
ENV["SASS_PATH"] = [ENV["SASS_PATH"], smock_path].compact.join(File::PATH_SEPARATOR)
|
26
|
+
end
|
27
|
+
end
|
data/lib/smock/engine.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# This code is borrowed shamelessly from Bourbon
|
2
|
+
|
3
|
+
require 'smock/version'
|
4
|
+
require "fileutils"
|
5
|
+
require 'thor'
|
6
|
+
|
7
|
+
module Smock
|
8
|
+
class Generator < Thor
|
9
|
+
map ['-v', '--version'] => :version
|
10
|
+
|
11
|
+
desc 'install', 'Install Smock into your project'
|
12
|
+
method_options :path => :string, :force => :boolean
|
13
|
+
def install
|
14
|
+
if smock_files_already_exist? && !options[:force]
|
15
|
+
puts "Smock files already installed, doing nothing."
|
16
|
+
else
|
17
|
+
install_files
|
18
|
+
puts "Smock files installed to #{install_path}/"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'update', 'Update Smock'
|
23
|
+
method_options :path => :string
|
24
|
+
def update
|
25
|
+
if smock_files_already_exist?
|
26
|
+
remove_smock_directory
|
27
|
+
install_files
|
28
|
+
puts "Smock files updated."
|
29
|
+
else
|
30
|
+
puts "No existing Smock installation. Doing nothing."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'version', 'Show Smock version'
|
35
|
+
def version
|
36
|
+
say "Smock #{Smock::VERSION}"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def smock_files_already_exist?
|
42
|
+
install_path.exist?
|
43
|
+
end
|
44
|
+
|
45
|
+
def install_path
|
46
|
+
@install_path ||= if options[:path]
|
47
|
+
Pathname.new(File.join(options[:path], 'smock'))
|
48
|
+
else
|
49
|
+
Pathname.new('smock')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def install_files
|
54
|
+
make_install_directory
|
55
|
+
copy_in_scss_files
|
56
|
+
end
|
57
|
+
|
58
|
+
def remove_smock_directory
|
59
|
+
FileUtils.rm_rf("smock")
|
60
|
+
end
|
61
|
+
|
62
|
+
def make_install_directory
|
63
|
+
FileUtils.mkdir_p(install_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def copy_in_scss_files
|
67
|
+
FileUtils.cp_r(all_stylesheets, install_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
def all_stylesheets
|
71
|
+
Dir["#{stylesheets_directory}/*"]
|
72
|
+
end
|
73
|
+
|
74
|
+
def stylesheets_directory
|
75
|
+
File.join(top_level_directory, "app", "assets", "stylesheets")
|
76
|
+
end
|
77
|
+
|
78
|
+
def top_level_directory
|
79
|
+
File.dirname(File.dirname(File.dirname(__FILE__)))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "find"
|
3
|
+
|
4
|
+
namespace :smock do
|
5
|
+
desc "Move files to the Rails assets directory."
|
6
|
+
task :install, [:sass_path] do |t, args|
|
7
|
+
args.with_defaults(:sass_path => 'public/stylesheets/sass')
|
8
|
+
source_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
9
|
+
FileUtils.mkdir_p("#{Rails.root}/#{args.sass_path}/smock")
|
10
|
+
FileUtils.cp_r("#{source_root}/app/assets/stylesheets/.", "#{Rails.root}/#{args.sass_path}/smock", { :preserve => true })
|
11
|
+
Find.find("#{Rails.root}/#{args.sass_path}/smock") do |path|
|
12
|
+
if path.end_with?(".css.scss")
|
13
|
+
path_without_css_extension = path.gsub(/\.css\.scss$/, ".scss")
|
14
|
+
FileUtils.mv(path, path_without_css_extension)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -81,7 +81,8 @@ description: ! 'This gem provides the basic styles and files for use in an appli
|
|
81
81
|
'
|
82
82
|
email:
|
83
83
|
- studio.dev@envato.com
|
84
|
-
executables:
|
84
|
+
executables:
|
85
|
+
- smock
|
85
86
|
extensions: []
|
86
87
|
extra_rdoc_files: []
|
87
88
|
files:
|
@@ -207,7 +208,12 @@ files:
|
|
207
208
|
- app/assets/stylesheets/thirdparty/nprogress.css
|
208
209
|
- app/assets/stylesheets/thirdparty/typecsset.scss
|
209
210
|
- app/assets/stylesheets/thirdparty/video-js.css
|
211
|
+
- bin/smock
|
212
|
+
- lib/smock.rb
|
213
|
+
- lib/smock/engine.rb
|
214
|
+
- lib/smock/generator.rb
|
210
215
|
- lib/smock/version.rb
|
216
|
+
- lib/tasks/install.rake
|
211
217
|
- smock.gemspec
|
212
218
|
- v2/_colors.css.sass
|
213
219
|
- v2/_forms.css.sass
|
@@ -249,7 +255,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
255
|
version: '0'
|
250
256
|
segments:
|
251
257
|
- 0
|
252
|
-
hash: -
|
258
|
+
hash: -2956158949193097946
|
253
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
260
|
none: false
|
255
261
|
requirements:
|
@@ -258,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
264
|
version: '0'
|
259
265
|
segments:
|
260
266
|
- 0
|
261
|
-
hash: -
|
267
|
+
hash: -2956158949193097946
|
262
268
|
requirements: []
|
263
269
|
rubyforge_project: smock
|
264
270
|
rubygems_version: 1.8.21
|