Skip to content

Commit

Permalink
Rename to yamlfish
Browse files Browse the repository at this point in the history
  • Loading branch information
Intrepidd committed Feb 18, 2024
1 parent 06195c8 commit 4d34e54
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

# Specify your gem's dependencies in i28s-cli.gemspec
# Specify your gem's dependencies in yamlfish-cli.gemspec
gemspec

gem "rake", "~> 13.0"
Expand Down
35 changes: 25 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
PATH
remote: .
specs:
i28s-cli (0.1.0)
yamlfish (0.1.0.alpha1)
activesupport (>= 6)
faraday (~> 2.0)
thor (~> 1.2)

GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.6)
activesupport (7.1.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
concurrent-ruby (1.2.2)
base64 (0.2.0)
bigdecimal (3.1.6)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
diff-lcs (1.5.0)
faraday (2.7.10)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
drb (2.2.0)
ruby2_keywords
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
i18n (1.14.1)
concurrent-ruby (~> 1.0)
minitest (5.18.1)
minitest (5.22.2)
mutex_m (0.2.0)
net-http (0.4.1)
uri
rake (13.0.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand All @@ -38,17 +51,19 @@ GEM
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
ruby2_keywords (0.0.5)
thor (1.2.2)
thor (1.3.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (0.13.0)

PLATFORMS
x86_64-darwin-21
x86_64-darwin-22

DEPENDENCIES
i28s-cli!
rake (~> 13.0)
rspec (~> 3.0)
yamlfish!

BUNDLED WITH
2.2.32
40 changes: 1 addition & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1 @@
# I28s::Cli

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/i28s/cli`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'i28s-cli'
```

And then execute:

$ bundle install

Or install it yourself as:

$ gem install i28s-cli

## Usage

TODO: Write usage instructions here

## Development

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.

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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/i28s-cli.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
# Yamlfish
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "i28s/cli"
require "yamlfish/cli"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
23 changes: 0 additions & 23 deletions exe/i28s

This file was deleted.

23 changes: 23 additions & 0 deletions exe/yamlfish
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "thor"
require_relative "../lib/yamlfish/cli"

class YamlfishExe < Thor
desc "push", "Pushes translations to yamlfish"
option :branch, type: :string, default: "main"
def push(locale)
Yamlfish::Cli::Push.new(locale, branch: options[:branch]).call
end

desc "pull", "Pulls translations from yamlfish"
option :inplace, type: :boolean, default: false
option :force_update, type: :boolean, default: false
option :branch, type: :string, default: "main"
def pull(locale)
Yamlfish::Cli::Pull.new(locale, inplace: options[:inplace], force_update: options[:force_update], branch: options[:branch]).call
end
end

YamlfishExe.start(ARGV)
10 changes: 5 additions & 5 deletions i28s-cli.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

require_relative "lib/i28s/cli/version"
require_relative "lib/yamlfish/cli/version"

Gem::Specification.new do |spec|
spec.name = "i28s"
spec.version = I28s::Cli::VERSION
spec.name = "yamlfish"
spec.version = Yamlfish::Cli::VERSION
spec.authors = ["Adrien Siami"]
spec.email = ["[email protected]"]

spec.summary = "i28s"
spec.summary = "Easily manage your translations with yamlfish"
# spec.description = "TODO: Write a longer description or delete this line."
spec.homepage = "https://i28s.dev"
spec.homepage = "https://yamlfish.dev"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.6.0"

Expand Down
6 changes: 3 additions & 3 deletions lib/i28s/cli.rb → lib/yamlfish/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_relative "cli/pull"
require "yaml"

module I28s
module Yamlfish
module Cli
class Error < StandardError; end
# Your code goes here...
Expand All @@ -17,11 +17,11 @@ def self.configuration
class Configuration
attr_accessor :api_key, :project_token, :base_url

DEFAULT_BASE_URL = "https://i28s.dev/api/v1"
DEFAULT_BASE_URL = "https://yamlfish.dev/api/v1"

def initialize
configuration = begin
YAML.load_file(File.expand_path(".i28s.yml"))
YAML.load_file(File.expand_path(".yamlfish.yml"))
rescue Errno::ENOENT
{}
end
Expand Down
10 changes: 5 additions & 5 deletions lib/i28s/cli/pull.rb → lib/yamlfish/cli/pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require_relative "../../refinements/dot_flatten"
require_relative "yaml_dumper"

module I28s
module Yamlfish
module Cli
class Pull
using Refinements::DotFlatten
Expand All @@ -19,10 +19,10 @@ def initialize(locale_identifier, inplace: false, force_update: false, branch: "

def call
response = Faraday.get(
"#{I28s::Cli.configuration.base_url}/projects/#{I28s::Cli.configuration.project_token}/#{@branch}/locales/#{@locale_identifier}/export",
"#{Yamlfish::Cli.configuration.base_url}/projects/#{Yamlfish::Cli.configuration.project_token}/#{@branch}/locales/#{@locale_identifier}/export",
{},
{
"Authorization": "Bearer #{I28s::Cli.configuration.api_key}"
"Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
}
)
translations = JSON.parse(response.body)
Expand All @@ -48,12 +48,12 @@ def replace_inplace(translations)
end
end

File.write(filename, I28s::Cli::YamlDumper.dump(file.dot_unflatten)) if update || @force_update
File.write(filename, Yamlfish::Cli::YamlDumper.dump(file.dot_unflatten)) if update || @force_update
end
end

def dump_translations(translations)
File.write("./config/locales/#{@locale_identifier}.yml", I28s::Cli::YamlDumper.dump(translations.dot_unflatten))
File.write("./config/locales/#{@locale_identifier}.yml", Yamlfish::Cli::YamlDumper.dump(translations.dot_unflatten))
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/i28s/cli/push.rb → lib/yamlfish/cli/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "active_support/core_ext/hash/deep_merge"
require "faraday"

module I28s
module Yamlfish
module Cli
class Push
def initialize(locale_identifier, branch: "main")
Expand All @@ -21,10 +21,10 @@ def call
raise "No translations" unless translations&.any?

response = Faraday.post(
"#{I28s::Cli.configuration.base_url}/projects/#{I28s::Cli.configuration.project_token}/#{@branch}/locales/#{@locale_identifier}/import",
"#{Yamlfish::Cli.configuration.base_url}/projects/#{Yamlfish::Cli.configuration.project_token}/#{@branch}/locales/#{@locale_identifier}/import",
{ data: JSON.dump(translations) },
{
"Authorization": "Bearer #{I28s::Cli.configuration.api_key}"
"Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
}
)
puts response.status
Expand Down
2 changes: 1 addition & 1 deletion lib/i28s/cli/version.rb → lib/yamlfish/cli/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module I28s
module Yamlfish
module Cli
VERSION = "0.1.0.alpha1"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module I28s
module Yamlfish
module Cli
class YamlDumper
# We want to dump strings that contain newlines as literal scalars for readability
Expand Down
4 changes: 2 additions & 2 deletions spec/i28s/cli_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

RSpec.describe I28s::Cli do
RSpec.describe Yamlfish::Cli do
it "has a version number" do
expect(I28s::Cli::VERSION).not_to be nil
expect(Yamlfish::Cli::VERSION).not_to be nil
end

it "does something useful" do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "i28s/cli"
require "yamlfish/cli"

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down

0 comments on commit 4d34e54

Please sign in to comment.