rusic 1.9.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -2
- data/Guardfile +60 -6
- data/lib/rusic/uploaders/base.rb +2 -1
- data/lib/rusic/uploaders/custom_attributes.rb +32 -30
- data/lib/rusic/version.rb +1 -1
- data/spec/fixtures/attributes.yml +23 -0
- data/spec/lib/rusic/uploaders/custom_attributes_spec.rb +63 -0
- data/spec/spec_helper.rb +11 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f64e6f298aee830ae7ee989c147de8c5eff2566
|
4
|
+
data.tar.gz: 875d333932c8971d940c38e5296031bb63e0ecc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 306f6076a71c985f5d8388145aa8f96aefa0da4cd3e04c65ec2bccbbb208f5506466f811806d281ccf802329a386cf162cb02109cffdae5a969619d304ff2888
|
7
|
+
data.tar.gz: e09f3dec26d84d00c4e23625166cb6579d3236d0175ad59cd741b89b4abbfcc534536ab4c10da10af72be5bf782f5c83c54093420f5d3783655382c10f14b60c
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,9 +1,63 @@
|
|
1
1
|
require './lib/rusic/version'
|
2
2
|
|
3
|
-
guard :shell do
|
4
|
-
watch(%r{lib/.*}) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
3
|
+
# guard :shell do
|
4
|
+
# watch(%r{lib/.*}) {
|
5
|
+
# `gem build ./rusic.gemspec`
|
6
|
+
# `gem install rusic-#{Rusic::VERSION}.gem`
|
7
|
+
# `rm rusic-#{Rusic::VERSION}.gem`
|
8
|
+
# }
|
9
|
+
# end
|
10
|
+
|
11
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
12
|
+
# rspec may be run, below are examples of the most common uses.
|
13
|
+
# * bundler: 'bundle exec rspec'
|
14
|
+
# * bundler binstubs: 'bin/rspec'
|
15
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
16
|
+
# installed the spring binstubs per the docs)
|
17
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
18
|
+
# * 'just' rspec: 'rspec'
|
19
|
+
|
20
|
+
guard :rspec, cmd: 'rspec --color --format doc' do
|
21
|
+
require "guard/rspec/dsl"
|
22
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
23
|
+
|
24
|
+
# Feel free to open issues for suggestions and improvements
|
25
|
+
|
26
|
+
# RSpec files
|
27
|
+
rspec = dsl.rspec
|
28
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
29
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
30
|
+
watch(rspec.spec_files)
|
31
|
+
|
32
|
+
# Ruby files
|
33
|
+
ruby = dsl.ruby
|
34
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
35
|
+
|
36
|
+
# Rails files
|
37
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
38
|
+
dsl.watch_spec_files_for(rails.app_files)
|
39
|
+
dsl.watch_spec_files_for(rails.views)
|
40
|
+
|
41
|
+
watch(rails.controllers) do |m|
|
42
|
+
[
|
43
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
44
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
45
|
+
rspec.spec.("acceptance/#{m[1]}")
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
# Rails config changes
|
50
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
51
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
52
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
53
|
+
|
54
|
+
# Capybara features specs
|
55
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
56
|
+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
|
57
|
+
|
58
|
+
# Turnip features and steps
|
59
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
60
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
61
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
62
|
+
end
|
9
63
|
end
|
data/lib/rusic/uploaders/base.rb
CHANGED
@@ -1,48 +1,50 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'awesome_print'
|
3
|
+
|
1
4
|
module Rusic
|
2
5
|
module Uploaders
|
3
6
|
class CustomAttributes < Base
|
4
7
|
def perform
|
5
|
-
client["themes/#{theme}"].
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def message
|
11
|
-
"Updating custom attributes"
|
8
|
+
client["themes/#{theme}/custom_attribute_collections"].post(params.to_json, content_type: :json)
|
12
9
|
end
|
13
10
|
|
14
11
|
def params
|
15
|
-
|
16
|
-
|
17
|
-
'custom_attributes_attributes' => {}
|
18
|
-
}
|
12
|
+
parameters = {
|
13
|
+
custom_attribute_collections: []
|
19
14
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
attribute_collections.each do |attribute_collection_key, attribute_collection|
|
16
|
+
custom_attribute_collection = {
|
17
|
+
key: attribute_collection_key,
|
18
|
+
title: attribute_collection["title"],
|
19
|
+
help_title: attribute_collection.fetch('help_title', nil),
|
20
|
+
help_body: attribute_collection.fetch('help_body', nil),
|
21
|
+
custom_attributes: [],
|
27
22
|
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
attribute_collection["attributes"].each do |attribute_key, attribute|
|
24
|
+
custom_attribute_collection[:custom_attributes] << {
|
25
|
+
'key' => attribute_key,
|
26
|
+
'value' => attribute.fetch('value'),
|
27
|
+
'help_text' => attribute.fetch('help_text', ''),
|
28
|
+
'input_type' => attribute.fetch('type', 'string'),
|
29
|
+
'select_options' => attribute.fetch('select_options', nil),
|
30
|
+
}
|
35
31
|
end
|
32
|
+
parameters[:custom_attribute_collections] << custom_attribute_collection
|
36
33
|
end
|
37
|
-
|
34
|
+
parameters
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def message
|
40
|
+
"Updating custom attributes"
|
38
41
|
end
|
39
42
|
|
40
|
-
def
|
41
|
-
|
42
|
-
Hash[@existing_attributes.fetch('custom_attributes', []).map {|i| [i['key'], i] }]
|
43
|
+
def attribute_collections
|
44
|
+
attributes_file["custom_attribute_collections"]
|
43
45
|
end
|
44
46
|
|
45
|
-
def
|
47
|
+
def attributes_file
|
46
48
|
::YAML::load_file(file.file) || {}
|
47
49
|
end
|
48
50
|
end
|
data/lib/rusic/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
custom_attribute_collections:
|
2
|
+
awesome_group:
|
3
|
+
title: Awesome Group Title
|
4
|
+
help_title: Do something awesome
|
5
|
+
help_body: Here is some help to being awesome
|
6
|
+
attributes:
|
7
|
+
some_nested_text_1:
|
8
|
+
value: Example
|
9
|
+
help_text: Example Help Text
|
10
|
+
some_other_text_1:
|
11
|
+
value: Example
|
12
|
+
help_text: Example Help Text
|
13
|
+
ok_group:
|
14
|
+
title: OK Group Title
|
15
|
+
help_title: Do something average
|
16
|
+
help_body: Here is some help to being alright
|
17
|
+
attributes:
|
18
|
+
some_nested_text_2:
|
19
|
+
value: Example2
|
20
|
+
help_text: Example Help Text
|
21
|
+
some_other_text_2:
|
22
|
+
value: Example2
|
23
|
+
help_text: Example Help Text
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Rusic::Uploaders::CustomAttributes do
|
4
|
+
before do
|
5
|
+
@custom_attributes_uploader = Rusic::Uploaders::CustomAttributes.new(nil)
|
6
|
+
|
7
|
+
allow(@custom_attributes_uploader).to receive(:attributes_file) {
|
8
|
+
attributes_file = File.join(File.dirname(__FILE__), '..', '..', '..', 'fixtures', 'attributes.yml')
|
9
|
+
YAML.load(File.open(attributes_file))
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns params" do
|
14
|
+
expect(@custom_attributes_uploader.params).to eq({
|
15
|
+
custom_attribute_collections: [
|
16
|
+
{
|
17
|
+
key: "awesome_group",
|
18
|
+
title: "Awesome Group Title",
|
19
|
+
help_title: "Do something awesome",
|
20
|
+
help_body: "Here is some help to being awesome",
|
21
|
+
custom_attributes: [
|
22
|
+
{
|
23
|
+
"key" => "some_nested_text_1",
|
24
|
+
"value" => "Example",
|
25
|
+
"help_text" => "Example Help Text",
|
26
|
+
"input_type" => "text",
|
27
|
+
"select_options" => nil
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"key" => "some_other_text_1",
|
31
|
+
"value" => "Example",
|
32
|
+
"help_text" => "Example Help Text",
|
33
|
+
"input_type" => "text",
|
34
|
+
"select_options" => nil
|
35
|
+
}
|
36
|
+
]
|
37
|
+
},
|
38
|
+
{
|
39
|
+
key: "ok_group",
|
40
|
+
title: "OK Group Title",
|
41
|
+
help_title: "Do something average",
|
42
|
+
help_body: "Here is some help to being alright",
|
43
|
+
custom_attributes: [
|
44
|
+
{
|
45
|
+
"key" => "some_nested_text_2",
|
46
|
+
"value" => "Example2",
|
47
|
+
"help_text" => "Example Help Text",
|
48
|
+
"input_type" => "text",
|
49
|
+
"select_options" => nil
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"key" => "some_other_text_2",
|
53
|
+
"value" => "Example2",
|
54
|
+
"help_text" => "Example Help Text",
|
55
|
+
"input_type" => "text",
|
56
|
+
"select_options" => nil
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
]
|
61
|
+
})
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rusic'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
end
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Mytton
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|
@@ -129,6 +129,9 @@ files:
|
|
129
129
|
- lib/rusic/uploaders/template.rb
|
130
130
|
- lib/rusic/version.rb
|
131
131
|
- rusic.gemspec
|
132
|
+
- spec/fixtures/attributes.yml
|
133
|
+
- spec/lib/rusic/uploaders/custom_attributes_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
132
135
|
homepage: http://developer.rusic.com/
|
133
136
|
licenses:
|
134
137
|
- MIT
|
@@ -153,4 +156,7 @@ rubygems_version: 2.4.4
|
|
153
156
|
signing_key:
|
154
157
|
specification_version: 4
|
155
158
|
summary: Generate and deploy themes to Rusic
|
156
|
-
test_files:
|
159
|
+
test_files:
|
160
|
+
- spec/fixtures/attributes.yml
|
161
|
+
- spec/lib/rusic/uploaders/custom_attributes_spec.rb
|
162
|
+
- spec/spec_helper.rb
|