Skip to content

Refactoring to ease the way we define generated code #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 157 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
d08c5fa
ADD First test on getHeaderDescriptionString
netbe Oct 13, 2013
000025f
Refactor code to use must ache templates
netbe Oct 13, 2013
58e37e3
Refactor getSourceDescriptionString
netbe Oct 13, 2013
eb2342d
Update ignored files: default output folder
netbe Oct 13, 2013
66b0a4f
ADD tests on make function for Objc
netbe Oct 13, 2013
589b6fc
[WIP] ADD test for generated header
netbe Oct 22, 2013
63f90de
Extract functions to write files out of the make function
netbe Nov 1, 2013
aea218a
Refactor content of human header file
netbe Nov 1, 2013
206bd84
Refactor human source file
netbe Nov 1, 2013
f2dd295
Cleanup make function, move creating machine source file to its own f…
netbe Nov 1, 2013
5eb3fda
start using python naming convention
netbe Nov 1, 2013
be69c1e
rename function to match responsibility
netbe Nov 1, 2013
7e3751e
Rename generateHumanHeaderFile() to human_header_content()
netbe Nov 1, 2013
fb39c4c
Rename generateHumanSourceFile() to human_source_content()
netbe Nov 1, 2013
25661e8
Rename generateSourceFile() to machine_Source_content()
netbe Nov 1, 2013
937d4b7
Removed unused functions
netbe Nov 1, 2013
fb3ba3f
Moved includeHeaders to template for machineSourceFile
netbe Nov 1, 2013
939fc4b
Moving all code source generation of machine code to template
netbe Nov 1, 2013
e659804
ADD output files of test.json sample
netbe Nov 1, 2013
7d6b3c2
Cleanup test on test_class.json for obj-c
netbe Nov 1, 2013
7173371
ADD dump object for test.json
netbe Nov 2, 2013
1aabcfb
Refactor tests to reuse for test.json
netbe Nov 2, 2013
89924c2
add notes about development
Apr 15, 2014
63ea444
add requirements for development
Apr 15, 2014
8195cb9
add sample test for mustache
Apr 15, 2014
15d2321
update template and test
Apr 16, 2014
1fd6cd0
add handling methods
Apr 16, 2014
e273e2d
Merge branch 'feature/refactor' of https://github.com/sinnerschrader-…
Apr 16, 2014
22aa920
Fixes all tests
Apr 16, 2014
5338115
Merge branch 'feature/refactor' of github.com:sinnerschrader-mobile/m…
Apr 16, 2014
5460273
Start to process template with different kind of properties
Apr 16, 2014
e525e5c
indentations
Apr 16, 2014
b5c620f
add more
Apr 16, 2014
fe037d7
add new methods
Apr 16, 2014
ef8886e
machine file template passes test
Apr 16, 2014
11462ef
header template has now properties
Apr 16, 2014
db8e2ea
remove call to propertyDefinitionString
Apr 16, 2014
aa6cf15
add templates for humanClass
Apr 16, 2014
8e462ef
Merge branch 'feature/refactor' of https://github.com/sinnerschrader-…
Apr 16, 2014
62af7fa
add new test case for string options and regexp
Apr 16, 2014
1c02c76
add notes for development and testing
Apr 16, 2014
5486fcf
Fixes TestSampleTestStringOptionsCase.test_machine_header_content test
Apr 16, 2014
52800d4
adjust spaces of generated file
Apr 16, 2014
5c64913
Supports maxLength, minLength, regex options
Apr 16, 2014
ca83933
acceptNumber is NO for string type by default.
Apr 16, 2014
57e1946
Merge branch 'feature/refactor' of github.com:sinnerschrader-mobile/m…
Apr 16, 2014
c22000a
Fixes space in header
Apr 16, 2014
5922e3e
add new extension to human file
Apr 16, 2014
994571b
Fixes project Prefix
Apr 16, 2014
de8d70d
add new test case for subclasses
Apr 16, 2014
3e1ca31
Fixes new tests case subclass
Apr 17, 2014
3624a8f
Fixes properties name in header when using a protected name
Apr 17, 2014
e529c1f
Fixes protected name, i.e 'id' without projectPrefix
Apr 17, 2014
88a6cfd
Fixes subclass expected generated file
Apr 17, 2014
ab21fae
Fixes subclass test case
Apr 17, 2014
82045c3
remove unused testcase files
Apr 17, 2014
ad07b47
add new testCase data
Apr 17, 2014
c740525
rename test methods for subclass testcase
Apr 17, 2014
3c89c9c
testcase for property types
Apr 17, 2014
8515089
Start handling array properties
Apr 22, 2014
24bb719
Support date, boolean, data types in machine source file
Apr 22, 2014
b6e1fdf
Support init method and getter for array property
Apr 22, 2014
8f8f78e
don't need temporary array for known types
Apr 22, 2014
83e7b80
add new test case at the readJSON level with product.json sample
Apr 23, 2014
6456b8e
Fixes product.json syntax
Apr 23, 2014
80595e2
Fixes readJSON_test
Apr 23, 2014
eb73f49
Fixes human file expected output
Apr 23, 2014
aef3036
Diff all files
Apr 23, 2014
7f21ea8
Fixes crash on type 'any'
Apr 23, 2014
36bc7ab
support for objectProperties
Apr 23, 2014
a1ef19d
Reorder json properties to match expected output
Apr 23, 2014
fad7f2f
Fixes Objc tests
Apr 23, 2014
9634dee
Testing ProductDetailsJSONObject.h file
Apr 23, 2014
6d65375
making test pass
Apr 23, 2014
701d4b2
Fixes array property again
Apr 23, 2014
23f8679
WIP dealing with @class definition for properties
May 9, 2014
2970fa9
Remove old methods
May 12, 2014
9d1f94d
Fixes @class header definitions
May 12, 2014
fdd4de2
Fixes generation of custom methods for array
May 12, 2014
02365ca
make current tests pass
May 12, 2014
b671152
all headers for product sample pass the tests
May 12, 2014
856fa13
making tests pass for machine files
May 12, 2014
d34fa34
make tests pass for senderList2
May 12, 2014
a9930ad
update expected file with new template syntax
May 12, 2014
8b7e0fa
handling min/maxCount and min/maxValue attributes
May 12, 2014
27ee205
missing methods for array in implementation file
May 12, 2014
6e0a0eb
hasAnyType method for array
May 12, 2014
47461a4
handle string validation in custom method
May 12, 2014
fc410fe
Fixes minor syntax expectations
May 12, 2014
bb8d85d
handling custom methods for undefinedProperties
May 12, 2014
7c57cf6
multiple base-type properties implementation
May 12, 2014
79eba63
Fixes some failing tests
May 12, 2014
42847f4
[WIP] Dealing with custom primitive types
May 12, 2014
432db4c
add travis ci config
May 12, 2014
2c7ab43
external classes are listed under custom_classes
May 13, 2014
474b668
Fixes missing custom method definition
May 13, 2014
c88e57c
Fixing ordering methods expectation
May 13, 2014
6205209
trying to fix print statement on 3.X version
May 13, 2014
9422bea
remove extra unused files
May 13, 2014
2ac8961
open class per file, TemplateCodeGenerator has its own file
May 13, 2014
4a77992
Fixing breaking syntax on python 3.X
May 13, 2014
b0e4d76
Disable support of newer python versions
May 13, 2014
3aa870c
reorganise files into package
May 13, 2014
906f7ad
add files to run metajson as a script
May 13, 2014
1569eba
update readJSON with main method
May 13, 2014
d25b554
move templates inside package
May 13, 2014
a1fd32c
Fixes running readJSON_test
May 13, 2014
9985a56
trim white space
May 13, 2014
a2cbe96
modify definition of JSONScheme to metajson.JSONScheme
May 13, 2014
65ca094
change location of test_data to test/data
May 13, 2014
cd9ca08
fixing last templates issues and enable all tests
May 13, 2014
54957a1
Update setup.py to install metajson
May 13, 2014
b847d1c
ignore build folder
May 13, 2014
238fe2a
move doc files to wiki
May 13, 2014
48032e8
Create template_keys.csv
netbe May 14, 2014
f8548a2
Update template_keys.csv
netbe May 14, 2014
4293c3c
move requirements to setup
May 14, 2014
e29af8a
Templates are now included in install process
May 14, 2014
7b1c5ff
ignore generated files
May 14, 2014
6953994
restore requirements file for testing and development (pip)
May 14, 2014
630bdaf
Merge branch 'feature/refactor' of github.com:sinnerschrader-mobile/m…
May 14, 2014
d060af0
update default params and add version option
May 14, 2014
0fe2d42
reset version to next release 1.0.0
May 14, 2014
f6b646e
refactor script to be more readable
May 14, 2014
ccfa3e1
support yaml as input file
May 14, 2014
3f3706b
make sure yaml support outputs the same as json
May 14, 2014
4232371
read_template folder
May 15, 2014
514ff24
refactor generation of apiparser template code
May 15, 2014
194d42a
ignore default generation folders
May 15, 2014
2f95bb7
reorder fucntions
May 15, 2014
16eac92
update template copy
May 15, 2014
f50f555
move template for iOS in iOS folder
May 15, 2014
2700d35
template subdirectories are respected
May 15, 2014
b8ed095
remove writing from objectiveCCodeGenerator
May 15, 2014
d4e8493
avoid order of files in tests
May 16, 2014
a06203f
add extra info to version. devel version shows git revision
May 16, 2014
cedad0f
clean options for command usage
May 16, 2014
2ad6f26
update README
May 16, 2014
c0cee17
change 'comment' template key to 'description'
May 20, 2014
afaad91
Typo fixes
May 20, 2014
edba73c
uniform variableName and varName
May 20, 2014
2748fb4
replace {{capitalizeVarName}} by {{#_upper_camelcase}}{{varName}}{{/_…
May 20, 2014
5549b4b
remove sub key value for min/maxLength,min/maxValue, min/maxCount, regex
May 20, 2014
3af890a
projectPrefix becomes prefix
May 20, 2014
587648c
remove template keys csv, see wiki
May 20, 2014
d102ecd
replace {{humanClassName}} and {{machineClassName}}
May 20, 2014
1ecb555
Fixing tests broken due to copyright timestamp
S2MBO Mar 9, 2015
13f0cfb
Merge pull request #23 from S2MBO/feature/refactor
netbe Mar 9, 2015
26b6288
Added package parameter for Java code generation
S2MBO Mar 12, 2015
40cbdab
Templates for Android code generation
S2MBO Mar 11, 2015
16e5bb5
Unified Android and iOS code generation
S2MBO Mar 12, 2015
b587191
Renamed ObjectiveCCodeGenerator.py to SourceCodeGenerator
S2MBO Mar 12, 2015
c35c5d8
Respecting suffix in class names.
S2MBO Mar 16, 2015
d9c1bf9
Moved member variable's definitions up and added some whitespace.
S2MBO Mar 16, 2015
e1b249f
Merge pull request #26 from S2MBO/feature/refactor
Mar 18, 2015
836833c
Improved test portability to fix sinnerschrader-mobile/metaJSON#28
S2MBO Mar 20, 2015
1cd0e33
Merge pull request #29 from S2MBO/test_port
netbe Apr 8, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Exclude .pyc (compile python file) files
*.pyc

# Default ouptut folder
src/
build/
dist/
*.egg-info
classes/
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: python
python:
- "2.7"

# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: nosetests
443 changes: 0 additions & 443 deletions JavaCodeGenerator.py

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include metajson/templates *
1,032 changes: 0 additions & 1,032 deletions ObjectiveCCodeGenerator.py

This file was deleted.

53 changes: 12 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,31 @@ metaJSON provides a meta language to generate object models for several language

## Usage

1. Write your JSON scheme according to the JSON spec of your backend (for yaml, please see details below)
1. Write your [JSON scheme](https://github.com/sinnerschrader-mobile/metaJSON/wiki/Protocol) according to the JSON spec of your backend
2. Run the script

```
# python readJSON.py -h

readJSON.py [ -p | -t | -o | -s ] [-i]
# metajson -h
Options:
-v, --version shows version
-h, --help shows help
-p, --prefix= project prefix (default: S2M)
-s, --suffix= classname suffix (default: JSONObject). Use "-s false" for no suffix
-t, --target= target platform iOS or Android (default: iOS)
-i, --input= meta-JSON file to read
-o, --output= ouput path of generated source codes
-p, --prefix= project prefix (default: S2M)
-s, --suffix= classname suffix (default: JSONObject). Use "-s false" for no suffix
-i, --input= meta-JSON file to read
-o, --output= ouput path of generated source codes (default: src)
--template= template directory to use to generate code
--package= name of the generated package (default: none)
```

A working sample call could look like that:
```
# python readJSON.py --p GitHub -t Android -i github-scheme.json -o com/example/project/android/json
# metajson --p GitHub -i github-scheme.json -o com/example/project/android/json --template=metajson/templates/Android --package=com.example.project.android.json
```
The result of that call will be generated Java code in the folder "com". The java package structure and definition will be there, so you just need to copy the folder in your project structure. It is ready to be used.

<!--
## Yaml

if you prefer to use yaml as a description language, you will need to install the converter via npm:

```
npm install -g yamljs
```

#### Converting YAML to JSON

Example:

```
yaml2json --pretty --indentation 6 test.yaml > test.json
```

#### Converting JSON to YAML

Example:

```
json2yaml -d 5 test.json > test.yaml
```
-->

## Documentation

See MetaJSONProtocol.md file in the doc folder.

## Known issues
Please check the issue tracker and/or refer to the known_issues.md file in the doc folder.
See [Wiki](https://github.com/sinnerschrader-mobile/metaJSON/wiki)

## License
The project is published with the MIT License. Please read the LICENSE.txt for more details.
The project is published with the MIT License. Please read the LICENSE.txt for more details.
Loading