rusic 1.0.0 → 1.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2992ed7dc5c61302612089bd996c7f313eb1e64
4
- data.tar.gz: bda858e42776f4935c28db32feca0414c5cc1ba9
3
+ metadata.gz: 906bf98a81ece30e9e3c56c38dd7cfaa41e949fb
4
+ data.tar.gz: c24e9a824095e62cba7f26dcd350ec95128d3316
5
5
  SHA512:
6
- metadata.gz: 4651c6e49a8129285a3e37158d7f755b0a70a03a113115934052e6803ce21c0fb4c729feeb0c986a8ab43351d960439f01d0f831f3578c7c25370eb93eeccfd3
7
- data.tar.gz: 2c9cdfabe02b89e2287fa2be93a433387072f323c6ab14d35c3e473aa943672912390e887b58e8a4f8ae5d5a561da6b0adee38a4212654036afc060f1e9581f8
6
+ metadata.gz: 5f29976443dd6b7680efbb28a60f3c5d40369f10545f4aff603bbd6b99f2feb5fd6f6b4837d7a164787688c4847488bd2172f92fb2dfd8c092bdf9b7552db9f7
7
+ data.tar.gz: e6ddcbcb09030b21625f94ab77645572e5cd5ec391899ead7251b688a4d798a82e45c23cb3ccc413775207fa27e87ccc41c97d070d68dadda3161efabe158710
data/lib/rusic.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  require 'rusic/version'
2
2
 
3
3
  require 'rest_client'
4
+ require 'command_line_reporter'
4
5
 
5
6
  module Rusic
6
7
  require 'rusic/cli'
7
8
  require 'rusic/deployer'
8
9
  require 'rusic/theme_file'
9
10
  require 'rusic/generators/theme'
11
+ require 'rusic/uploaders/base'
10
12
  require 'rusic/uploaders/asset'
11
13
  require 'rusic/uploaders/editable_asset'
12
14
  require 'rusic/uploaders/template'
data/lib/rusic/cli.rb CHANGED
@@ -24,9 +24,11 @@ module Rusic
24
24
  files.flatten!
25
25
 
26
26
  if options[:watch]
27
- FileWatcher.new(files).watch(0.5) do |file|
28
- deployer = Rusic::Deployer.new(file)
29
- deployer.upload_files(options)
27
+ FileWatcher.new(%w[layouts/ ideas/ pages/ assets/]).watch(0.5) do |file, event|
28
+ unless event == :delete
29
+ deployer = Rusic::Deployer.new(file)
30
+ deployer.upload_files(options)
31
+ end
30
32
  end
31
33
  else
32
34
  deployer = Rusic::Deployer.new(files)
@@ -10,6 +10,14 @@ module Rusic
10
10
  files.each do |file|
11
11
  file.uploader.upload_file(options)
12
12
  end
13
+ rescue RestClient::Unauthorized
14
+ puts
15
+ puts '401 Unauthorized. Ensure your API Key is set correctly.'
16
+ exit(1)
17
+ rescue RestClient::ResourceNotFound
18
+ puts
19
+ puts '404 Not Found. Ensure you are have permission to access the given theme'
20
+ exit(1)
13
21
  end
14
22
  end
15
23
  end
@@ -24,6 +24,10 @@ module Rusic
24
24
  uploader
25
25
  end
26
26
 
27
+ def descriptor
28
+ "#{dirname}/#{filename}"
29
+ end
30
+
27
31
  def dirname
28
32
  pathname.dirname
29
33
  end
@@ -1,20 +1,8 @@
1
1
  module Rusic
2
2
  module Uploaders
3
- class Asset
4
- attr_accessor :file, :api_key, :theme, :api_host
5
-
6
- def initialize(file)
7
- @file = file
8
- end
9
-
10
- def upload_file(options = {})
11
- @api_key = options.fetch('api_key')
12
- @api_host = options.fetch('api_host')
13
- @theme = options.fetch('theme')
14
-
3
+ class Asset < Base
4
+ def perform
15
5
  client["themes/#{theme}/assets/#{file.filename}"].put(params)
16
-
17
- puts "Saved assets/#{file.filename}"
18
6
  end
19
7
 
20
8
  private
@@ -26,15 +14,6 @@ module Rusic
26
14
  def image
27
15
  File.open(file.pathname.to_s, 'rb')
28
16
  end
29
-
30
- def client
31
- headers = {
32
- 'X-API-Key' => api_key,
33
- 'Accept' => 'application/vnd.rusic.v1+json'
34
- }
35
-
36
- @client ||= RestClient::Resource.new("http://#{api_host}", headers: headers)
37
- end
38
17
  end
39
18
  end
40
19
  end
