change name

This commit is contained in:
Torsten Ruger 2017-09-27 15:35:55 +03:00
parent bf1b3e95bd
commit 6ca249118c
23 changed files with 93 additions and 96 deletions

1
.ruby-version Normal file
View File

@ -0,0 +1 @@
2.3.4

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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 . ..

View File

@ -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

View File

@ -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.
#

View File

@ -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.

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
module Sof
module RxFile
# What makes a node simple is that it has no further structure
#

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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])

View File

@ -1,6 +1,6 @@
require_relative "helper"
class BasicSof < MiniTest::Test
class BasicRxFile < MiniTest::Test
include Checker
def test_true

View File

@ -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

View File

@ -4,7 +4,7 @@ class NamedRef < ObjectWithAttributes
super()
@name = name
end
def sof_reference_name
def rxf_reference_name
@name.to_s
end
end

View File

@ -1,6 +1,6 @@
require_relative "helper"
class ObjectSof < MiniTest::Test
class ObjectRxFile < MiniTest::Test
include Checker
def test_simple_object