hash2lrtemplate 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/.ruby-version +1 -0
- data/.travis.yml +16 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/hash2lrtemplate.gemspec +32 -0
- data/lib/core_ext/hash.rb +5 -0
- data/lib/core_ext/string.rb +19 -0
- data/lib/hash2lrtemplate.rb +13 -0
- data/lib/hash2lrtemplate/.codeclimate.yml +7 -0
- data/lib/hash2lrtemplate/convertor.rb +33 -0
- data/lib/hash2lrtemplate/extension.rb +15 -0
- data/lib/hash2lrtemplate/json2lrtemplate.rb +41 -0
- data/lib/hash2lrtemplate/version.rb +5 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 11d6058cf516c600abe3be3f5142bfbfa368efd4ff319b055fc2a19e0c9a5bd0
|
4
|
+
data.tar.gz: 21d8ff5ec2e292c06151b9b244db62253fa3dc927fabfea19833d75222c25d75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b20ae2166a171cd34d22d6e93d0a7b0d8c1a438d58aecae2c00e3d9e78ca888258d7f5d3ff4cd0987ec80905c94a338cbcf97e3b62552599ee7c9c00a2d3d526
|
7
|
+
data.tar.gz: 563eea1371e9ac60d6954b84791c51088305e67b8a7f30534cbbe63bf9fb7fbb155d36b649bf4e433a527164396b1d39fbaf3f01ad2b1f9b65e4aec1f09b9810
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
inherit_from: https://raw.githubusercontent.com/laurentzziu/utils/master/gems/.rubocop.yml
|
2
|
+
require:
|
3
|
+
- rubocop-performance
|
4
|
+
- rubocop-rspec
|
5
|
+
RSpec/InstanceVariable:
|
6
|
+
Enabled: false
|
7
|
+
RSpec/BeforeAfterAll:
|
8
|
+
Enabled: false
|
9
|
+
RSpec/NestedGroups:
|
10
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4
|
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
sudo: false
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- CC_TEST_REPORTER_ID=a87699ecde683509adade37fe7021f4a2e7f0844908a3a605fbd01966f7ba098
|
5
|
+
language: ruby
|
6
|
+
rvm:
|
7
|
+
- 2.4.3
|
8
|
+
before_install: gem install bundler -v 1.16.1
|
9
|
+
before_script:
|
10
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
11
|
+
- chmod +x ./cc-test-reporter
|
12
|
+
- ./cc-test-reporter before-build
|
13
|
+
script:
|
14
|
+
- bundle exec rspec
|
15
|
+
after_script:
|
16
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at florin@floringorgan.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hash2lrtemplate (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
callable_class (0.1.1)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
jaro_winkler (1.5.3)
|
13
|
+
parallel (1.17.0)
|
14
|
+
parser (2.6.3.0)
|
15
|
+
ast (~> 2.4.0)
|
16
|
+
rainbow (3.0.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
rspec (3.8.0)
|
19
|
+
rspec-core (~> 3.8.0)
|
20
|
+
rspec-expectations (~> 3.8.0)
|
21
|
+
rspec-mocks (~> 3.8.0)
|
22
|
+
rspec-core (3.8.1)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-expectations (3.8.4)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-mocks (3.8.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-support (3.8.2)
|
31
|
+
rubocop (0.71.0)
|
32
|
+
jaro_winkler (~> 1.5.1)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 2.6)
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
36
|
+
ruby-progressbar (~> 1.7)
|
37
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
38
|
+
rubocop-performance (1.4.0)
|
39
|
+
rubocop (>= 0.71.0)
|
40
|
+
rubocop-rspec (1.33.0)
|
41
|
+
rubocop (>= 0.60.0)
|
42
|
+
ruby-progressbar (1.10.1)
|
43
|
+
unicode-display_width (1.6.0)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
bundler
|
50
|
+
callable_class
|
51
|
+
hash2lrtemplate!
|
52
|
+
rake (~> 10.0)
|
53
|
+
rspec (~> 3.0)
|
54
|
+
rubocop
|
55
|
+
rubocop-performance
|
56
|
+
rubocop-rspec
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Florinel Gorgan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/laurentzziu/hash2lrtemplate.svg?branch=master)](https://travis-ci.org/laurentzziu/hash2lrtemplate)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/hash2lrtemplate.svg)](https://rubygems.org/gems/hash2lrtemplate)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/2b822e7586dae7602550/maintainability)](https://codeclimate.com/github/laurentzziu/hash2lrtemplate/maintainability)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/2b822e7586dae7602550/test_coverage)](https://codeclimate.com/github/laurentzziu/hash2lrtemplate/test_coverage)
|
5
|
+
|
6
|
+
|
7
|
+
# Hash2lrtemplate
|
8
|
+
|
9
|
+
Convert `Hash` objects to strings formatted as `.lrtemplate` (Adobe Lightroom) files.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'hash2lrtemplate'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install hash2lrtemplate
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Call the convertor
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
hash = {
|
33
|
+
s: {
|
34
|
+
id: "635D4B13-0693-458A-9EA3-9B0FE599A2E3",
|
35
|
+
internal_name: "Hash2lrtemplate test demo",
|
36
|
+
title: "Hash2lrtemplate test demo",
|
37
|
+
type: "Develop",
|
38
|
+
value: {
|
39
|
+
uuid: "DA481B09-FABA-4551-A981-08C13F519C07",
|
40
|
+
settings: {
|
41
|
+
Blacks2012: -20,
|
42
|
+
Tint: 10,
|
43
|
+
ConvertToGrayscale: false,
|
44
|
+
CameraProfile: "Adobe Standard",
|
45
|
+
ToneCurvePV2012Red: [0, 0, 57, 40, 144, 147, 196, 206, 255, 255]
|
46
|
+
}
|
47
|
+
},
|
48
|
+
version: 0
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
Hash2lrtemplate::Convertor.new(hash).call
|
53
|
+
# or call the .call method directly on the class
|
54
|
+
Hash2lrtemplate::Convertor.call(hash)
|
55
|
+
# => "s = {id = \"635D4B13-0693-458A-9EA3-9B0FE599A2E3\",internalName = \"Hash2lrtemplate test demo\",title = \"Hash2lrtemplate test demo\",type = \"Develop\",value = {uuid = \"DA481B09-FABA-4551-A981-08C13F519C07\",settings = {Blacks2012 = -20,Tint = 10,ConvertToGrayscale = false,CameraProfile = \"Adobe Standard\",ToneCurvePV2012Red = {0,0,57,40,144,147,196,206,255,255,},},},version = 0,}"
|
56
|
+
```
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/laurentzziu/hash2lrtemplate>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
71
|
+
|
72
|
+
## Code of Conduct
|
73
|
+
|
74
|
+
Everyone interacting in the Hash2lrtemplate project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/laurentzziu/hash2lrtemplate/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hash2lrtemplate"
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'hash2lrtemplate/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'hash2lrtemplate'
|
9
|
+
spec.version = Hash2lrtemplate::VERSION
|
10
|
+
spec.authors = ['Florinel Gorgan']
|
11
|
+
spec.email = ['florin@floringorgan.com']
|
12
|
+
|
13
|
+
spec.summary = %q(Convert Hash objects to .lrtemplate strings.)
|
14
|
+
spec.description = %q{Convert Hash objects to strings formatted as .lrtemplate (Adobe Lightroom) files.}
|
15
|
+
spec.homepage = 'https://github.com/laurentzziu/hash2lrtemplate'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler'
|
26
|
+
spec.add_development_dependency 'callable_class'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
spec.add_development_dependency 'rubocop-performance'
|
31
|
+
spec.add_development_dependency 'rubocop-rspec'
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class String
|
4
|
+
# https://apidock.com/rails/String/camelize
|
5
|
+
def camelize(uppercase_first_letter = true)
|
6
|
+
string = self
|
7
|
+
string = if uppercase_first_letter
|
8
|
+
string.sub(/^[a-z\d]*/) { $&.capitalize }
|
9
|
+
else
|
10
|
+
string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
|
11
|
+
end
|
12
|
+
string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
|
13
|
+
end
|
14
|
+
|
15
|
+
# https://stackoverflow.com/a/27737214
|
16
|
+
def titleize
|
17
|
+
split(' ').map(&:capitalize).join(' ')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'hash2lrtemplate/version'
|
4
|
+
require 'core_ext/string'
|
5
|
+
require 'callable_class'
|
6
|
+
require 'hash2lrtemplate/json2lrtemplate'
|
7
|
+
require 'hash2lrtemplate/convertor'
|
8
|
+
require 'hash2lrtemplate/extension'
|
9
|
+
require 'core_ext/hash'
|
10
|
+
|
11
|
+
module Hash2lrtemplate
|
12
|
+
class Error < StandardError; end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Hash2lrtemplate
|
6
|
+
class Convertor
|
7
|
+
include CallableClass
|
8
|
+
|
9
|
+
attr_reader :hash
|
10
|
+
|
11
|
+
def initialize(hash)
|
12
|
+
raise Hash2lrtemplate::Error, 'Invalid class. Expected class: `Hash`.' unless hash.is_a?(Hash)
|
13
|
+
|
14
|
+
@hash = hash
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Converts the hash to JSON and call {Hash2lrtemplate::JSON2lrtemplate.call}
|
19
|
+
#
|
20
|
+
# @return [String] Converted string
|
21
|
+
#
|
22
|
+
def call
|
23
|
+
convert
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def convert
|
29
|
+
json_string = @hash.to_json
|
30
|
+
Hash2lrtemplate::JSON2lrtemplate.call(json_string)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hash2lrtemplate
|
4
|
+
# This module is meant to be included in the `Hash` class
|
5
|
+
module Extension
|
6
|
+
#
|
7
|
+
# Convert the hash to +.lrtemplate+
|
8
|
+
#
|
9
|
+
# @return [String] Converted string
|
10
|
+
#
|
11
|
+
def to_lrtemplate
|
12
|
+
Hash2lrtemplate::Convertor.call(self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hash2lrtemplate
|
4
|
+
# Transformations:
|
5
|
+
#
|
6
|
+
# - Transform +"keys"+ to +keys+ (remove quotes)
|
7
|
+
# - Transform +[]+ to +{}+
|
8
|
+
# - Transform +:+ to +=+
|
9
|
+
# - Remove leading and ending +{}+
|
10
|
+
# - +,+ before closing +}+
|
11
|
+
class JSON2lrtemplate
|
12
|
+
include CallableClass
|
13
|
+
|
14
|
+
attr_reader :json_string
|
15
|
+
|
16
|
+
def initialize(json_string)
|
17
|
+
raise Hash2lrtemplate::Error, 'Invalid class. Expected class: `String`' unless json_string.is_a?(String)
|
18
|
+
|
19
|
+
@json_string = json_string
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Convert from JSON to +.lrtemplate+ format
|
24
|
+
#
|
25
|
+
# @return [String] Converted string
|
26
|
+
#
|
27
|
+
def call
|
28
|
+
convert
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def convert
|
34
|
+
@json_string.gsub(/"(\w+)"(?=:)/) { |_| $1.camelize(false) }
|
35
|
+
.gsub(/(\[[.\S\s^"]*?\])/) { |_| $1.tr('[]', '{}') }
|
36
|
+
.gsub(':', ' = ')
|
37
|
+
.sub(/\A{/, '').sub(/}\Z/, '')
|
38
|
+
.gsub(/(?<=.)(}){1}(?=.)?/) { |_| ",#{$1}" }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hash2lrtemplate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florinel Gorgan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: callable_class
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Convert Hash objects to strings formatted as .lrtemplate (Adobe Lightroom)
|
112
|
+
files.
|
113
|
+
email:
|
114
|
+
- florin@floringorgan.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".ruby-version"
|
123
|
+
- ".travis.yml"
|
124
|
+
- CODE_OF_CONDUCT.md
|
125
|
+
- Gemfile
|
126
|
+
- Gemfile.lock
|
127
|
+
- LICENSE.txt
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/console
|
131
|
+
- bin/setup
|
132
|
+
- hash2lrtemplate.gemspec
|
133
|
+
- lib/core_ext/hash.rb
|
134
|
+
- lib/core_ext/string.rb
|
135
|
+
- lib/hash2lrtemplate.rb
|
136
|
+
- lib/hash2lrtemplate/.codeclimate.yml
|
137
|
+
- lib/hash2lrtemplate/convertor.rb
|
138
|
+
- lib/hash2lrtemplate/extension.rb
|
139
|
+
- lib/hash2lrtemplate/json2lrtemplate.rb
|
140
|
+
- lib/hash2lrtemplate/version.rb
|
141
|
+
homepage: https://github.com/laurentzziu/hash2lrtemplate
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
metadata: {}
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.7.3
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: Convert Hash objects to .lrtemplate strings.
|
165
|
+
test_files: []
|