From 6ca249118c130d489f6c1fb8526cf6d2541b0226 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 27 Sep 2017 15:35:55 +0300 Subject: [PATCH] change name --- .ruby-version | 1 + .travis.yml | 6 +-- Gemfile | 2 +- Gemfile.lock | 22 +++++----- LICENSE | 3 +- README.md | 23 +++++----- lib/rubyx-object-file.rb | 34 +++++++-------- lib/{sof => rx-file}/array_node.rb | 4 +- lib/{sof => rx-file}/hash_node.rb | 4 +- lib/{sof => rx-file}/members.rb | 6 +-- lib/{sof => rx-file}/node.rb | 2 +- lib/{sof => rx-file}/object_node.rb | 2 +- lib/{sof => rx-file}/occurence.rb | 2 +- lib/{sof => rx-file}/simple_node.rb | 2 +- lib/{sof => rx-file}/util.rb | 4 +- lib/{sof => rx-file}/volotile.rb | 4 +- lib/{sof => rx-file}/writer.rb | 46 ++++++++++---------- rubyx-object-file.gemspec => rx-file.gemspec | 4 +- test/helper.rb | 4 +- test/test_basic.rb | 2 +- test/test_ext.rb | 8 ++-- test/test_names.rb | 2 +- test/test_object.rb | 2 +- 23 files changed, 93 insertions(+), 96 deletions(-) create mode 100644 .ruby-version rename lib/{sof => rx-file}/array_node.rb (96%) rename lib/{sof => rx-file}/hash_node.rb (97%) rename lib/{sof => rx-file}/members.rb (97%) rename lib/{sof => rx-file}/node.rb (99%) rename lib/{sof => rx-file}/object_node.rb (99%) rename lib/{sof => rx-file}/occurence.rb (97%) rename lib/{sof => rx-file}/simple_node.rb (98%) rename lib/{sof => rx-file}/util.rb (95%) rename lib/{sof => rx-file}/volotile.rb (91%) rename lib/{sof => rx-file}/writer.rb (76%) rename rubyx-object-file.gemspec => rx-file.gemspec (81%) diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..3f684d2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.3.4 diff --git a/.travis.yml b/.travis.yml index 29cc6fc..6237f3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,5 @@ cache: bundler script: - CODECLIMATE_REPO_TOKEN=40ed7f464af09c892b27adc2cd171c36b24992d8d527428285bc55c46fe2f0e0 ruby test/test_all.rb rvm: - - 1.9.3 - - 2.0.0 - - 2.1.5 - - 2.2.0 + - 2.2.7 + - 2.3.4 diff --git a/Gemfile b/Gemfile index 784f36f..351a420 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "http://rubygems.org" gem "rake" -gem "rubyx-object-file" , :path => "." +gem "rx-file" , :path => "." gem "codeclimate-test-reporter", require: nil diff --git a/Gemfile.lock b/Gemfile.lock index 45d8ac8..9b236b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,22 @@ PATH remote: . specs: - rubyx-object-file (0.3.0) + rx-file (0.3.0) GEM remote: http://rubygems.org/ specs: - codeclimate-test-reporter (0.4.8) - simplecov (>= 0.7.1, < 1.0.0) + codeclimate-test-reporter (1.0.8) + simplecov (<= 0.13) docile (1.1.5) - json (1.8.3) - minitest (5.8.1) - rake (10.4.2) - simplecov (0.10.0) + json (2.1.0) + minitest (5.10.3) + rake (12.1.0) + simplecov (0.13.0) docile (~> 1.1.0) - json (~> 1.8) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.2) PLATFORMS ruby @@ -25,7 +25,7 @@ DEPENDENCIES codeclimate-test-reporter minitest rake - rubyx-object-file! + rx-file! BUNDLED WITH - 1.14.6 + 1.15.4 diff --git a/LICENSE b/LICENSE index af7233a..afa1ff3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 A minimal oo vm that strives for simplicity and clarity +Copyright (c) 2014-7 An object file format Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ 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 index c3fb6ad..5c29e2b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -[![Build Status](https://travis-ci.org/salama/salama-object-file.svg?branch=master)](https://travis-ci.org/salama/salama-object-file) -[![Gem Version](https://badge.fury.io/rb/salama-object-file.svg)](http://badge.fury.io/rb/salama-object-file) -[![Code Climate](https://codeclimate.com/github/salama/salama-object-file/badges/gpa.svg)](https://codeclimate.com/github/salama/salama-object-file) -[![Test Coverage](https://codeclimate.com/github/salama/salama-object-file/badges/coverage.svg)](https://codeclimate.com/github/salama/salama-object-file) +[![Build Status](https://travis-ci.org/rubyx/rx-file.svg?branch=master)](https://travis-ci.org/rubyx/rx-file) +[![Gem Version](https://badge.fury.io/rb/rx-file.svg)](http://badge.fury.io/rb/rx-file) +[![Code Climate](https://codeclimate.com/github/rubyx/rx-file/badges/gpa.svg)](https://codeclimate.com/github/rubyx/rx-file) +[![Test Coverage](https://codeclimate.com/github/rubyx/rx-file/badges/coverage.svg)](https://codeclimate.com/github/rubyx/rx-file) ### Reading the code -Knowing what's going on while coding salama is not so easy: Hence the need to look at code dumps +Knowing what's going on while coding rubyx is not so easy: Hence the need to look at code dumps Hence the need for a code/object file format (remember an oo program is just objects, some data, some code, all objects) @@ -19,7 +19,7 @@ But the "sort of" started to get to me, because - 2) does not allow for (easy) ordering. - 3) has no concept of dumping only parts of an object -To fix this i started on Sof, with an eye to expand it. +To fix this i started on RxFile, with an eye to expand it. The main starting goal was quite like yaml, but with @@ -33,10 +33,10 @@ The main starting goal was quite like yaml, but with The module's main useful api is - Sof::Writer.write(object_to_derialize) + RxFile::Writer.write(object_to_derialize) -### Salama Object File +### Ruby X File Ok, so we all heard about object files, it's the things compilers create so we don't have to have huge compiles and can link them later. @@ -60,13 +60,12 @@ And so this is a little start, just some outputter. #### Direction -The way this is meant to go (planned for 2020+) was a salama core with only a sof parser -(as that is soo much simpler). +The way this is meant to go (planned for 2020+) was a rubyx core with only a rx-filw parser (as that is soo much simpler). Then to_ruby for all the ast classes to be able to roundtrip ruby code. -Then go to storing sof in git, rather than ruby. +Then go to storing rxf in git, rather than ruby. Then write a python/java parser and respective runtime conversion. Extracting common features. With the respective to_python on the ast's to roundtrip that too. -Have to since by now we work on sof's. Etc . .. +Have to since by now we work on rx-file's. Etc . .. diff --git a/lib/rubyx-object-file.rb b/lib/rubyx-object-file.rb index f15f361..23ebbf8 100644 --- a/lib/rubyx-object-file.rb +++ b/lib/rubyx-object-file.rb @@ -2,49 +2,49 @@ # if you want some attributes not written also check volotile -require_relative "sof/util" -require_relative "sof/node" -require_relative "sof/simple_node" -require_relative "sof/object_node" -require_relative "sof/members" -require_relative "sof/volotile" -require_relative "sof/writer" -require_relative "sof/array_node" -require_relative "sof/hash_node" -require_relative "sof/occurence" +require_relative "rx-file/util" +require_relative "rx-file/node" +require_relative "rx-file/simple_node" +require_relative "rx-file/object_node" +require_relative "rx-file/members" +require_relative "rx-file/volotile" +require_relative "rx-file/writer" +require_relative "rx-file/array_node" +require_relative "rx-file/hash_node" +require_relative "rx-file/occurence" Class.class_eval do - def to_sof + def to_rxf self.name end end Symbol.class_eval do - def to_sof() + def to_rxf() ":#{to_s}" end end TrueClass.class_eval do - def to_sof() + def to_rxf() "true" end end NilClass.class_eval do - def to_sof() + def to_rxf() "nil" end end FalseClass.class_eval do - def to_sof() + def to_rxf() "false" end end String.class_eval do - def to_sof() + def to_rxf() "'" + self + "'" end end Fixnum.class_eval do - def to_sof() + def to_rxf() to_s end end diff --git a/lib/sof/array_node.rb b/lib/rx-file/array_node.rb similarity index 96% rename from lib/sof/array_node.rb rename to lib/rx-file/array_node.rb index b015590..9fc7412 100644 --- a/lib/sof/array_node.rb +++ b/lib/rx-file/array_node.rb @@ -1,8 +1,8 @@ -module Sof +module RxFile - # A ArrayNode is a Node for an Array. See Node for when and how nodes are used in Sof. + # A ArrayNode is a Node for an Array. See Node for when and how nodes are used in RxFile. # A ArrayNode has a list of children that hold the value node representations for # the arrays values. # diff --git a/lib/sof/hash_node.rb b/lib/rx-file/hash_node.rb similarity index 97% rename from lib/sof/hash_node.rb rename to lib/rx-file/hash_node.rb index 7129cca..912c605 100644 --- a/lib/sof/hash_node.rb +++ b/lib/rx-file/hash_node.rb @@ -1,5 +1,5 @@ -module Sof - # A HashNode is a Node for a Hash. See Node for when and how nodes are used in Sof. +module RxFile + # A HashNode is a Node for a Hash. See Node for when and how nodes are used in RxFile. # A HashNode has a list of children that hold the key/value node representations for # the hashes keys and values. diff --git a/lib/sof/members.rb b/lib/rx-file/members.rb similarity index 97% rename from lib/sof/members.rb rename to lib/rx-file/members.rb index 4fcd50f..99266e1 100644 --- a/lib/sof/members.rb +++ b/lib/rx-file/members.rb @@ -1,4 +1,4 @@ -module Sof +module RxFile # Members are members of the graph to be written # The class collects all reachable objects into a hash for further transformation @@ -37,8 +37,8 @@ module Sof unless occurence.referenced # puts "referencing #{@counter} #{occurence.object.name}, at level #{level}/#{occurence.level} " if @counter == 23 # puts "referencing #{@counter} #{occurence.object.name}, at level #{level}/#{occurence.level} " if @counter == 19 - if object.respond_to? :sof_reference_name - reference = object.sof_reference_name + if object.respond_to? :rxf_reference_name + reference = object.rxf_reference_name reference = reference.to_s.gsub(/\s|\W/ , "") #remove space and stuff if( @references.include?(reference) or reference.empty?) reference = "#{reference}-#{@counter}" diff --git a/lib/sof/node.rb b/lib/rx-file/node.rb similarity index 99% rename from lib/sof/node.rb rename to lib/rx-file/node.rb index 9d6e28a..d05d199 100644 --- a/lib/sof/node.rb +++ b/lib/rx-file/node.rb @@ -1,6 +1,6 @@ # We transform objects into a tree of nodes -module Sof +module RxFile # Before writing the objects are transformed into a tree of nodes. # as the Members (all objects) are a graph (not tree) this is achieved by referencing diff --git a/lib/sof/object_node.rb b/lib/rx-file/object_node.rb similarity index 99% rename from lib/sof/object_node.rb rename to lib/rx-file/object_node.rb index 4fc82b9..1a5eb10 100644 --- a/lib/sof/object_node.rb +++ b/lib/rx-file/object_node.rb @@ -1,5 +1,5 @@ -module Sof +module RxFile # ObjectNode means node with structure # ie arrays and hashes get transformed into these too, as well as objects with attributes diff --git a/lib/sof/occurence.rb b/lib/rx-file/occurence.rb similarity index 97% rename from lib/sof/occurence.rb rename to lib/rx-file/occurence.rb index a85549f..5b3444a 100644 --- a/lib/sof/occurence.rb +++ b/lib/rx-file/occurence.rb @@ -1,4 +1,4 @@ -module Sof +module RxFile # simple struct like class to wrap an object and hold additionally # - the shallowest level at which it was seen diff --git a/lib/sof/simple_node.rb b/lib/rx-file/simple_node.rb similarity index 98% rename from lib/sof/simple_node.rb rename to lib/rx-file/simple_node.rb index 4389140..a0769b7 100644 --- a/lib/sof/simple_node.rb +++ b/lib/rx-file/simple_node.rb @@ -1,4 +1,4 @@ -module Sof +module RxFile # What makes a node simple is that it has no further structure # diff --git a/lib/sof/util.rb b/lib/rx-file/util.rb similarity index 95% rename from lib/sof/util.rb rename to lib/rx-file/util.rb index 4fe6a08..7d9ce88 100644 --- a/lib/sof/util.rb +++ b/lib/rx-file/util.rb @@ -1,4 +1,4 @@ -module Sof +module RxFile # module for a couple of helpers that are needed in Members and Writer @@ -24,7 +24,7 @@ module Sof # attributes may be supressed with Volotile # TODO should be able to specify order too def attributes_for object - Sof::Util.attributes(object) + RxFile::Util.attributes(object) end # return a list of attributes for a given object diff --git a/lib/sof/volotile.rb b/lib/rx-file/volotile.rb similarity index 91% rename from lib/sof/volotile.rb rename to lib/rx-file/volotile.rb index 7226f20..97916a8 100644 --- a/lib/sof/volotile.rb +++ b/lib/rx-file/volotile.rb @@ -1,4 +1,4 @@ -module Sof +module RxFile # Volotile module keeps track of attributes that are not menat to be written # The idea being similar to private methods. So not every little detail is relevant @@ -9,7 +9,7 @@ module Sof module Volotile @@mapping = { } - # Add attributes that are then ommited from the sof writing process + # Add attributes that are then ommited from the rxf writing process # The clazz is the real class object (eg String), and thus the # adding must happen after the class definition, often at the end of the file # attributes are an array of Symbols diff --git a/lib/sof/writer.rb b/lib/rx-file/writer.rb similarity index 76% rename from lib/sof/writer.rb rename to lib/rx-file/writer.rb index 0c83a59..0c3f942 100644 --- a/lib/sof/writer.rb +++ b/lib/rx-file/writer.rb @@ -1,6 +1,6 @@ -module Sof +module RxFile - # this function writes the object (and all reachable objects) out as sof + # this function writes the object (and all reachable objects) out as rxf # and returns a string # For trees or graphs this works best by handing roots # Internally this is done in three steps: @@ -23,9 +23,9 @@ module Sof end # main function, creates nodes from the occurences and writes the nodes to a string - # returns the sof formatted string for all objects + # returns the rxf formatted string for all objects def write - node = to_sof_node(@members.root , 0) + node = to_rxf_node(@members.root , 0) io = StringIO.new node.out( io , 0 ) io.string @@ -36,10 +36,10 @@ module Sof # from the object we get the Occurence and decide wether a reference node is needed # simple objects (with more inner structure) become SimpleNodes # Any structured object becomes a ObjectNode - # Hash and Array create their own nodes via to_sof_node functions on the classes - def to_sof_node(object , level) + # Hash and Array create their own nodes via to_rxf_node functions on the classes + def to_rxf_node(object , level) if is_value?(object) - return SimpleNode.new(object.to_sof()) + return SimpleNode.new(object.to_rxf()) end occurence = @members.objects[object.object_id] raise "no object #{object}" unless occurence @@ -57,14 +57,14 @@ module Sof ref = occurence.referenced case object.class.name when "Array" , "Parfait::List" - # If a class defines to_sof_node it tells the write that it will generate Nodes itself - # this delegates to array_to_sof_node - array_to_sof_node(object , level , ref ) + # If a class defines to_rxf_node it tells the write that it will generate Nodes itself + # this delegates to array_to_rxf_node + array_to_rxf_node(object , level , ref ) when "Hash" , "Parfait::Dictionary" # and hash keys/values - hash_to_sof_node( object , level , ref) + hash_to_rxf_node( object , level , ref) else - object_to_sof_node(object , level , ref) + object_to_rxf_node(object , level , ref) end end @@ -76,41 +76,41 @@ module Sof # # objects may be derived from array/hash. In that case the ObjectNode gets a super # (either ArrayNode or HashNode) - def object_to_sof_node( object , level , ref) + def object_to_rxf_node( object , level , ref) node = ObjectNode.new(object.class.name , ref) attributes_for(object).each() do |a| val = get_value(object , a) next if val.nil? - node.add( a , to_sof_node( val , level + 1) ) + node.add( a , to_rxf_node( val , level + 1) ) end #TODO get all superclsses here, but this covers 99% so . . moving on superclasses = [object.class.superclass.name] if superclasses.include?( "Array") or superclasses.include?( "Parfait::List") - node.add_super( array_to_sof_node(object , level , ref ) ) + node.add_super( array_to_rxf_node(object , level , ref ) ) end if superclasses.include?( "Hash") or superclasses.include?( "Parfait::Dictionary") - node.add_super( hash_to_sof_node(object , level , ref ) ) + node.add_super( hash_to_rxf_node(object , level , ref ) ) end node end # Creates a ArrayNode (see there) for the Array. # This mainly involves creating nodes for the children - def array_to_sof_node(array , level , ref ) - node = Sof::ArrayNode.new(ref) + def array_to_rxf_node(array , level , ref ) + node = RxFile::ArrayNode.new(ref) array.each do |object| - node.add to_sof_node( object , level + 1) + node.add to_rxf_node( object , level + 1) end node end # Creates a HashNode (see there) for the Hash. # This mainly involves creating nodes for key value pairs - def hash_to_sof_node(hash , level , ref) - node = Sof::HashNode.new(ref) + def hash_to_rxf_node(hash , level , ref) + node = RxFile::HashNode.new(ref) hash.each do |key , object| - k = to_sof_node( key ,level + 1) - v = to_sof_node( object ,level + 1) + k = to_rxf_node( key ,level + 1) + v = to_rxf_node( object ,level + 1) node.add(k , v) end node diff --git a/rubyx-object-file.gemspec b/rx-file.gemspec similarity index 81% rename from rubyx-object-file.gemspec rename to rx-file.gemspec index 0bbaa2c..c74bf7a 100644 --- a/rubyx-object-file.gemspec +++ b/rx-file.gemspec @@ -1,14 +1,14 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = 'rubyx-object-file' + s.name = 'rx-file' s.version = '0.3.0' s.authors = ['Torsten Ruger'] s.email = 'torsten@villataika.fi' s.extra_rdoc_files = ['README.md'] s.files = %w(README.md LICENSE Rakefile) + Dir.glob("lib/**/*") - s.homepage = 'https://github.com/ruby-x/rubyx-object-file' + s.homepage = 'https://github.com/ruby-x/rx-file' s.license = 'MIT' s.require_paths = ['lib'] s.summary = 'Rubyx object file is the object file format of rubyx. It is a sort of condensed yaml' diff --git a/test/helper.rb b/test/helper.rb index 401cc5f..d2e768a 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -13,7 +13,7 @@ require 'rubyx-object-file' module Checker def check should - out = Sof.write(@out) + out = RxFile.write(@out) same = (should == out) puts "Shouldda\n#{out}" unless same assert_equal should , out @@ -28,4 +28,4 @@ class ObjectWithAttributes attr_accessor :extra , :volotile end OBJECT_STRING = "ObjectWithAttributes(:name => 'some name', :number => 1234)" -Sof::Volotile.add(ObjectWithAttributes , [:volotile]) +RxFile::Volotile.add(ObjectWithAttributes , [:volotile]) diff --git a/test/test_basic.rb b/test/test_basic.rb index 3994b9a..5f7c53e 100644 --- a/test/test_basic.rb +++ b/test/test_basic.rb @@ -1,6 +1,6 @@ require_relative "helper" -class BasicSof < MiniTest::Test +class BasicRxFile < MiniTest::Test include Checker def test_true diff --git a/test/test_ext.rb b/test/test_ext.rb index 62a578d..ea8143e 100644 --- a/test/test_ext.rb +++ b/test/test_ext.rb @@ -9,17 +9,17 @@ class FailValue end end class BasicValue < FailValue - def to_sof + def to_rxf "'#{@name}'" end end -class ObjectSof < MiniTest::Test +class ObjectRxFile < MiniTest::Test include Checker - def test_to_sof + def test_to_rxf assert_raises NoMethodError do - Sof::Writer.write(FailValue.new("name")) + RxFile::Writer.write(FailValue.new("name")) end end diff --git a/test/test_names.rb b/test/test_names.rb index 3a69ad7..2da6dd7 100644 --- a/test/test_names.rb +++ b/test/test_names.rb @@ -4,7 +4,7 @@ class NamedRef < ObjectWithAttributes super() @name = name end - def sof_reference_name + def rxf_reference_name @name.to_s end end diff --git a/test/test_object.rb b/test/test_object.rb index 6d79520..c810f34 100644 --- a/test/test_object.rb +++ b/test/test_object.rb @@ -1,6 +1,6 @@ require_relative "helper" -class ObjectSof < MiniTest::Test +class ObjectRxFile < MiniTest::Test include Checker def test_simple_object