diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..42f3dce --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +*.rb diff=ruby +*.gemspec diff=ruby + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5d9c71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +.bundle/ + +pkg/ +.byebug_history + +*.gem diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..8fc4e1e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,122 @@ +AllCops: + TargetRubyVersion: 2.4 + +# frozen_string_literal: true +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: when_needed + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Do not use braces for hash literals when they are the last argument of a +# method call. +Style/BracesAroundHashParameters: + Enabled: true + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +# No extra empty lines. +Layout/EmptyLines: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer {a: :b} over { :a => :b }. +Style/HashSyntax: + Enabled: true + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: normal + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{a: 1}` not `{ a:1 }`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: false + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +# Detect hard tabs, no hard tabs. +Layout/Tab: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingBlankLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: true + +# Use quotes for string literals when they are enough. +Style/UnneededPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Lint/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..55bc983 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.4.1 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..98a4f88 --- /dev/null +++ b/Gemfile @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# Declare your gem"s dependencies in form_core.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..876a5ea --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,44 @@ +PATH + remote: . + specs: + yafl (0.0.1) + +GEM + remote: https://rubygems.org/ + specs: + ast (2.3.0) + coderay (1.1.2) + method_source (0.9.0) + minitest (5.10.3) + parallel (1.12.0) + parser (2.4.0.0) + ast (~> 2.2) + powerpack (0.1.1) + pry (0.11.1) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + rainbow (2.2.2) + rake + rake (12.1.0) + rubocop (0.50.0) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.9.0) + unicode-display_width (1.3.0) + +PLATFORMS + ruby + +DEPENDENCIES + minitest + pry + rake + rubocop + yafl! + +BUNDLED WITH + 1.15.4 diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..7805781 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2017 Jun Jiang + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..69ce627 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +YAFL +==== + +Yet Another Formula Language. + +## Usage + +TODO + +## Installation + +Add this line to your Gemfile: + +```ruby +gem "yafl" +``` + +Or you may want to include the gem directly from GitHub: + +```ruby +gem "yafl", github: "jasl-lab/yafl" +``` + +And then execute: + +```sh +$ bundle +``` + +## Contributing + +Bug report or pull request are welcome. + +### Make a pull request + +1. Fork it +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create new Pull Request + +Please write unit test with your code if necessary. + +## License + +The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..786f61e --- /dev/null +++ b/Rakefile @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +begin + require "bundler/setup" +rescue LoadError + puts "You must `gem install bundler` and `bundle install` to run rake tasks" +end + +require "rdoc/task" + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = "rdoc" + rdoc.title = "YAFL" + rdoc.options << "--line-numbers" + rdoc.rdoc_files.include("README.md") + rdoc.rdoc_files.include("lib/**/*.rb") +end + +require "bundler/gem_tasks" + +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs << "test" + t.pattern = "test/*_test.rb" + t.verbose = false +end + +task :console do + begin + require "pry" + console = Pry + rescue LoadError + require "irb" + require "irb/completion" + console = IRB + end + + require "yafl" + ARGV.clear + console.start +end + +task default: :test diff --git a/lib/yafl.rb b/lib/yafl.rb new file mode 100644 index 0000000..630f034 --- /dev/null +++ b/lib/yafl.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +module YAFL # :nodoc: +end diff --git a/lib/yafl/version.rb b/lib/yafl/version.rb new file mode 100644 index 0000000..e653741 --- /dev/null +++ b/lib/yafl/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module YAFL + VERSION = "0.0.1" +end diff --git a/test/yafl_test.rb b/test/yafl_test.rb new file mode 100644 index 0000000..ac9e080 --- /dev/null +++ b/test/yafl_test.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require "minitest/autorun" +require "yafl" + +class YAFLTest < Minitest::Test + def test_true + assert_equal true, true + end +end diff --git a/yafl.gemspec b/yafl.gemspec new file mode 100644 index 0000000..c2e4a9e --- /dev/null +++ b/yafl.gemspec @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +$LOAD_PATH.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "yafl/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "yafl" + s.version = YAFL::VERSION + s.authors = ["jasl"] + s.email = ["jasl9187@hotmail.com"] + s.homepage = "https://github.com/jasl-lab/yafl" + s.summary = "YAFL - Yet Another Formula Language." + s.description = <<-TEXT.lstrip + YAFL - Yet Another Formula Language + TEXT + s.license = "MIT" + + s.add_development_dependency "pry" + s.add_development_dependency "rake" + s.add_development_dependency "minitest" + s.add_development_dependency "rubocop" + + s.files = Dir["lib/**/*", "MIT-LICENSE", "Rakefile", "README.md"] + s.test_files = Dir["test/*_test.rb"] + s.require_path = "lib" +end