loremGem 0.2.0
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 +7 -0
- data/.gitattributes +14 -0
- data/.gitignore +24 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +37 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +12 -0
- data/LICENSE Bootstrap +21 -0
- data/LICENSE Lorem.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +80 -0
- data/assets/javascript/bootstrap/alert.js +177 -0
- data/assets/javascript/bootstrap/button.js +166 -0
- data/assets/javascript/bootstrap/carousel.js +507 -0
- data/assets/javascript/bootstrap/collapse.js +366 -0
- data/assets/javascript/bootstrap/dropdown.js +488 -0
- data/assets/javascript/bootstrap/modal.js +584 -0
- data/assets/javascript/bootstrap/popover.js +205 -0
- data/assets/javascript/bootstrap/scrollspy.js +318 -0
- data/assets/javascript/bootstrap/tab.js +250 -0
- data/assets/javascript/bootstrap/tooltip.js +673 -0
- data/assets/javascript/bootstrap/util.js +131 -0
- data/assets/javascript/bootstrap-sprockets.js +11 -0
- data/assets/javascript/bootstrap.js +3926 -0
- data/assets/javascript/bootstrap.min.js +6 -0
- data/assets/javascript/lorem.js +24044 -0
- data/assets/stylesheets/_bootstrap-grid.scss +32 -0
- data/assets/stylesheets/_bootstrap-reboot.scss +12 -0
- data/assets/stylesheets/_bootstrap.scss +42 -0
- data/assets/stylesheets/bootstrap/_alert.scss +51 -0
- data/assets/stylesheets/bootstrap/_badge.scss +47 -0
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +41 -0
- data/assets/stylesheets/bootstrap/_button-group.scss +172 -0
- data/assets/stylesheets/bootstrap/_buttons.scss +144 -0
- data/assets/stylesheets/bootstrap/_card.scss +301 -0
- data/assets/stylesheets/bootstrap/_carousel.scss +236 -0
- data/assets/stylesheets/bootstrap/_close.scss +34 -0
- data/assets/stylesheets/bootstrap/_code.scss +48 -0
- data/assets/stylesheets/bootstrap/_custom-forms.scss +421 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +166 -0
- data/assets/stylesheets/bootstrap/_forms.scss +335 -0
- data/assets/stylesheets/bootstrap/_functions.scss +86 -0
- data/assets/stylesheets/bootstrap/_grid.scss +52 -0
- data/assets/stylesheets/bootstrap/_images.scss +42 -0
- data/assets/stylesheets/bootstrap/_input-group.scss +158 -0
- data/assets/stylesheets/bootstrap/_jumbotron.scss +16 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +115 -0
- data/assets/stylesheets/bootstrap/_media.scss +8 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +41 -0
- data/assets/stylesheets/bootstrap/_modal.scss +168 -0
- data/assets/stylesheets/bootstrap/_nav.scss +118 -0
- data/assets/stylesheets/bootstrap/_navbar.scss +299 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +78 -0
- data/assets/stylesheets/bootstrap/_popover.scss +183 -0
- data/assets/stylesheets/bootstrap/_print.scss +141 -0
- data/assets/stylesheets/bootstrap/_progress.scss +34 -0
- data/assets/stylesheets/bootstrap/_reboot.scss +480 -0
- data/assets/stylesheets/bootstrap/_root.scss +19 -0
- data/assets/stylesheets/bootstrap/_tables.scss +188 -0
- data/assets/stylesheets/bootstrap/_tooltip.scss +115 -0
- data/assets/stylesheets/bootstrap/_transitions.scss +22 -0
- data/assets/stylesheets/bootstrap/_type.scss +125 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +15 -0
- data/assets/stylesheets/bootstrap/_variables.scss +929 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +13 -0
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +12 -0
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +35 -0
- data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +5 -0
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +123 -0
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +109 -0
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +66 -0
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_float.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +147 -0
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +45 -0
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +67 -0
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +52 -0
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +37 -0
- data/assets/stylesheets/bootstrap/mixins/_image.scss +36 -0
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_lists.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +22 -0
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +17 -0
- data/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +33 -0
- data/assets/stylesheets/bootstrap/mixins/_size.scss +6 -0
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +30 -0
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +13 -0
- data/assets/stylesheets/bootstrap/mixins/_text-truncate.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +13 -0
- data/assets/stylesheets/bootstrap/mixins/_visibility.scss +7 -0
- data/assets/stylesheets/bootstrap/utilities/_align.scss +8 -0
- data/assets/stylesheets/bootstrap/utilities/_background.scss +19 -0
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +59 -0
- data/assets/stylesheets/bootstrap/utilities/_clearfix.scss +3 -0
- data/assets/stylesheets/bootstrap/utilities/_display.scss +38 -0
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +52 -0
- data/assets/stylesheets/bootstrap/utilities/_flex.scss +51 -0
- data/assets/stylesheets/bootstrap/utilities/_float.scss +9 -0
- data/assets/stylesheets/bootstrap/utilities/_position.scss +37 -0
- data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +11 -0
- data/assets/stylesheets/bootstrap/utilities/_shadows.scss +6 -0
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +12 -0
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +51 -0
- data/assets/stylesheets/bootstrap/utilities/_text.scss +58 -0
- data/assets/stylesheets/bootstrap/utilities/_visibility.scss +11 -0
- data/assets/stylesheets/lorem.css +23980 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/loremGem/engine.rb +12 -0
- data/lib/loremGem/version.rb +4 -0
- data/lib/loremGem.rb +74 -0
- data/loremGem.gemspec +50 -0
- data/tasks/updater/js.rb +68 -0
- data/tasks/updater/logger.rb +57 -0
- data/tasks/updater/network.rb +103 -0
- data/tasks/updater/scss.rb +26 -0
- data/tasks/updater.rb +67 -0
- data/test/dummy_rails/README.rdoc +3 -0
- data/test/dummy_rails/Rakefile +6 -0
- data/test/dummy_rails/app/assets/images/.keep +0 -0
- data/test/dummy_rails/app/assets/javascripts/application.js +7 -0
- data/test/dummy_rails/app/assets/stylesheets/application.sass +4 -0
- data/test/dummy_rails/app/controllers/application_controller.rb +5 -0
- data/test/dummy_rails/app/controllers/pages_controller.rb +4 -0
- data/test/dummy_rails/app/helpers/application_helper.rb +2 -0
- data/test/dummy_rails/app/views/layouts/application.html.erb +14 -0
- data/test/dummy_rails/app/views/pages/root.html.slim +58 -0
- data/test/dummy_rails/config/application.rb +34 -0
- data/test/dummy_rails/config/boot.rb +5 -0
- data/test/dummy_rails/config/environment.rb +5 -0
- data/test/dummy_rails/config/environments/development.rb +23 -0
- data/test/dummy_rails/config/environments/production.rb +82 -0
- data/test/dummy_rails/config/environments/test.rb +38 -0
- data/test/dummy_rails/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy_rails/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy_rails/config/initializers/inflections.rb +16 -0
- data/test/dummy_rails/config/initializers/mime_types.rb +5 -0
- data/test/dummy_rails/config/initializers/secret_token.rb +18 -0
- data/test/dummy_rails/config/initializers/session_store.rb +3 -0
- data/test/dummy_rails/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy_rails/config/locales/en.yml +3 -0
- data/test/dummy_rails/config/locales/es.yml +3 -0
- data/test/dummy_rails/config/routes.rb +3 -0
- data/test/dummy_rails/config.ru +4 -0
- data/test/dummy_rails/log/.keep +0 -0
- data/test/gemfiles/rails_4_2.gemfile +7 -0
- data/test/gemfiles/rails_5_0.gemfile +8 -0
- data/test/gemfiles/rails_5_1.gemfile +8 -0
- data/test/rails_test.rb +24 -0
- data/test/support/dummy_rails_integration.rb +29 -0
- data/test/support/reporting.rb +27 -0
- data/test/test_helper.rb +35 -0
- data/test/test_helper_rails.rb +6 -0
- metadata +480 -0
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "loremGem"
|
|
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,12 @@
|
|
|
1
|
+
require 'autoprefixer-rails'
|
|
2
|
+
module LoremGem
|
|
3
|
+
module Rails
|
|
4
|
+
class Engine < ::Rails::Engine
|
|
5
|
+
initializer 'loremGem.assets' do |app|
|
|
6
|
+
%w(stylesheets javascripts).each do |sub|
|
|
7
|
+
app.config.assets.paths << root.join('assets', sub).to_s
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/loremGem.rb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require "loremGem/version"
|
|
2
|
+
|
|
3
|
+
module LoremGem
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
# Inspired by Kaminari
|
|
7
|
+
def load!
|
|
8
|
+
if rails?
|
|
9
|
+
register_rails_engine
|
|
10
|
+
elsif hanami?
|
|
11
|
+
register_hanami
|
|
12
|
+
elsif sprockets?
|
|
13
|
+
register_sprockets
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
configure_sass
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Paths
|
|
20
|
+
def gem_path
|
|
21
|
+
@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def stylesheets_path
|
|
25
|
+
File.join assets_path, 'stylesheets'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def javascripts_path
|
|
29
|
+
File.join assets_path, 'javascripts'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def assets_path
|
|
33
|
+
@assets_path ||= File.join gem_path, 'assets'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Environment detection helpers
|
|
37
|
+
def sprockets?
|
|
38
|
+
defined?(::Sprockets)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def rails?
|
|
42
|
+
defined?(::Rails)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def hanami?
|
|
46
|
+
defined?(::Hanami)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def configure_sass
|
|
52
|
+
require 'sass'
|
|
53
|
+
|
|
54
|
+
::Sass.load_paths << stylesheets_path
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def register_rails_engine
|
|
58
|
+
require 'LoremGem/engine'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def register_sprockets
|
|
62
|
+
Sprockets.append_path(stylesheets_path)
|
|
63
|
+
Sprockets.append_path(javascripts_path)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def register_hanami
|
|
67
|
+
Hanami::Assets.sources << assets_path
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
LoremGem.load!
|
data/loremGem.gemspec
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'loremGem/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "loremGem"
|
|
8
|
+
spec.version = LoremGem::VERSION
|
|
9
|
+
spec.authors = ["Andrea Crisciotti"]
|
|
10
|
+
spec.email = ["crisciottiandrea@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{This gem is created to the LoremFramework's sistem.}
|
|
13
|
+
spec.description = %q{Unify the web.}
|
|
14
|
+
spec.homepage = "https://github.com/LoremFramework/loremGem"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
spec.add_runtime_dependency 'popper_js', '>= 1.12.9', '< 2'
|
|
19
|
+
|
|
20
|
+
spec.add_runtime_dependency 'sass', '>= 3.5.2'
|
|
21
|
+
spec.add_runtime_dependency 'autoprefixer-rails', '>= 6.0.3'
|
|
22
|
+
|
|
23
|
+
# Testing dependencies
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.8.0'
|
|
27
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.0.5'
|
|
28
|
+
spec.add_development_dependency 'term-ansicolor'
|
|
29
|
+
# Integration testing
|
|
30
|
+
spec.add_development_dependency 'capybara', '>= 2.6.0'
|
|
31
|
+
spec.add_development_dependency 'poltergeist'
|
|
32
|
+
# Dummy Rails app dependencies
|
|
33
|
+
spec.add_development_dependency 'actionpack', '>= 4.1.5'
|
|
34
|
+
spec.add_development_dependency 'activesupport', '>= 4.1.5'
|
|
35
|
+
spec.add_development_dependency 'json', '>= 1.8.1'
|
|
36
|
+
spec.add_development_dependency 'sprockets-rails', '>= 2.3.2'
|
|
37
|
+
spec.add_development_dependency 'jquery-rails', '>= 3.1.0'
|
|
38
|
+
spec.add_development_dependency 'slim-rails'
|
|
39
|
+
spec.add_development_dependency 'uglifier'
|
|
40
|
+
|
|
41
|
+
spec.files = `git ls-files`.split("\n")
|
|
42
|
+
spec.test_files = `git ls-files -- test/*`.split("\n")
|
|
43
|
+
|
|
44
|
+
#spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
45
|
+
spec.bindir = "exe"
|
|
46
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
47
|
+
spec.require_paths = ["lib"]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
end
|
data/tasks/updater/js.rb
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'tsort'
|
|
2
|
+
|
|
3
|
+
class Updater
|
|
4
|
+
module Js
|
|
5
|
+
def update_javascript_assets
|
|
6
|
+
log_status 'Updating javascripts...'
|
|
7
|
+
save_to = @save_to[:js]
|
|
8
|
+
read_files('js/dist', bootstrap_js_files).each do |name, content|
|
|
9
|
+
save_file("#{save_to}/#{name}", remove_source_mapping_url(content))
|
|
10
|
+
end
|
|
11
|
+
log_processed "#{bootstrap_js_files * ' '}"
|
|
12
|
+
|
|
13
|
+
log_status 'Updating javascript manifest'
|
|
14
|
+
manifest = ''
|
|
15
|
+
bootstrap_js_files.each do |name|
|
|
16
|
+
name = name.gsub(/\.js$/, '')
|
|
17
|
+
manifest << "//= require ./LoremGem/#{name}\n"
|
|
18
|
+
end
|
|
19
|
+
dist_js = read_files('dist/js', %w(lorem.js bootstrap.min.js))
|
|
20
|
+
{
|
|
21
|
+
'assets/javascripts/bootstrap-sprockets.js' => manifest,
|
|
22
|
+
'assets/javascripts/lorem.js' => dist_js['lorem.js'],
|
|
23
|
+
'assets/javascripts/bootstrap.min.js' => dist_js['bootstrap.min.js'],
|
|
24
|
+
}.each do |path, content|
|
|
25
|
+
save_file path, remove_source_mapping_url(content)
|
|
26
|
+
log_processed path
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def bootstrap_js_files
|
|
31
|
+
@bootstrap_js_files ||= begin
|
|
32
|
+
src_files = get_paths_by_type('js/src', /\.js$/) - %w[index.js]
|
|
33
|
+
imports = Deps.new
|
|
34
|
+
# Get the imports from the ES6 files to order requires correctly.
|
|
35
|
+
read_files('js/src', src_files).each do |name, content|
|
|
36
|
+
imports.add name,
|
|
37
|
+
*content.scan(%r{import [a-zA-Z]* from '\./(\w+)})
|
|
38
|
+
.flatten(1).map { |f| "#{f}.js" }
|
|
39
|
+
end
|
|
40
|
+
imports.tsort
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def remove_source_mapping_url(content)
|
|
45
|
+
content.sub(%r{^//# sourceMappingURL=.*\n?\z}, '')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Deps
|
|
49
|
+
include TSort
|
|
50
|
+
|
|
51
|
+
def initialize
|
|
52
|
+
@imports = {}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def add(from, *tos)
|
|
56
|
+
(@imports[from] ||= []).push(*tos.sort)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def tsort_each_child(node, &block)
|
|
60
|
+
@imports[node].each(&block)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def tsort_each_node(&block)
|
|
64
|
+
@imports.each_key(&block)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class Updater
|
|
2
|
+
class Logger
|
|
3
|
+
include Term::ANSIColor
|
|
4
|
+
|
|
5
|
+
def log_status(status)
|
|
6
|
+
puts bold status
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def log_file_info(s)
|
|
10
|
+
puts " #{magenta s}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def log_transform(*args, from: caller[1][/`.*'/][1..-2].sub(/^block in /, ''))
|
|
14
|
+
puts " #{cyan from}#{cyan ": #{args * ', '}" unless args.empty?}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def log_processing(name)
|
|
18
|
+
puts yellow " #{File.basename(name)}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def log_processed(name)
|
|
22
|
+
puts green " #{name}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def log_http_get_file(url, cached = false)
|
|
26
|
+
s = " #{'CACHED ' if cached}GET #{url}..."
|
|
27
|
+
if cached
|
|
28
|
+
puts dark green s
|
|
29
|
+
else
|
|
30
|
+
puts dark cyan s
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def log_http_get_files(files, from, cached = false)
|
|
35
|
+
return if files.empty?
|
|
36
|
+
s = " #{'CACHED ' if cached}GET #{files.length} files from #{from} #{files * ' '}..."
|
|
37
|
+
if cached
|
|
38
|
+
puts dark green s
|
|
39
|
+
else
|
|
40
|
+
puts dark cyan s
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def puts(*args)
|
|
45
|
+
STDERR.puts *args unless @silence
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
alias log puts
|
|
49
|
+
|
|
50
|
+
def silence_log
|
|
51
|
+
@silence = true
|
|
52
|
+
yield
|
|
53
|
+
ensure
|
|
54
|
+
@silence = false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'shellwords'
|
|
2
|
+
class Updater
|
|
3
|
+
module Network
|
|
4
|
+
protected
|
|
5
|
+
|
|
6
|
+
WRITE_FILES_MUTEX = Mutex.new
|
|
7
|
+
|
|
8
|
+
def get_paths_by_type(dir, file_re, recursive = true)
|
|
9
|
+
get_file_paths(dir, recursive).select { |path| path =~ file_re }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_file_paths(dir, recursive = true)
|
|
13
|
+
get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def file_url(path)
|
|
17
|
+
"https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def read_files(path, files)
|
|
21
|
+
path_url = file_url path
|
|
22
|
+
contents = read_cached_files(path, files)
|
|
23
|
+
log_http_get_files contents.keys, path_url, true if contents.keys
|
|
24
|
+
files -= contents.keys
|
|
25
|
+
log_http_get_files files, path_url, false
|
|
26
|
+
files.map do |name|
|
|
27
|
+
Thread.start {
|
|
28
|
+
contents[name] = open("#{path_url}/#{name}").read
|
|
29
|
+
WRITE_FILES_MUTEX.synchronize { write_cached_files path, name => contents[name] }
|
|
30
|
+
}
|
|
31
|
+
end.each(&:join)
|
|
32
|
+
contents
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def read_cached_files(path, files)
|
|
36
|
+
full_path = "#@cache_path/#@branch_sha/#{path}"
|
|
37
|
+
contents = {}
|
|
38
|
+
if File.directory?(full_path)
|
|
39
|
+
files.each do |name|
|
|
40
|
+
path = "#{full_path}/#{name}"
|
|
41
|
+
contents[name] = File.read(path, mode: 'rb') if File.exists?(path)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
contents
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def write_cached_files(path, files)
|
|
48
|
+
full_path = "./#@cache_path/#@branch_sha/#{path}"
|
|
49
|
+
files.each do |name, content|
|
|
50
|
+
FileUtils.mkdir_p File.dirname(File.join(full_path, name))
|
|
51
|
+
File.open("#{full_path}/#{name}", 'wb') { |f| f.write content }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def get_file(url)
|
|
57
|
+
uri = URI(url)
|
|
58
|
+
cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
|
|
59
|
+
FileUtils.mkdir_p File.dirname(cache_path)
|
|
60
|
+
if File.exists?(cache_path)
|
|
61
|
+
log_http_get_file url, true
|
|
62
|
+
File.read(cache_path, mode: 'rb')
|
|
63
|
+
else
|
|
64
|
+
log_http_get_file url, false
|
|
65
|
+
content = open(url).read
|
|
66
|
+
File.open(cache_path, 'wb') { |f| f.write content }
|
|
67
|
+
content
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# get sha of the branch (= the latest commit)
|
|
72
|
+
def get_branch_sha
|
|
73
|
+
@branch_sha ||= begin
|
|
74
|
+
if @branch =~ /\A[0-9a-f]{40,}\z/
|
|
75
|
+
@branch
|
|
76
|
+
else
|
|
77
|
+
cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch"
|
|
78
|
+
log cmd
|
|
79
|
+
result = %x[#{cmd}]
|
|
80
|
+
raise 'Could not get branch sha!' unless $?.success? && !result.empty?
|
|
81
|
+
result.split(/\s+/).first
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Get the sha of a dir
|
|
87
|
+
def get_tree_sha(dir, tree = get_trees)
|
|
88
|
+
tree['tree'].find { |t| t['path'] == dir }['sha']
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def get_trees
|
|
92
|
+
@trees ||= get_tree(@branch_sha)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def get_tree(sha, recursive = true)
|
|
96
|
+
get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def get_json(url)
|
|
100
|
+
JSON.parse get_file(url)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class Updater
|
|
2
|
+
module Scss
|
|
3
|
+
def update_scss_assets
|
|
4
|
+
log_status 'Updating scss...'
|
|
5
|
+
save_to = @save_to[:scss]
|
|
6
|
+
contents = {}
|
|
7
|
+
bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/)
|
|
8
|
+
read_files('scss', bootstrap_scss_files).each do |name, file|
|
|
9
|
+
contents[name] = file
|
|
10
|
+
save_file("#{save_to}/#{name}", file)
|
|
11
|
+
end
|
|
12
|
+
log_processed "#{bootstrap_scss_files * ' '}"
|
|
13
|
+
|
|
14
|
+
log_status 'Updating scss main files'
|
|
15
|
+
%w(bootstrap bootstrap-grid bootstrap-reboot).each do |name|
|
|
16
|
+
# Compass treats non-partials as targets to copy into the main project, so make them partials.
|
|
17
|
+
# Also move them up a level to clearly indicate entry points.
|
|
18
|
+
from = "#{save_to}/#{name}.scss"
|
|
19
|
+
to = "#{save_to}/../_#{name}.scss"
|
|
20
|
+
FileUtils.mv from, to
|
|
21
|
+
# As we moved the files, adjust imports accordingly.
|
|
22
|
+
File.write to, File.read(to).gsub(/ "/, ' "LoremGem/')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/tasks/updater.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'strscan'
|
|
6
|
+
require 'forwardable'
|
|
7
|
+
require 'term/ansicolor'
|
|
8
|
+
require 'fileutils'
|
|
9
|
+
|
|
10
|
+
require_relative 'updater/scss'
|
|
11
|
+
require_relative 'updater/js'
|
|
12
|
+
require_relative 'updater/logger'
|
|
13
|
+
require_relative 'updater/network'
|
|
14
|
+
|
|
15
|
+
class Updater
|
|
16
|
+
extend Forwardable
|
|
17
|
+
include Network
|
|
18
|
+
include Js
|
|
19
|
+
include Scss
|
|
20
|
+
|
|
21
|
+
def initialize(repo: 'twbs/bootstrap', branch: 'master', save_to: {}, cache_path: 'tmp/bootstrap-cache')
|
|
22
|
+
@logger = Logger.new
|
|
23
|
+
@repo = repo
|
|
24
|
+
@branch = branch || 'master'
|
|
25
|
+
@branch_sha = get_branch_sha
|
|
26
|
+
@cache_path = cache_path
|
|
27
|
+
@repo_url = "https://github.com/#@repo"
|
|
28
|
+
@save_to = {
|
|
29
|
+
js: 'assets/javascripts/bootstrap',
|
|
30
|
+
scss: 'assets/stylesheets/bootstrap'}.merge(save_to)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def_delegators :@logger, :log, :log_status, :log_processing, :log_transform, :log_file_info, :log_processed, :log_http_get_file, :log_http_get_files, :silence_log
|
|
34
|
+
|
|
35
|
+
def update_bootstrap
|
|
36
|
+
log_status 'Updating Bootstrap'
|
|
37
|
+
puts " repo : #@repo_url"
|
|
38
|
+
puts " branch : #@branch_sha #@repo_url/tree/#@branch"
|
|
39
|
+
puts " save to: #{@save_to.to_json}"
|
|
40
|
+
puts " twbs cache: #{@cache_path}"
|
|
41
|
+
puts '-' * 60
|
|
42
|
+
|
|
43
|
+
FileUtils.rm_rf('assets')
|
|
44
|
+
@save_to.each { |_, v| FileUtils.mkdir_p(v) }
|
|
45
|
+
|
|
46
|
+
update_scss_assets
|
|
47
|
+
update_javascript_assets
|
|
48
|
+
store_version
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def save_file(path, content, mode='w')
|
|
52
|
+
dir = File.dirname(path)
|
|
53
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
|
54
|
+
File.open(path, mode) { |file| file.write(content) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def upstream_version
|
|
58
|
+
@upstream_version ||= get_json(file_url 'package.json')['version']
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Update version.rb file with BOOTSTRAP_SHA
|
|
62
|
+
def store_version
|
|
63
|
+
path = 'lib/LoremGem/version.rb'
|
|
64
|
+
content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][^'"]*['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
|
|
65
|
+
File.open(path, 'w') { |f| f.write(content) }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>bootstrap Dummy App</title>
|
|
5
|
+
<%= stylesheet_link_tag 'application', media: "all", 'data-turbolinks-track' => true %>
|
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<%= yield %>
|
|
12
|
+
</body>
|
|
13
|
+
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
.navbar.navbar-dark.bg-inverse: .container-fluid
|
|
2
|
+
button.navbar-toggler.hidden-sm-up type="button" data-toggle="collapse" data-target="#c1" ☰
|
|
3
|
+
.collapse.navbar-toggleable-xs#c1
|
|
4
|
+
a.navbar-brand href="#" Bootstrap Test Rails App
|
|
5
|
+
ul.nav.navbar-nav
|
|
6
|
+
li.nav-item.active: a.nav-link href="#"
|
|
7
|
+
' Home
|
|
8
|
+
span.sr-only (current)
|
|
9
|
+
li.nav-item: a.nav-link href="#" Link
|
|
10
|
+
li.nav-item.dropdown
|
|
11
|
+
a.nav-link.dropdown-toggle href="#" data-toggle="dropdown" role="button" aria-expanded="false"
|
|
12
|
+
' Dropdown
|
|
13
|
+
span.caret
|
|
14
|
+
.dropdown-menu role="menu"
|
|
15
|
+
a.dropdown-item href="#" Action
|
|
16
|
+
a.dropdown-item href="#" Another action
|
|
17
|
+
a.dropdown-item href="#" Something else here
|
|
18
|
+
a.dropdown-divider
|
|
19
|
+
a.dropdown-item href="#" Separated ank
|
|
20
|
+
a.dropdown-divider
|
|
21
|
+
a.dropdown-item href="#" One more separated link
|
|
22
|
+
|
|
23
|
+
.container
|
|
24
|
+
.card
|
|
25
|
+
.card-header: h3 Dummy App
|
|
26
|
+
.card-block: .row
|
|
27
|
+
.col-sm-3
|
|
28
|
+
h2 3 columns
|
|
29
|
+
.list-group
|
|
30
|
+
a.list-group-item href='#one' One
|
|
31
|
+
a.list-group-item href='#two' Two
|
|
32
|
+
a.list-group-item href='#three' Three
|
|
33
|
+
.col-sm-3
|
|
34
|
+
h2 3 columns
|
|
35
|
+
.btn-group
|
|
36
|
+
button.btn.btn-primary type='button' Button
|
|
37
|
+
button.btn.btn-primary type='button' Button
|
|
38
|
+
table.table
|
|
39
|
+
caption Table
|
|
40
|
+
tr
|
|
41
|
+
td.table-danger Danger!
|
|
42
|
+
td.table-success Success!
|
|
43
|
+
.col-sm-6
|
|
44
|
+
h2 6 columns
|
|
45
|
+
.row
|
|
46
|
+
.col-xs-4.col-xs-push-4: .card: .card-block
|
|
47
|
+
.card-text data-toggle="tooltip" title="hi"
|
|
48
|
+
h6 This is col-xs-4 col-xs-push-4.<br><small>Hover for tooltip.</small>
|
|
49
|
+
|
|
50
|
+
.card: .card-block: form.form-inline
|
|
51
|
+
.form-group
|
|
52
|
+
label.sr-only for="exampleInputEmail2" Email address
|
|
53
|
+
input.form-control#exampleInputEmail2 type="email" placeholder="Enter email"
|
|
54
|
+
.checkbox
|
|
55
|
+
label
|
|
56
|
+
input type="checkbox"
|
|
57
|
+
| Remember me
|
|
58
|
+
button.btn.btn-default type="submit" Sign in
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails'
|
|
4
|
+
|
|
5
|
+
%w(
|
|
6
|
+
action_controller
|
|
7
|
+
action_view
|
|
8
|
+
sprockets
|
|
9
|
+
).each do |framework|
|
|
10
|
+
require "#{framework}/railtie"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'autoprefixer-rails'
|
|
14
|
+
require 'slim-rails'
|
|
15
|
+
require 'uglifier'
|
|
16
|
+
|
|
17
|
+
require 'LoremGem'
|
|
18
|
+
require 'jquery-rails'
|
|
19
|
+
|
|
20
|
+
module Dummy
|
|
21
|
+
class Application < Rails::Application
|
|
22
|
+
config.assets.enabled = true if config.assets.respond_to?(:enabled)
|
|
23
|
+
if Rails::VERSION::MAJOR > 4
|
|
24
|
+
# Rails 4 precompiles application.css|js by default, but future version of Rails do not.
|
|
25
|
+
config.assets.precompile += %w( application.css application.js )
|
|
26
|
+
end
|
|
27
|
+
config.to_prepare do
|
|
28
|
+
if ENV['VERBOSE']
|
|
29
|
+
STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}",
|
|
30
|
+
"Asset paths: #{Rails.application.config.assets.paths}"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|