conjoin 0.0.34 → 0.0.35

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b8b9127fdc632e670c731db9eb43b1cc5cf0467
4
- data.tar.gz: 04d29ac8854dfefb515efee206062be1766cde48
3
+ metadata.gz: 16386c064cd75fb529451dcde88625e630de1096
4
+ data.tar.gz: 01b5fc701fc224b5f259ae61e98a4b32f9cd1c90
5
5
  SHA512:
6
- metadata.gz: 70bb59ae96fb3b104992ec5bc0bbf64ed1680db797d6e6bcbd08143a0c369069164cd08dbb51e656a94ea27aba2a04aa705c12004c85665ea899b5202d287746
7
- data.tar.gz: 083e121cec8db74ba539f96931739efecfe195da6d054f5d7462d1a96246626cf64294be050af59b0ac651c29c5317b23281149f3d08a0d9b9730412d05840e5
6
+ metadata.gz: 6f4ac6f704a1427764a145a067155fbf701fe22cad121ef8a3a94c86e4a04c5e8c3cd22f2bd27d0c1712dee37bd8b7274a479c039df1396fbb81e94830c29578
7
+ data.tar.gz: ea9a0f92745a0ede832d56a3ddef14858023ad544fdc0a20f07ebeaa3eb32c84391e0cc177cdfce8f6dffa9cdd5e4414cebb462c76c5175bfab25ecd07e27781
data/bin/conjoin ADDED
@@ -0,0 +1,179 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ARGV.empty?
4
+ puts "usage: conjoin [s (development)] [test]"
5
+ exit
6
+ end
7
+
8
+ ENV['RACK_ENV'] ||= 'development'
9
+
10
+ require 'rubygems'
11
+ require 'bundler/setup'
12
+ require 'clap'
13
+
14
+ module Conjoin
15
+ module CLI
16
+ extend self
17
+
18
+ VERSION = '0.1.0'
19
+
20
+ def version
21
+ say VERSION
22
+ end
23
+
24
+ def help(command)
25
+ # display help
26
+ end
27
+
28
+ def server
29
+ system_with_env 'mr-sparkle'
30
+ end
31
+
32
+ def console
33
+ ENV['CONJOIN_CONSOLE'] = 'true'
34
+ system_with_env "pry -r ./config/console.rb"
35
+ end
36
+
37
+ def tests
38
+ env = ENV['RACK_ENV'] = 'test'
39
+
40
+ Dir["./test/**/*_test.rb"].each_with_index do |file, i|
41
+ if i != 0
42
+ print " \e[90mFile: #{file}"
43
+ else
44
+ print "\n \e[90mFile: #{file}"
45
+ end
46
+
47
+ system_with_env "bin/cutest #{file}"
48
+ end
49
+ end
50
+
51
+ def cutest
52
+ system_with_env "bundle exec cutest #{argv_string}"
53
+ end
54
+
55
+ def rake
56
+ system_with_env "bundle exec rake #{argv_string}"
57
+ end
58
+
59
+ def deploy
60
+ unless %x[git log -1 --pretty=%B][/ran deploy and compiled files/]
61
+
62
+ if %x[git status][/Changes not staged/]
63
+ return puts 'Please commit all changes before deploying.'
64
+ end
65
+
66
+ sha = %x[git rev-parse HEAD].gsub(/\n/, '')
67
+ previous_sha = File.open('sha').read
68
+
69
+ diff = `git diff --name-only #{previous_sha} #{sha}`
70
+
71
+ no_changed_assets = true
72
+
73
+ diff.split(/\n/).each do |d|
74
+ next if d[/^public\/assets/]
75
+ no_changed_assets &= !d[/\.(css|js|styl|scss|less|coffee)$/]
76
+ end
77
+
78
+ if !no_changed_assets
79
+ env = ENV['RACK_ENV']
80
+
81
+ File.foreach ".#{env}.env" do |line|
82
+ key, value = line.split "="
83
+ ENV[key] = value.gsub('\n', '').strip
84
+ end
85
+
86
+ app_path = "#{Dir.pwd}/config/boot.rb"
87
+ file_content = File.open(app_path).read
88
+ require app_path
89
+ javascript = stylesheet = ''
90
+
91
+ app = file_content.match(/(^.*)\.initialize!/).to_a.last.constantize
92
+
93
+ FileUtils.rm_rf('public/assets')
94
+ new_app = app.new
95
+ app.all_assets.to_hash.each do |type, files|
96
+ files.each do |file|
97
+ next unless file.is_a? String
98
+
99
+ file.scan(/(.*)\.(\w*)/).each do |f, ext|
100
+ case type
101
+ when 'stylesheet'
102
+ stylesheet += Conjoin::Assets.add_asset(new_app, f, 'css')
103
+ when 'javascript'
104
+ javascript += Conjoin::Assets.add_asset(new_app, f, 'js')
105
+ end
106
+ end
107
+ end
108
+
109
+ case type
110
+ when 'stylesheet', 'javascript'
111
+ ext = type == 'stylesheet' ? 'css' : 'js'
112
+ path = "public/assets/#{type}-#{sha}.#{ext}"
113
+ tmp_path = "app/assets/#{type}-#{sha}.#{ext}"
114
+ FileUtils.mkdir_p File.dirname(tmp_path)
115
+ FileUtils.mkdir_p File.dirname(path)
116
+ File.write tmp_path, (type == 'stylesheet' ? stylesheet : javascript)
117
+ system "minify #{tmp_path} > #{path}"
118
+ File.delete tmp_path
119
+ end
120
+ end
121
+ File.write('sha', sha)
122
+ system 'git add --all && git commit -am "ran deploy and compiled files."'
123
+ end
124
+ end
125
+
126
+ system argv_string
127
+ end
128
+
129
+ private
130
+
131
+ def argv
132
+ @args ||= begin
133
+ ARGV.shift
134
+ ARGV
135
+ end
136
+
137
+ @args.each_with_index do |arg, i|
138
+ if arg[/\s/]
139
+ @args[i] = '"#{arg}"'
140
+ else
141
+ @args[i] = arg
142
+ end
143
+ end
144
+
145
+ @args
146
+ end
147
+
148
+ def env
149
+ @env ||= ENV['RACK_ENV'] = argv_string.length > 0 ? argv_string : 'development'
150
+ end
151
+
152
+ def argv_string
153
+ argv.join ' '
154
+ end
155
+
156
+ def system_with_env command
157
+ env_file = ".#{env}.env"
158
+ if File.file? env_file
159
+ system "env $(cat #{env_file}) #{command}"
160
+ else
161
+ system command
162
+ end
163
+ end
164
+
165
+ def root
166
+ File.expand_path(File.dirname(__FILE__))
167
+ end
168
+ end
169
+ end
170
+
171
+ Clap.run ARGV,
172
+ "s" => Conjoin::CLI.method(:server),
173
+ "c" => Conjoin::CLI.method(:console),
174
+ "tests" => Conjoin::CLI.method(:test),
175
+ "test" => Conjoin::CLI.method(:cutest),
176
+ "rake" => Conjoin::CLI.method(:rake),
177
+ "deploy" => Conjoin::CLI.method(:deploy),
178
+ "-v" => Conjoin::CLI.method(:version),
179
+ "-h" => Conjoin::CLI.method(:help)
@@ -54,7 +54,7 @@ module Conjoin
54
54
  path = "#{plugin.settings[:path] || '/'}#{cache_string}assets/images/#{file}"
55
55
  end
56
56
  end
57
- "http#{req.env['SERVER_PORT'] == '443' ? 's' : ''}://#{req.env['HTTP_HOST']}#{path}"
57
+ "//#{path}"
58
58
  end
59
59
 
60
60
  def image_tag file, options = {}
@@ -1,3 +1,3 @@
1
1
  module Conjoin
2
- VERSION = "0.0.34"
2
+ VERSION = "0.0.35"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.34
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
@@ -433,7 +433,8 @@ dependencies:
433
433
  description: Still in development
434
434
  email:
435
435
  - cjlazell@gmail.com
436
- executables: []
436
+ executables:
437
+ - conjoin
437
438
  extensions: []
438
439
  extra_rdoc_files: []
439
440
  files:
@@ -442,6 +443,7 @@ files:
442
443
  - LICENSE.txt
443
444
  - README.md
444
445
  - Rakefile
446
+ - bin/conjoin
445
447
  - conjoin.gemspec
446
448
  - lib/conjoin.rb
447
449
  - lib/conjoin/active_record.rb