@@ -0,0 +1,43 @@
1
+ module Rusic
2
+ module Uploaders
3
+ class Base
4
+ include CommandLineReporter
5
+
6
+ attr_accessor :file, :api_key, :theme, :api_host
7
+
8
+ def initialize(file)
9
+ @file = file
10
+ end
11
+
12
+ def upload_file(options = {})
13
+ @api_key = options.fetch('api_key')
14
+ @api_host = options.fetch('api_host')
15
+ @theme = options.fetch('theme')
16
+
17
+ report(message: "Uploading #{file.descriptor}", complete: '', type: 'inline', indent_size: 2) do
18
+ begin
19
+ perform
20
+ print(' [done]'.green)
21
+ rescue RestClient::UnprocessableEntity
22
+ print(' [failed]'.red)
23
+ end
24
+ end
25
+ end
26
+
27
+ def perform
28
+ fail NotImplementedError, 'define a #perform method on your uploader'
29
+ end
30
+
31
+ protected
32
+
33
+ def client
34
+ headers = {
35
+ 'X-API-Key' => api_key,
36
+ 'Accept' => 'application/vnd.rusic.v1+json'
37
+ }
38
+
39
+ @client ||= RestClient::Resource.new("http://#{api_host}", headers: headers)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,27 +1,13 @@
1
1
  module Rusic
2
2
  module Uploaders
3
- class EditableAsset
4
- attr_accessor :file, :api_key, :theme, :api_host
5
-
6
- def initialize(file)
7
- @file = file
8
- end
9
-
10
- def upload_file(options = {})
11
- @api_key = options.fetch('api_key')
12
- @api_host = options.fetch('api_host')
13
- @theme = options.fetch('theme')
14
-
3
+ class EditableAsset < Base
4
+ def perform
15
5
  case file.extname
16
6
  when '.css'
17
7
  client["themes/#{theme}/stylesheets/#{file.filename}"].put(params)
18
-
19
8
  when '.js'
20
9
  client["themes/#{theme}/javascripts/#{file.filename}"].put(params)
21
-
22
10
  end
23
-
24
- puts "Saved assets/#{file.filename}"
25
11
  end
26
12
 
27
13
  private
@@ -33,15 +19,6 @@ module Rusic
33
19
  def body
34
20
  File.read(file.pathname.to_s)
35
21
  end
36
-
37
- def client
38
- headers = {
39
- 'X-API-Key' => api_key,
40
- 'Accept' => 'application/vnd.rusic.v1+json'
41
- }
42
-
43
- @client ||= RestClient::Resource.new("http://#{api_host}", headers: headers)
44
- end
45
22
  end
46
23
  end
47
24
  end
@@ -1,20 +1,8 @@
1
1
  module Rusic
2
2
  module Uploaders
3
- class Template
4
- attr_accessor :file, :api_key, :theme, :api_host
5
-
6
- def initialize(file)
7
- @file = file
8
- end
9
-
10
- def upload_file(options = {})
11
- @api_key = options.fetch('api_key')
12
- @api_host = options.fetch('api_host')
13
- @theme = options.fetch('theme')
14
-
3
+ class Template < Base
4
+ def perform
15
5
  client["themes/#{theme}/templates/#{file.dirname}/#{file.filename}"].put(params)
16
-
17
- puts "Saved #{file.dirname}/#{file.filename}"
18
6
  end
19
7
 
20
8
  private
@@ -26,15 +14,6 @@ module Rusic
26
14
  def body
27
15
  File.read(file.pathname.to_s)
28
16
  end
29
-
30
- def client
31
- headers = {
32
- 'X-API-Key' => api_key,
33
- 'Accept' => 'application/vnd.rusic.v1+json'
34
- }
35
-
36
- @client ||= RestClient::Resource.new("http://#{api_host}", headers: headers)
37
- end
38
17
  end
39
18
  end
40
19
  end
data/lib/rusic/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rusic
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0.beta1"
3
3
  end
data/rusic.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency 'thor', '~> 0.14.6'
22
22
  spec.add_runtime_dependency 'rest-client', '~> 1.6'
23
23
  spec.add_runtime_dependency 'filewatcher', '~> 0.3'
24
+ spec.add_runtime_dependency 'command_line_reporter', '~> 3.3'
24
25
 
25
26
  spec.add_development_dependency 'rake', '~> 0.9.0'
26
27
  spec.add_development_dependency 'rspec', '~> 2.6.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rusic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mytton
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: command_line_reporter
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.3'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.3'
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: rake
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +145,7 @@ files:
131
145
  - lib/rusic/templates/pages/about.html.liquid
132
146
  - lib/rusic/theme_file.rb
133
147
  - lib/rusic/uploaders/asset.rb
148
+ - lib/rusic/uploaders/base.rb
134
149
  - lib/rusic/uploaders/editable_asset.rb
135
150
  - lib/rusic/uploaders/template.rb
136
151
  - lib/rusic/version.rb
@@ -150,9 +165,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
165
  version: '0'
151
166
  required_rubygems_version: !ruby/object:Gem::Requirement
152
167
  requirements:
153
- - - ">="
168
+ - - ">"
154
169
  - !ruby/object:Gem::Version
155
- version: '0'
170
+ version: 1.3.1
156
171
  requirements: []
157
172
  rubyforge_project:
158
173
  rubygems_version: 2.2.2